Gaillard Pierre-Olivier <[EMAIL PROTECTED]> writes:

| "Lars Gullik Bjønnes" wrote:
| > 
| > Gaillard Pierre-Olivier <[EMAIL PROTECTED]> writes:
| > 
| > |  XMLAttributes is a subclass of map<string,string> that defines a method
| > | "set(string name, int value)".
| > 
| > By adding a [] operator you can at least make things a bit nicer.
| > 
|  I tried this (see lower) but since it is a conversion problem is seems
| I should redefine "=" operator 
| or define a converter from int to string.

Hmmm, yes... this should be possible by not inheriting from map, but
instead use map as a member variable. I belive that will make the
design better too.

| > |  What do you think, may I write new Lyx 'Write' methods in the same
| > | style ? In languages like Python the
| > |  code is even nicer, but maybe Lars would know how to make this code
| > | nicer in C++.
| > 
| > How is it done in Python?
| > 
|  In Python dictionnaries (maps) are native, so you can write something
| like :
|   xmlOut.startElement("LyxTabular", {"version" : "1.0", "option" :
| "xml"})
|  Also you don't need to manage your memory and you can put any type of
| data 
| in your dictionnary. So that ints work as well as strings without any
| effort.

So we should be albe to have something like:

xmlOut.startElement("LyxTabular").subE("version", "1.0").subE("option", "xml");

if we want to. And if we make subE an template member we can use it to
insert types of any kind. (as long as they can be converted to string
with tostr (support/lstrings.h))


|  that method 'set' was OK. I believe I need a subclass of string (e.g.
| ValueString) that provides a constructor :
|   ValueString(int i). 
|  But I am not used to C++ so I did not do that. If you think I should I
| can do it on wednesday evening.

This should not be needed, and is not adviced anyway.

| > Or is set a template?
| > What is XMLAttributes really?
| >
|  Well just a map<string, string> with an additional 'set' method that
| uses strstream to build a string from the int value it was passed. You
| can check this in the files I sent to you and Juergen ).

I did right after reading your patch. (tar.gz)

|  As far as release-time is concerned, I need this XML file-format at
| work (I need to emulate some Interleaf features soon, so I need to be
| able to manage LyX files in Python scripts) but I am afraid that 1.1.6
| would not be ready in-time anyway (that is even if XML file-format did
| not introduce any delay... which is questionable), so that I will have
| to make the scripts for the current LyX format. Then when the XML format
| is available I can upgrade my scripts easily and make them robust.
|  
|       Thanks for your help, I expect to write other XML write methods on
| wednesday but if you have comments I will 
| rewrite the things until we get something clean. 

Ok.

        Lgb

Reply via email to