166 if ((cllist == 0) || (filename == 0))
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 <<
" &buf, void* ptr = 0, bool checktypes = true);" << std::endl
210 fh <<
"#endif" << std::endl << std::endl;
211 fs << std::endl << std::endl;
228 case kInt_t:
return "int";
239 return "unsigned char";
243 case kUInt_t:
return "unsigned int";
244 case kULong_t:
return "unsigned long";
276 return "unsigned char";
365 if ((specials == 1) && (member != 0)) {
375 if ((specials == 2) && (member != 0)) {
435 fs <<
"//__________________________________________________________________________" << std::endl;
438 fs <<
"{" << std::endl;
439 fs <<
tab1 << cl->
GetName() <<
" *obj = (" << cl->
GetName() <<
"*) ptr;" << std::endl;
441 fs <<
tab1 <<
"if (buf.IsReading()) { " << std::endl;
447 while ((
c1 = (
TClass *)iter()) != 0) {
450 if (
c1->GetListOfBases()->FindObject(cl->
GetName()) == 0)
453 fs <<
tab2 <<
"if (checktypes) {" << std::endl;
454 fs <<
tab3 <<
"void* ";
458 fs <<
"res = " <<
GetStreamerName(
c1) <<
"(buf, dynamic_cast<" <<
c1->GetName() <<
"*>(obj));" << std::endl;
459 fs <<
tab3 <<
"if (res) return dynamic_cast<" << cl->
GetName() <<
"*>((" <<
c1->GetName() <<
" *) res);"
463 fs <<
tab2 <<
"}" << std::endl;
468 fs <<
tab2 <<
"if (obj==0) obj = new " << cl->
GetName() <<
";" << std::endl;
543 std::cout <<
"fatal error with TStreamerBasicPointer" << std::endl;
551 fs <<
", \"" << el->
GetName() <<
"\", true)" << endch <<
";" << std::endl;
559 fs <<
", \"" << el->
GetName() <<
"\")" << endch <<
";" << std::endl;
630 fs <<
tab2 <<
"// STL type = " << elstl->
GetSTLtype() << std::endl;
634 fs <<
tab2 <<
"buf.SkipMember(\"" << el->
GetName() <<
"\"); // sinfo type " << el->
GetType() <<
" of class "
638 fs <<
tab2 <<
"buf.EndClassNode();" << std::endl;
640 fs <<
tab1 <<
"} else {" << std::endl;
644 fs <<
tab2 <<
"if (obj==0) return 0;" << std::endl;
648 while ((
c1 = (
TClass *)iter()) != 0) {
651 if (
c1->GetListOfBases()->FindObject(cl->
GetName()) == 0)
655 fs <<
tab2 <<
"if (checktypes) {" << std::endl;
657 fs <<
tab3 <<
"if (dynamic_cast<" <<
c1->GetName() <<
"*>(obj))" << std::endl;
662 fs <<
tab2 <<
"}" << std::endl;
692 fs <<
tab2 <<
"buf.WriteValue(";
697 fs <<
", \"" << el->
GetName() <<
"\");" << std::endl;
739 std::cout <<
"fatal error with TStreamerBasicPointer" << std::endl;
811 fs <<
tab2 <<
"// STL type = " << elstl->
GetSTLtype() << std::endl;
815 fs <<
tab2 <<
"buf.MakeEmptyMember(\"" << el->
GetName() <<
"\"); // sinfo type " << el->
GetType()
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;
855 fs << tname << (isargptr ?
" " :
" *") << argname <<
" = "
856 <<
"(" << argcl->
GetName() <<
"*)"
857 <<
"buf.ReadObjectPtr(0, " <<
GetStreamerName(argcl) <<
");" << std::endl;
870 fs <<
"string *" << argname <<
" = "
871 <<
"buf.ReadSTLstring();" << std::endl;
883 default: fs <<
"/* argument " << argname <<
" not supported */";
909 fs <<
"buf.WriteValue(" << accname <<
", 0);" << std::endl;
914 fs <<
"buf.WriteObjectPtr(";
918 fs <<
"&(" << accname <<
")";
924 fs <<
"buf.WriteSTLstring(";
928 fs <<
"&(" << accname <<
")";
929 fs <<
");" << std::endl;
933 default: fs <<
"/* argument not supported */" << std::endl;
942 if ((cl == 0) || (el == 0))
961 std::vector<std::string> splitName;
979 default:
return false;
982 for (
int n = 0;
n < narg;
n++) {
996 int pstar = buf.
Index(
"*");
1001 while ((pstar > 0) && (buf[pstar] ==
' '))
1005 isargptr[
n] =
false;
1007 if (buf.
Index(
"const ") == 0) {
1009 while ((buf.
Length() > 0) && (buf[0] ==
' '))
1016 else if (buf ==
"string")
1031 Bool_t akaarrayaccess = (narg == 1) && (argtype[0] < 20);
1033 char tabs[30], tabs2[30];
1045 accname =
"(*cont)->";
1061 fs <<
"*dynamic_cast<" << contcl->
GetName() <<
"*>(obj);" << std::endl;
1066 strlcpy(tabs,
tab4,
sizeof(tabs));
1069 strlcpy(tabs,
tab3,
sizeof(tabs));
1071 strlcpy(tabs2, tabs,
sizeof(tabs2));
1074 strlcat(tabs2,
tab1,
sizeof(tabs2));
1075 fs << tabs <<
"if (" << (isarr ?
"*cont" :
"cont") <<
"==0) {" << std::endl;
1076 fs << tabs2 <<
"buf.WriteSTLsize(0" << (isstr ?
",true);" :
");") << std::endl;
1077 fs << tabs <<
"} else {" << std::endl;
1080 fs << tabs2 <<
"buf.WriteSTLsize(" << accname << (isstr ?
"length(), true);" :
"size());") << std::endl;
1083 fs << tabs2 <<
"buf.WriteSTLstringData(" << accname <<
"c_str());" << std::endl;
1085 if (akaarrayaccess) {
1086 fs << tabs2 << argtname[0] <<
"* arr = new " << argtname[0] <<
"[" << accname <<
"size()];" << std::endl;
1087 fs << tabs2 <<
"int k = 0;" << std::endl;
1090 fs << tabs2 << contcl->
GetName() <<
"::const_iterator iter;" << std::endl;
1091 fs << tabs2 <<
"for (iter = " << accname <<
"begin(); iter != " << accname <<
"end(); iter++)";
1092 if (akaarrayaccess) {
1093 fs << std::endl << tabs2 <<
tab1 <<
"arr[k++] = *iter;" << std::endl;
1094 fs << tabs2 <<
"buf.WriteArray(arr, " << accname <<
"size(), 0, false);" << std::endl;
1095 fs << tabs2 <<
"delete[] arr;" << std::endl;
1096 }
else if (narg == 1) {
1097 fs << std::endl << tabs2 <<
tab1;
1098 WriteSTLarg(fs,
"*iter", argtype[0], isargptr[0], argcl[0]);
1099 }
else if (narg == 2) {
1100 fs <<
" {" << std::endl;
1101 fs << tabs2 <<
tab1;
1102 WriteSTLarg(fs,
"iter->first", argtype[0], isargptr[0], argcl[0]);
1103 fs << tabs2 <<
tab1;
1104 WriteSTLarg(fs,
"iter->second", argtype[1], isargptr[1], argcl[1]);
1105 fs << tabs2 <<
"}" << std::endl;
1110 fs << tabs <<
"}" << std::endl;
1114 fs << tabs <<
"cont++;" << std::endl;
1116 fs << tabs <<
"(void*) cont = (char*) cont + sizeof(" << contcl->
GetName() <<
");" << std::endl;
1117 fs <<
tab3 <<
"}" << std::endl;
1120 fs <<
tab3 <<
"buf.EndSTLnode();" << std::endl;
1121 fs <<
tab2 <<
"}" << std::endl;
1132 accname =
"(*cont)->";
1150 fs <<
"*dynamic_cast<" << contcl->
GetName() <<
"*>(obj);" << std::endl;
1155 strlcpy(tabs,
tab4,
sizeof(tabs));
1158 strlcpy(tabs,
tab3,
sizeof(tabs));
1160 fs << tabs <<
"int size = buf.ReadSTLsize(" << (isstr ?
"true);" :
");") << std::endl;
1163 fs << tabs <<
"delete " << accptr <<
";" << std::endl;
1164 fs << tabs <<
"if (size==0) " << accptr <<
" = 0;" << std::endl;
1165 fs << tabs <<
" else " << accptr <<
" = new " << contcl->
GetName() <<
";" << std::endl;
1169 fs <<
"cont" << endch <<
";" << std::endl;
1172 fs << tabs << accname << (isstr ?
"erase();" :
"clear();") << std::endl;
1176 fs << tabs <<
"if (size>0) " << accname <<
"assign(buf.ReadSTLstringData(size));" << std::endl;
1178 if (akaarrayaccess) {
1179 fs << tabs << argtname[0] <<
"* arr = new " << argtname[0] <<
"[size];" << std::endl;
1180 fs << tabs <<
"buf.ReadArray(arr, size, 0, false);" << std::endl;
1183 fs << tabs <<
"for(int k=0;k<size;k++)";
1185 if (akaarrayaccess) {
1186 fs << std::endl << tabs <<
tab1 << accname;
1191 fs <<
"(arr[k]);" << std::endl;
1192 fs << tabs <<
"delete[] arr;" << std::endl;
1193 }
else if (narg == 1) {
1195 fs <<
" {" << std::endl << tabs <<
tab1;
1196 ReadSTLarg(fs, arg1, argtype[0], isargptr[0], argcl[0], argtname[0], ifcond);
1199 fs <<
"if (" << ifcond <<
") ";
1205 fs <<
"(" << arg1 <<
");" << std::endl;
1206 fs << tabs <<
"}" << std::endl;
1207 }
else if (narg == 2) {
1208 TString arg1(
"arg1"), arg2(
"arg2"), ifcond;
1209 fs <<
" {" << std::endl << tabs <<
tab1;
1210 ReadSTLarg(fs, arg1, argtype[0], isargptr[0], argcl[0], argtname[0], ifcond);
1212 ReadSTLarg(fs, arg2, argtype[1], isargptr[1], argcl[1], argtname[1], ifcond);
1215 fs <<
"if (" << ifcond <<
") ";
1216 fs << accname <<
"insert(make_pair(" << arg1 <<
", " << arg2 <<
"));" << std::endl;
1217 fs << tabs <<
"}" << std::endl;
1223 fs << tabs <<
"cont++;" << std::endl;
1225 fs << tabs <<
"(void*) cont = (char*) cont + sizeof(" << contcl->
GetName() <<
");" << std::endl;
1226 fs <<
tab3 <<
"}" << std::endl;
1229 fs <<
tab3 <<
"buf.EndSTLnode();" << std::endl;
1230 fs <<
tab2 <<
"}" << std::endl;
const char * names_xmlfileclass
TClass instances represent classes, structs and namespaces in the ROOT type system.
TDataMember * GetDataMember(const char *datamember) const
Return pointer to datamember object with name "datamember".
ROOT::ESTLType GetCollectionType() const
Return the 'type' of the STL the TClass is representing.
TVirtualStreamerInfo * GetStreamerInfo(Int_t version=0, Bool_t isTransient=kFALSE) const
returns a pointer to the TVirtualStreamerInfo object for version If the object does not exist,...
TClass * GetBaseDataMember(const char *datamember)
Return pointer to (base) class that contains datamember.
const char * GetDeclFileName() const
Return name of the file containing the declaration of this 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.
All ROOT classes may have RTTI (run time type identification) support added.
TMethodCall * SetterMethod(TClass *cl)
Return a TMethodCall method responsible for setting the value of data member.
Long_t GetOffset() const
Get offset from "this".
Int_t GetArrayDim() const
Return number of array dimensions.
Bool_t IsEnum() const
Return true if data member is an enum.
Bool_t IsBasic() const
Return true if data member is a basic type, e.g. char, int, long...
Bool_t IsaPointer() const
Return true if data member is a pointer.
TDataType * GetDataType() const
const char * GetTypeName() const
Get type of data member, e,g.: "class TDirectory*" -> "TDirectory".
TMethodCall * GetterMethod(TClass *cl=0)
Return a TMethodCall method responsible for getting the value of data member.
Long_t Property() const
Get property description word. For meaning of bits see EProperty.
Basic data type descriptor (datatype information is obtained from CINT).
TString GetTypeName()
Get basic type of typedef, e,g.
Long_t Property() const
Get property description word. For meaning of bits see EProperty.
Method or function calling interface.
const char * GetMethodName() const
TFunction * GetMethod()
Returns the TMethod describing the method to be executed.
The TNamed class is the base class for all named ROOT classes.
virtual const char * GetName() const
Returns name of object.
virtual void Delete(Option_t *option="")
Remove all objects from the array AND delete all heap based objects.
virtual TObject * FindObject(const char *name) const
Find an object in this collection using its name.
Int_t GetLast() const
Return index of last object in array.
TObject * At(Int_t idx) const
Mother of all ROOT objects.
const char * GetCountName() const
virtual TClass * GetClassPointer() const
Returns a pointer to the TClass of this element.
Int_t GetArrayDim() const
Int_t GetArrayLength() const
const char * GetTypeNameBasic() const
Return type name of this element in case the type name is not a standard basic type,...
Bool_t IsaPointer() const
Return true if the data member is a pointer.
const char * Data() const
TString & Remove(Ssiz_t pos)
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Abstract Interface class describing Streamer information for one class.
virtual TObjArray * GetElements() const =0
virtual Int_t GetClassVersion() const =0
TString GetMemberTypeName(TDataMember *member)
returns name of simple data type for 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 GetStreamerName(TClass *cl)
returns streamer function name for given class
TString fSetterName
buffer for name of getter method
const char * ElementGetter(TClass *cl, const char *membername, int specials=0)
produce code to access member of given class.
TXMLSetup fXmlSetup
buffer for name of setter method
virtual ~TXMLPlayer()
destructor of TXMLPlayer object
TString GetBasicTypeName(TStreamerElement *el)
return simple data types for given TStreamerElement object
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.
TXMLPlayer()
default constructor
TString GetBasicTypeReaderMethodName(Int_t type, const char *realname)
return functions name to read simple data type from xml file
void ProduceStreamerSource(std::ostream &fs, TClass *cl, TList *cllist)
Produce source code of streamer function for specified 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.
const char * ElementSetter(TClass *cl, const char *membername, char *endch)
Produce code to set value to given data member.
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 * XmlGetElementName(const TStreamerElement *el)
return converted name for TStreamerElement
ROOT::ESTLType IsSTLCont(std::string_view type)
type : type name: vector<list<classA,allocator>,allocator> result: 0 : not stl container code of cont...
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.