> There is more to externalising than speed.

Agreed. And the string solution is not even slow...

> ...
> You would have done better to argue for a strstream solution in your
> original proposal so we could just add a strstream operator<< and
> operator>> for data objects like PrinterParams etc.

Well, using strings means using stringstreams for conversion.  I was not
arguing for anything else. Maybe a year ago I'd have used strstreams,
but that's solved now... I am growing up, too.

> or delete a variable from the data structure.  We could add the type_info
> within the operator<< like this to get some extra checking (assuming my
> imagined stream operators exist) or just use a string name:
> 
> stringstream & operator<< (stringstream & ss, PrinterParams const & pp)

  ^^^^^^^^^^^^  this should work with any ostream.

> {
>       // can we export type_info to a stream?
>       return ss << type_info(pp) ...

This is possible but not acceptable for anything external since type_info
can/will depend on compiler and platform.

I can see, however, no problem with your alternative 'a string name' as in

    return ss << "printerparam " << ... 

> stringstream & operator>> (stringstream & ss, PrinterParams & pp)
> {
>       Assert (ss[0] == type_info(pp))
>       // how do you extract the type_info from a stream?

If you pass strings around instead of streams, you simply check the first
"word" in the string.  Streams are inherently write/read once, everything
else is a kludge.

Another option to uniformaly pass complex information around is some data
structure that resembles XML, i.e. 

struct info 
{
        string name_;                       //  "printerparam"  
        map<string, string> parameters_;    //  "target"->"..", "duplex"->"1"...
        string contents_;                   //   empty in this case
        vector<string> nested_;             //   empty in this case
} 

with content similar to lyxtext, i.e. "normal text" with a special marker
for the nested elements (aka "LyX Insets").  This can be made pretty
fast, I use variations of this in Real Live (i.e.  the programming I do to
earn a living). In the context of a heavy user interface (like LyX) it is
not even noticable.

Andre'

> P.S.  I see you wrote this on Friday so I guess I've taken your flame bait

It was just a small bait, but the time was certainly right ;-)

I am much more relaxed about LyX development nowadays than I was some
time ago. Maybe this is because I haven't used LyX much lately, so I can
consider looking at the sources as a mere hobby and not as "fixing a tool I
desperately need for work". Or, maybe it is because I see progress in a
direction that I like. I don't really know...

-- 
Andre' Poenitz ........................................ [EMAIL PROTECTED]

Reply via email to