Class for xml code generation It should be used for generation of xml steramers, which could be used outside root environment. This means, that with help of such streamers user can read and write objects from/to xml file, which later can be accepted by ROOT. At the moment supported only classes, which are not inherited from TObject and which not contains any TObject members. To generate xml code: 1. ROOT library with required classes should be created. In general, without such library non of user objects can be stored and retrived from any ROOT file 2. Generate xml streamers by root script like: void generate() { gSystem->Load("libRXML.so"); // load ROOT xml library gSystem->Load("libuser.so"); // load user ROOT library TList lst; lst.Add(TClass::GetClass("TUserClass1")); lst.Add(TClass::GetClass("TUserClass2")); TXMLPlayer player; player.ProduceCode(&lst, "streamers"); // create xml streamers } 3. Copy "streamers.h", "streamers.cxx", "TXmlFile.h", "TXmlFile.cxx" files to user project and compile them. TXmlFile class implementation can be taken from http://www-linux.gsi.de/~linev/xmlfile.tar.gz TXMLPlayer class generates one function per class, which called class streamer. Name of such function for class TExample will be TExample_streamer. Following data members for streamed classes are supported: - simple data types (int, double, float) - array of simple types (int[5], double[5][6]) - dynamic array of simple types (int* with comment field // [fSize]) - const char* - object of any nonROOT class - pointer on object - array of objects - array of pointers on objects - stl string - stl vector, list, deque, set, multiset, map, multimap - allowed arguments for stl containers are: simple data types, string, object, pointer on object Any other data member can not be (yet) read from xml file and write to xml file. If data member of class is private or protected, it can not be accessed via member name. Two alternative way is supported. First, if for class member fValue exists function GetValue(), it will be used to get value from the class, and if exists SetValue(), it will be used to set apropriate data member. Names of setter and getter methods can be specified in comments filed like: int fValue; // *OPTION={GetMethod="GetV";SetMethod="SetV"} If getter or setter methods does not available, address to data member will be calculated as predefined offeset to object start address. In that case generated code should be used only on the same platform (OS + compiler), where it was generated. Generated streamers resolve inheritance tree for given class. This allows to have array (or vector) of object pointers on some basic class, while objects of derived class(es) are used. To access data from xml files, user should use TXmlFile class, which is different from ROOT TXMLFile, but provides very similar functionality. For example, to read object from xml file: TXmlFile file("test.xml"); // open xml file file.ls(); // show list of keys in file TExample* ex1 = (TExample*) file.Get("ex1", TExample_streamer); // get object file.Close(); To write object to file: TXmlFile outfile("test2.xml", "recreate"); // create xml file TExample* ex1 = new TExample; outfile.Write(ex1, "ex1", TExample_streamer); // write object to file outfile.Close(); Complete example for generating and using of external xml streamers can be taken from http://www-linux.gsi.de/~linev/xmlreader.tar.gz Any bug reports and requests for additional functionality are welcome. Sergey Linev, S.Linev@gsi.de
TXMLPlayer() | |
TXMLPlayer(const TXMLPlayer&) | |
virtual | ~TXMLPlayer() |
void | TObject::AbstractMethod(const char* method) const |
virtual void | TObject::AppendPad(Option_t* option = "") |
virtual void | TObject::Browse(TBrowser* b) |
static TClass* | Class() |
virtual const char* | TObject::ClassName() const |
virtual void | TObject::Clear(Option_t* = "") |
virtual TObject* | TObject::Clone(const char* newname = "") const |
virtual Int_t | TObject::Compare(const TObject* obj) const |
virtual void | TObject::Copy(TObject& object) const |
virtual void | TObject::Delete(Option_t* option = "")MENU |
virtual Int_t | TObject::DistancetoPrimitive(Int_t px, Int_t py) |
virtual void | TObject::Draw(Option_t* option = "") |
virtual void | TObject::DrawClass() constMENU |
virtual TObject* | TObject::DrawClone(Option_t* option = "") constMENU |
virtual void | TObject::Dump() constMENU |
virtual void | TObject::Error(const char* method, const char* msgfmt) const |
virtual void | TObject::Execute(const char* method, const char* params, Int_t* error = 0) |
virtual void | TObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0) |
virtual void | TObject::ExecuteEvent(Int_t event, Int_t px, Int_t py) |
virtual void | TObject::Fatal(const char* method, const char* msgfmt) const |
virtual TObject* | TObject::FindObject(const char* name) const |
virtual TObject* | TObject::FindObject(const TObject* obj) const |
virtual Option_t* | TObject::GetDrawOption() const |
static Long_t | TObject::GetDtorOnly() |
virtual const char* | TObject::GetIconName() const |
virtual const char* | TObject::GetName() const |
virtual char* | TObject::GetObjectInfo(Int_t px, Int_t py) const |
static Bool_t | TObject::GetObjectStat() |
virtual Option_t* | TObject::GetOption() const |
virtual const char* | TObject::GetTitle() const |
virtual UInt_t | TObject::GetUniqueID() const |
virtual Bool_t | TObject::HandleTimer(TTimer* timer) |
virtual ULong_t | TObject::Hash() const |
virtual void | TObject::Info(const char* method, const char* msgfmt) const |
virtual Bool_t | TObject::InheritsFrom(const char* classname) const |
virtual Bool_t | TObject::InheritsFrom(const TClass* cl) const |
virtual void | TObject::Inspect() constMENU |
void | TObject::InvertBit(UInt_t f) |
virtual TClass* | IsA() const |
virtual Bool_t | TObject::IsEqual(const TObject* obj) const |
virtual Bool_t | TObject::IsFolder() const |
Bool_t | TObject::IsOnHeap() const |
virtual Bool_t | TObject::IsSortable() const |
Bool_t | TObject::IsZombie() const |
virtual void | TObject::ls(Option_t* option = "") const |
void | TObject::MayNotUse(const char* method) const |
virtual Bool_t | TObject::Notify() |
void | TObject::Obsolete(const char* method, const char* asOfVers, const char* removedFromVers) const |
static void | TObject::operator delete(void* ptr) |
static void | TObject::operator delete(void* ptr, void* vp) |
static void | TObject::operator delete[](void* ptr) |
static void | TObject::operator delete[](void* ptr, void* vp) |
void* | TObject::operator new(size_t sz) |
void* | TObject::operator new(size_t sz, void* vp) |
void* | TObject::operator new[](size_t sz) |
void* | TObject::operator new[](size_t sz, void* vp) |
TXMLPlayer& | operator=(const TXMLPlayer&) |
virtual void | TObject::Paint(Option_t* option = "") |
virtual void | TObject::Pop() |
virtual void | TObject::Print(Option_t* option = "") const |
Bool_t | ProduceCode(TList* cllist, const char* filename) |
virtual Int_t | TObject::Read(const char* name) |
virtual void | TObject::RecursiveRemove(TObject* obj) |
void | TObject::ResetBit(UInt_t f) |
virtual void | TObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU |
virtual void | TObject::SavePrimitive(ostream& out, Option_t* option = "") |
void | TObject::SetBit(UInt_t f) |
void | TObject::SetBit(UInt_t f, Bool_t set) |
virtual void | TObject::SetDrawOption(Option_t* option = "")MENU |
static void | TObject::SetDtorOnly(void* obj) |
static void | TObject::SetObjectStat(Bool_t stat) |
virtual void | TObject::SetUniqueID(UInt_t uid) |
virtual void | ShowMembers(TMemberInspector&) |
virtual void | Streamer(TBuffer&) |
void | StreamerNVirtual(TBuffer& ClassDef_StreamerNVirtual_b) |
virtual void | TObject::SysError(const char* method, const char* msgfmt) const |
Bool_t | TObject::TestBit(UInt_t f) const |
Int_t | TObject::TestBits(UInt_t f) const |
virtual void | TObject::UseCurrentStyle() |
virtual void | TObject::Warning(const char* method, const char* msgfmt) const |
virtual Int_t | TObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) |
virtual Int_t | TObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const |
virtual void | TObject::DoError(int level, const char* location, const char* fmt, va_list va) const |
const char* | ElementGetter(TClass* cl, const char* membername, int specials = 0) |
const char* | ElementSetter(TClass* cl, const char* membername, char* endch) |
TString | GetBasicTypeName(TStreamerElement* el) |
TString | GetBasicTypeReaderMethodName(Int_t type, const char* realname) |
TString | GetMemberTypeName(TDataMember* member) |
TString | GetStreamerName(TClass* cl) |
void | TObject::MakeZombie() |
Bool_t | ProduceSTLstreamer(ostream& fs, TClass* cl, TStreamerSTL* el, Bool_t isWriting) |
void | ProduceStreamerSource(ostream& fs, TClass* cl, TList* cllist) |
void | ReadSTLarg(ostream& fs, TString& argname, int argtyp, Bool_t isargptr, TClass* argcl, TString& tname, TString& ifcond) |
void | WriteSTLarg(ostream& fs, const char* accname, int argtyp, Bool_t isargptr, TClass* argcl) |
enum TObject::EStatusBits { | kCanDelete | |
kMustCleanup | ||
kObjInCanvas | ||
kIsReferenced | ||
kHasUUID | ||
kCannotPick | ||
kNoContextMenu | ||
kInvalidObject | ||
}; | ||
enum TObject::[unnamed] { | kIsOnHeap | |
kNotDeleted | ||
kZombie | ||
kBitMask | ||
kSingleKey | ||
kOverwrite | ||
kWriteDelete | ||
}; |
Produce streamers for provide class list TList should include list of classes, for which code should be generated. filename specify name of file (without extension), where streamers should be created. Function produces two files: header file and source file. For instance, if filename is "streamers", files "streamers.h" and "streamers.cxx" will be created.
returns name of simple data type for given data member
return simple data types for given TStreamerElement object
return functions name to read simple data type from xml file
produce code to access member of given class. Parameter specials has following meaning: 0 - nothing special 1 - cast to data type 2 - produce pointer on given member 3 - skip casting when produce pointer by buf.P() function
Produce code to set value to given data member. endch should be output after value is specified.
Produce source code of streamer function for specified class
Produce code to read argument of stl container from xml file
Produce code to write argument of stl container to xml file
Produce code of xml streamer for data member of stl type