Re: [ROOT] Human readable/writeable I/O?

From: Brett Viren (bv@bnl.gov)
Date: Wed Jan 23 2002 - 16:33:24 MET


Thanks Rene and Valeriy.

Implementing SavePrimitive() seems like it should work, I'll give it a
try.

One thing:  Assuming I produce output which looks something like:

    // output.C file:
    Registry* reg = new Registry()
    reg->Set("key1","val1");
    reg->Set("key2",42);
    reg->Set("key3",6.9);

    Registry* reg2 = new Registry();
    reg2->Set("key1","1lav");
    reg2->Set("key2",24);
    reg2->Set("key3",9.6);

    reg->Set("reg2",*reg2);

    // more state initializations ....

After having CINT read this file back in, I am unsure how to get the
pointer (reg) to the created Registry object from CINT into my
compiled code.  Also, do I need to explictly tell CINT to delete the
created pointers (reg and reg2 in the example above)?

Thanks,
-Brett.


Rene Brun writes:
 > Hi Brett,
 > 
 > As already indicated by Valery, implementing MyClass::SavePrimitive
 > is the solution to your problem if you want a readable version of the file.
 > SavePrimitive is implemented for most ROOT classes that appear in a canvas:
 > all graphics primitives, TGraph, TH1, TCanvas, TPad, etc.
 > In SavePrimitive, you generate the C++ code to rebuild the objects with
 > their attributes. This code can be edited and reexecuted by CINT again.
 > I strongly encourage people to implement the SavePrimitive function
 > for their classes.
 > 
 > I am also considering the generation of ascii files via the TStreamerInfo
 > class. XML is a likely choice. I agree with you that XML is NOT an input
 > format. I have seen that most attempts to use XML as an input format have
 > failed so far. But XML is a good candidate for an interchange format
 > between different applications when the volume of data to be exchanged is small.
 > The problem is not writing the XML file, but the choice of a good DTD.
 > 
 > Rene Brun
 > 
 > Brett Viren wrote:
 > > 
 > > Hi,
 > > 
 > > I have a container class: a heterogeneous map from string keys to
 > > values of type char, int, double, string and itself (that is, it can
 > > be used to form a hierarchical tree).  Currently it can be be
 > > read/written via ROOT streamers.  It is typically used to hold
 > > configuration data.
 > > 
 > > I am looking for a way to write it out as plain text in a form that
 > > can be edited in a text editor and subsequently read back in.
 > > 
 > > Does anyone have any ideas?  (Please, no XML).
 > > 
 > > Thanks,
 > > -Brett.



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:39 MET