151 if (cl==0)
return "";
167 if ((cllist==0) || (filename==0))
return kFALSE;
169 std::ofstream fh(
TString(filename)+
".h");
170 std::ofstream fs(
TString(filename)+
".cxx");
172 fh <<
"// generated header file" << std::endl << std::endl;
173 fh <<
"#ifndef " << filename <<
"_h" << std::endl;
174 fh <<
"#define " << filename <<
"_h" << std::endl << std::endl;
178 fs <<
"// generated source file" << std::endl << std::endl;
179 fs <<
"#include \"" << filename <<
".h\"" << std::endl << std::endl;
186 while ((cl = (
TClass*) iter()) != 0) {
201 while ((cl = (
TClass*) iter()) != 0) {
204 <<
names_xmlfileclass <<
" &buf, void* ptr = 0, bool checktypes = true);" << std::endl << std::endl;
209 fh <<
"#endif" << std::endl << std::endl;
210 fs << std::endl << std::endl;
220 if (member==0)
return "int";
226 case kInt_t:
return "int";
235 if ((first==
'B') || (first==
'b'))
return "bool";
236 return "unsigned char";
240 case kUInt_t:
return "unsigned int";
241 case kULong_t:
return "unsigned long";
245 if (member->
IsEnum())
return "int";
269 if ((first==
'B') || (first==
'b'))
return "bool";
270 return "unsigned char";
302 if (isbool)
return "ReadBool";
354 if ((specials==1) && (member!=0)) {
363 if ((specials==2) && (member!=0)) {
417 if (elements==0)
return;
419 fs <<
"//__________________________________________________________________________" << std::endl;
422 fs <<
"{" << std::endl;
423 fs <<
tab1 << cl->
GetName() <<
" *obj = (" << cl->
GetName() <<
"*) ptr;" << std::endl;
425 fs <<
tab1 <<
"if (buf.IsReading()) { " << std::endl;
431 while ((c1 = (
TClass*) iter()) != 0) {
432 if (c1==cl)
continue;
435 fs <<
tab2 <<
"if (checktypes) {" << std::endl;
436 fs <<
tab3 <<
"void* ";
441 <<
"(buf, dynamic_cast<" << c1->
GetName() <<
"*>(obj));" << std::endl;
442 fs << tab3 <<
"if (res) return dynamic_cast<" << cl->
GetName()
443 <<
"*>(("<< c1->
GetName() <<
" *) res);" << std::endl;
445 if (!firstchild) fs <<
tab2 <<
"}" << std::endl;
447 fs <<
tab2 <<
"if (!buf.CheckClassNode(\"" << cl->
GetName() <<
"\", " 450 fs <<
tab2 <<
"if (obj==0) obj = new " << cl->
GetName() <<
";" << std::endl;
453 for (n=0;n<=elements->
GetLast();n++) {
481 <<
"(\"" << el->
GetName() <<
"\")" << endch <<
";" << std::endl;
501 fs <<
tab2 <<
"buf.ReadArray(" 504 <<
", \"" << el->
GetName() <<
"\");" << std::endl;
526 std::cout <<
"fatal error with TStreamerBasicPointer" << std::endl;
534 fs <<
", \"" << el->
GetName() <<
"\", true)" << endch <<
";" << std::endl;
542 fs <<
", \"" << el->
GetName() <<
"\")" << endch <<
";" << std::endl;
549 <<
"*>(obj), false);" << std::endl;
559 <<
", \"" << el->
GetName() <<
"\", " 563 fs <<
", \"" << el->
GetName() <<
"\", " 577 <<
", \"" << el->
GetName() <<
"\", " 585 <<
"*) buf.ReadObjectPtr(\"" << el->
GetName() <<
"\", " 587 <<
")" <<endch <<
";" << std::endl;
595 fs <<
", \"" << el->
GetName() <<
"\", " 605 <<
"), \"" << el->
GetName() <<
"\", " 620 fs <<
tab2 <<
"// STL type = " << elstl->
GetSTLtype() << std::endl;
625 <<
"\"); // sinfo type " << el->
GetType()
627 <<
" not supported" << std::endl;
630 fs <<
tab2 <<
"buf.EndClassNode();" << std::endl;
632 fs <<
tab1 <<
"} else {" << std::endl;
636 fs <<
tab2 <<
"if (obj==0) return 0;" << std::endl;
640 while ((c1 = (
TClass*) iter()) != 0) {
641 if (c1==cl)
continue;
645 fs <<
tab2 <<
"if (checktypes) {" << std::endl;
647 fs <<
tab3 <<
"if (dynamic_cast<" << c1->
GetName() <<
"*>(obj))" << std::endl;
650 if (!firstchild) fs <<
tab2 <<
"}" << std::endl;
652 fs <<
tab2 <<
"buf.StartClassNode(\"" << cl->
GetName() <<
"\", " 655 for (n=0;n<=elements->
GetLast();n++) {
680 fs <<
tab2 <<
"buf.WriteValue(";
685 fs <<
", \"" << el->
GetName() <<
"\");" << std::endl;
705 fs <<
tab2 <<
"buf.WriteArray(" 708 <<
", \"" << el->
GetName() <<
"\");" << std::endl;
729 std::cout <<
"fatal error with TStreamerBasicPointer" << std::endl;
734 <<
", \"" << el->
GetName() <<
"\", true);" << std::endl;
740 <<
", \"" << el->
GetName() <<
"\");" << std::endl;
747 <<
"*>(obj), false);" << std::endl;
757 <<
", \"" << el->
GetName() <<
"\", " 761 fs <<
", \"" << el->
GetName() <<
"\", " 773 <<
", \"" << el->
GetName() <<
"\", " 777 fs <<
", \"" << el->
GetName() <<
"\", " 785 fs <<
", \"" << el->
GetName() <<
"\", " 794 <<
"), \"" << el->
GetName() <<
"\", " 808 fs <<
tab2 <<
"// STL type = " << elstl->
GetSTLtype() << std::endl;
813 fs <<
tab2 <<
"buf.MakeEmptyMember(\"" << el->
GetName()
814 <<
"\"); // sinfo type " << el->
GetType()
816 <<
" not supported" << std::endl;
819 fs <<
tab2 <<
"buf.EndClassNode();" << std::endl;
821 fs <<
tab1 <<
"}" << std::endl;
822 fs <<
tab1 <<
"return obj;" << std::endl;
823 fs <<
"}" << std::endl << std::endl;
854 fs << tname <<
" " << argname <<
" = buf." 860 fs << tname << (isargptr ?
" ":
" *") << argname <<
" = " 861 <<
"(" << argcl->
GetName() <<
"*)" 862 <<
"buf.ReadObjectPtr(0, " 865 if (ifcond.
Length()>0) ifcond+=
" && ";
875 fs <<
"string *" << argname <<
" = " 876 <<
"buf.ReadSTLstring();" << std::endl;
878 if (ifcond.
Length()>0) ifcond+=
" && ";
888 fs <<
"/* argument " << argname <<
" not supported */";
914 fs <<
"buf.WriteValue(" << accname <<
", 0);" << std::endl;
919 fs <<
"buf.WriteObjectPtr(";
923 fs <<
"&(" << accname <<
")";
929 fs <<
"buf.WriteSTLstring(";
933 fs <<
"&(" << accname <<
")";
934 fs <<
");" << std::endl;
939 fs <<
"/* argument not supported */" << std::endl;
948 if ((cl==0) || (el==0))
return false;
966 std::vector<std::string> splitName;
984 default:
return false;
987 for(
int n=0;
n<narg;
n++) {
1000 int pstar = buf.
Index(
"*");
1005 while ((pstar>0) && (buf[pstar]==
' ')) pstar--;
1008 isargptr[
n] =
false;
1010 if (buf.
Index(
"const ")==0) {
1012 while ((buf.
Length()>0) && (buf[0]==
' ')) buf.
Remove(0,1);
1016 if (dt) argtype[
n] = dt->
GetType();
else 1023 if (argtype[
n]<0) stltyp = -1;
1026 if (stltyp<0)
return false;
1029 Bool_t akaarrayaccess = (narg==1) && (argtype[0]<20);
1031 char tabs[30], tabs2[30];
1035 fs <<
tab2 <<
"if (buf.StartSTLnode(\"" 1042 if (isarr) { fs <<
"**cont"; accname =
"(*cont)->"; }
1043 else { fs <<
"*cont"; accname =
"cont->"; }
1045 if (isarr) { fs <<
"*cont"; accname =
"cont->"; }
1046 else { fs <<
"&cont"; accname =
"cont."; }
1051 fs <<
"*dynamic_cast<" << contcl->
GetName() <<
"*>(obj);" << std::endl;
1056 strlcpy(tabs,
tab4,
sizeof(tabs));
1059 strlcpy(tabs,
tab3,
sizeof(tabs));
1061 strlcpy(tabs2, tabs,
sizeof(tabs2));
1064 strlcat(tabs2,
tab1,
sizeof(tabs2));
1065 fs << tabs <<
"if (" << (isarr ?
"*cont" :
"cont") <<
"==0) {" << std::endl;
1066 fs << tabs2 <<
"buf.WriteSTLsize(0" << (isstr ?
",true);" :
");") << std::endl;
1067 fs << tabs <<
"} else {" << std::endl;
1070 fs << tabs2 <<
"buf.WriteSTLsize(" << accname
1071 << (isstr ?
"length(), true);" :
"size());") << std::endl;
1074 fs << tabs2 <<
"buf.WriteSTLstringData(" << accname <<
"c_str());" << std::endl;
1076 if (akaarrayaccess) {
1077 fs << tabs2 << argtname[0] <<
"* arr = new " << argtname[0]
1078 <<
"[" << accname <<
"size()];" << std::endl;
1079 fs << tabs2 <<
"int k = 0;" << std::endl;
1082 fs << tabs2 << contcl->
GetName() <<
"::const_iterator iter;" << std::endl;
1083 fs << tabs2 <<
"for (iter = " << accname <<
"begin(); iter != " 1084 << accname <<
"end(); iter++)";
1085 if (akaarrayaccess) {
1086 fs << std::endl << tabs2 <<
tab1 <<
"arr[k++] = *iter;" << std::endl;
1087 fs << tabs2 <<
"buf.WriteArray(arr, " << accname <<
"size(), 0, false);" << std::endl;
1088 fs << tabs2 <<
"delete[] arr;" << std::endl;
1091 fs << std::endl << tabs2 <<
tab1;
1092 WriteSTLarg(fs,
"*iter", argtype[0], isargptr[0], argcl[0]);
1095 fs <<
" {" << std::endl;
1096 fs << tabs2 <<
tab1;
1097 WriteSTLarg(fs,
"iter->first", argtype[0], isargptr[0], argcl[0]);
1098 fs << tabs2 <<
tab1;
1099 WriteSTLarg(fs,
"iter->second", argtype[1], isargptr[1], argcl[1]);
1100 fs << tabs2 <<
"}" << std::endl;
1104 if (isptr) fs << tabs <<
"}" << std::endl;
1108 fs << tabs <<
"cont++;" << std::endl;
1110 fs << tabs <<
"(void*) cont = (char*) cont + sizeof(" << contcl->
GetName() <<
");" << std::endl;
1111 fs <<
tab3 <<
"}" << std::endl;
1114 fs <<
tab3 <<
"buf.EndSTLnode();" << std::endl;
1115 fs <<
tab2 <<
"}" << std::endl;
1120 fs <<
tab2 <<
"if (buf.VerifySTLnode(\"" 1126 if (isarr) { fs <<
"**cont"; accname =
"(*cont)->"; accptr =
"*cont"; }
1127 else { fs <<
"*cont"; accname =
"cont->"; accptr =
"cont"; }
1129 if (isarr) { fs <<
"*cont"; accname =
"cont->"; }
1130 else { fs <<
"&cont"; accname =
"cont."; }
1135 fs <<
"*dynamic_cast<" << contcl->
GetName() <<
"*>(obj);" << std::endl;
1140 strlcpy(tabs,
tab4,
sizeof(tabs));
1143 strlcpy(tabs,
tab3,
sizeof(tabs));
1145 fs << tabs <<
"int size = buf.ReadSTLsize(" << (isstr ?
"true);" :
");") << std::endl;
1148 fs << tabs <<
"delete " << accptr <<
";" << std::endl;
1149 fs << tabs <<
"if (size==0) " << accptr <<
" = 0;" << std::endl;
1150 fs << tabs <<
" else " << accptr <<
" = new " << contcl->
GetName() <<
";" << std::endl;
1154 fs <<
"cont" << endch <<
";" << std::endl;
1157 fs << tabs << accname << (isstr ?
"erase();" :
"clear();") << std::endl;
1161 fs << tabs <<
"if (size>0) " << accname <<
"assign(buf.ReadSTLstringData(size));" << std::endl;
1163 if (akaarrayaccess) {
1164 fs << tabs << argtname[0] <<
"* arr = new " << argtname[0] <<
"[size];" << std::endl;
1165 fs << tabs <<
"buf.ReadArray(arr, size, 0, false);" << std::endl;
1168 fs << tabs <<
"for(int k=0;k<size;k++)";
1170 if (akaarrayaccess) {
1171 fs << std::endl << tabs <<
tab1 << accname;
1173 fs <<
"insert";
else fs <<
"push_back";
1174 fs <<
"(arr[k]);" << std::endl;
1175 fs << tabs <<
"delete[] arr;" << std::endl;
1179 fs <<
" {" << std::endl << tabs <<
tab1;
1180 ReadSTLarg(fs, arg1, argtype[0], isargptr[0], argcl[0], argtname[0], ifcond);
1182 if (ifcond.
Length()>0) fs <<
"if (" << ifcond <<
") ";
1188 fs <<
"(" << arg1 <<
");" << std::endl;
1189 fs << tabs <<
"}" << std::endl;
1192 TString arg1(
"arg1"), arg2(
"arg2"), ifcond;
1193 fs <<
" {" << std::endl << tabs <<
tab1;
1194 ReadSTLarg(fs, arg1, argtype[0], isargptr[0], argcl[0], argtname[0], ifcond);
1196 ReadSTLarg(fs, arg2, argtype[1], isargptr[1], argcl[1], argtname[1], ifcond);
1198 if (ifcond.
Length()>0) fs <<
"if (" << ifcond <<
") ";
1199 fs << accname <<
"insert(make_pair(" 1200 << arg1 <<
", " << arg2 <<
"));" << std::endl;
1201 fs << tabs <<
"}" << std::endl;
1206 if (isptr) fs << tabs <<
"cont++;" << std::endl;
1207 else fs << tabs <<
"(void*) cont = (char*) cont + sizeof(" << contcl->
GetName() <<
");" << std::endl;
1208 fs <<
tab3 <<
"}" << std::endl;
1211 fs <<
tab3 <<
"buf.EndSTLnode();" << std::endl;
1212 fs <<
tab2 <<
"}" << std::endl;
virtual const char * GetName() const
Returns name of object.
TMethodCall * SetterMethod(TClass *cl)
Return a TMethodCall method responsible for setting the value of data member.
TList * GetListOfBases()
Return list containing the TBaseClass(es) of a class.
const char * GetTypeNameBasic() const
Return type name of this element in case the type name is not a standard basic type, return the basic type name known to CINT.
TMethodCall * GetterMethod(TClass *cl=0)
Return a TMethodCall method responsible for getting the value of data member.
TString GetTypeName()
Get basic type of typedef, e,g.
ROOT::ESTLType IsSTLCont(std::string_view type)
type : type name: vector<list<classA,allocator>,allocator> result: 0 : not stl container code of cont...
TXMLSetup fXmlSetup
buffer for name of setter method
const char * GetDeclFileName() const
const char * names_xmlfileclass
TXMLPlayer()
default constructor
virtual void Delete(Option_t *option="")
Remove all objects from the array AND delete all heap based objects.
All ROOT classes may have RTTI (run time type identification) support added.
int GetSplit(const char *type, std::vector< std::string > &output, int &nestedLoc, EModType mode=TClassEdit::kNone)
Stores in output (after emptying it) the split type.
void ProduceStreamerSource(std::ostream &fs, TClass *cl, TList *cllist)
Produce source code of streamer function for specified class.
Bool_t IsEnum() const
Return true if data member is an enum.
virtual TClass * GetClassPointer() const
Returns a pointer to the TClass of this element.
TVirtualStreamerInfo * GetStreamerInfo(Int_t version=0) const
returns a pointer to the TVirtualStreamerInfo object for version If the object does not exist...
const char * GetTypeName() const
Get type of data member, e,g.: "class TDirectory*" -> "TDirectory".
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Int_t GetArrayLength() const
TObject * At(Int_t idx) const
Int_t GetArrayDim() const
TString GetBasicTypeReaderMethodName(Int_t type, const char *realname)
return functions name to read simple data type from xml file
Bool_t IsaPointer() const
Return true if the data member is a pointer.
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
TString GetStreamerName(TClass *cl)
returns streamer function name for given class
Bool_t ProduceSTLstreamer(std::ostream &fs, TClass *cl, TStreamerSTL *el, Bool_t isWriting)
Produce code of xml streamer for data member of stl type.
Bool_t IsBasic() const
Return true if data member is a basic type, e.g. char, int, long...
virtual Int_t GetClassVersion() const =0
The TNamed class is the base class for all named ROOT classes.
virtual TObject * FindObject(const char *name) const
Find an object in this collection using its name.
Long_t Property() const
Get property description word. For meaning of bits see EProperty.
Long_t Property() const
Get property description word. For meaning of bits see EProperty.
TDataType * GetDataType() const
Method or function calling interface.
const char * ElementSetter(TClass *cl, const char *membername, char *endch)
Produce code to set value to given data member.
Bool_t ProduceCode(TList *cllist, const char *filename)
Produce streamers for provide class list TList should include list of classes, for which code should ...
TString GetBasicTypeName(TStreamerElement *el)
return simple data types for given TStreamerElement object
const char * GetMethodName() const
Int_t GetLast() const
Return index of last object in array.
const char * XmlGetElementName(const TStreamerElement *el)
return converted name for TStreamerElement
Basic data type descriptor (datatype information is obtained from CINT).
void ReadSTLarg(std::ostream &fs, TString &argname, int argtyp, Bool_t isargptr, TClass *argcl, TString &tname, TString &ifcond)
Produce code to read argument of stl container from xml file.
Int_t GetArrayDim() const
Return number of array dimensions.
The ROOT global object gROOT contains a list of all defined classes.
TClass * GetBaseDataMember(const char *datamember)
Return pointer to (base) class that contains datamember.
ROOT::ESTLType GetCollectionType() const
Return the 'type' of the STL the TClass is representing.
Long_t GetOffset() const
Get offset from "this".
TString & Remove(Ssiz_t pos)
TString fSetterName
buffer for name of getter method
TFunction * GetMethod()
Returns the TMethod describing the method to be executed.
virtual TObjArray * GetElements() const =0
virtual ~TXMLPlayer()
destructor of TXMLPlayer object
void WriteSTLarg(std::ostream &fs, const char *accname, int argtyp, Bool_t isargptr, TClass *argcl)
Produce code to write argument of stl container to xml file.
const char * ElementGetter(TClass *cl, const char *membername, int specials=0)
produce code to access member of given class.
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Mother of all ROOT objects.
TString GetMemberTypeName(TDataMember *member)
returns name of simple data type for given data member
const char * GetCountName() const
TDataMember * GetDataMember(const char *datamember) const
Return pointer to datamember object with name "datamember".
Abstract Interface class describing Streamer information for one class.
Bool_t IsaPointer() const
Return true if data member is a pointer.
const char * Data() const