Logo ROOT  
Reference Guide
TXMLPlayer.cxx
Go to the documentation of this file.
1 // @(#)root/xml:$Id$
2 // Author: Sergey Linev, Rene Brun 10.05.2004
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 //________________________________________________________________________
13 //
14 // Class for xml code generation
15 // It should be used for generation of xml streamers, which could be used outside root
16 // environment. This means, that with help of such streamers user can read and write
17 // objects from/to xml file, which later can be accepted by ROOT.
18 //
19 // At the moment supported only classes, which are not inherited from TObject
20 // and which not contains any TObject members.
21 //
22 // To generate xml code:
23 //
24 // 1. ROOT library with required classes should be created.
25 // In general, without such library non of user objects can be stored and
26 // retrieved from any ROOT file
27 //
28 // 2. Generate xml streamers by root script like:
29 //
30 // void generate() {
31 // gSystem->Load("libRXML.so"); // load ROOT xml library
32 // gSystem->Load("libuser.so"); // load user ROOT library
33 //
34 // TList lst;
35 // lst.Add(TClass::GetClass("TUserClass1"));
36 // lst.Add(TClass::GetClass("TUserClass2"));
37 // ...
38 // TXMLPlayer player;
39 // player.ProduceCode(&lst, "streamers"); // create xml streamers
40 // }
41 //
42 // 3. Copy "streamers.h", "streamers.cxx", "TXmlFile.h", "TXmlFile.cxx" files
43 // to user project and compile them. TXmlFile class implementation can be taken
44 // from http://web-docs.gsi.de/~linev/xmlfile.tar.gz
45 //
46 // TXMLPlayer class generates one function per class, which called class streamer.
47 // Name of such function for class TExample will be TExample_streamer.
48 //
49 // Following data members for streamed classes are supported:
50 // - simple data types (int, double, float)
51 // - array of simple types (int[5], double[5][6])
52 // - dynamic array of simple types (int* with comment field // [fSize])
53 // - const char*
54 // - object of any nonROOT class
55 // - pointer on object
56 // - array of objects
57 // - array of pointers on objects
58 // - stl string
59 // - stl vector, list, deque, set, multiset, map, multimap
60 // - allowed arguments for stl containers are: simple data types, string, object, pointer on object
61 // Any other data member can not be (yet) read from xml file and write to xml file.
62 //
63 // If data member of class is private or protected, it can not be accessed via
64 // member name. Two alternative way is supported. First, if for class member fValue
65 // exists function GetValue(), it will be used to get value from the class, and if
66 // exists SetValue(), it will be used to set appropriate data member. Names of setter
67 // and getter methods can be specified in comments filed like:
68 //
69 // int fValue; // *OPTION={GetMethod="GetV";SetMethod="SetV"}
70 //
71 // If getter or setter methods does not available, address to data member will be
72 // calculated as predefined offset to object start address. In that case generated code
73 // should be used only on the same platform (OS + compiler), where it was generated.
74 //
75 // Generated streamers resolve inheritance tree for given class. This allows to have
76 // array (or vector) of object pointers on some basic class, while objects of derived
77 // class(es) are used.
78 //
79 // To access data from xml files, user should use TXmlFile class, which is different from
80 // ROOT TXMLFile, but provides very similar functionality. For example, to read
81 // object from xml file:
82 //
83 // TXmlFile file("test.xml"); // open xml file
84 // file.ls(); // show list of keys in file
85 // TExample* ex1 = (TExample*) file.Get("ex1", TExample_streamer); // get object
86 // file.Close();
87 //
88 // To write object to file:
89 //
90 // TXmlFile outfile("test2.xml", "recreate"); // create xml file
91 // TExample* ex1 = new TExample;
92 // outfile.Write(ex1, "ex1", TExample_streamer); // write object to file
93 // outfile.Close();
94 //
95 // Complete example for generating and using of external xml streamers can be taken from
96 // http://www-docs.gsi.de/~linev/xmlreader.tar.gz
97 //
98 // Any bug reports and requests for additional functionality are welcome.
99 //
100 // Sergey Linev, S.Linev@gsi.de
101 //
102 //________________________________________________________________________
103 
104 #include "TXMLPlayer.h"
105 
106 #include "TROOT.h"
107 #include "TList.h"
108 #include "TClass.h"
109 #include "TVirtualStreamerInfo.h"
110 #include "TStreamerElement.h"
111 #include "TObjArray.h"
112 #include "TDataMember.h"
113 #include "TMethod.h"
114 #include "TDataType.h"
115 #include "TMethodCall.h"
116 #include "TVirtualCollectionProxy.h"
117 #include "TClassEdit.h"
118 #include "strlcpy.h"
119 #include <iostream>
120 #include <fstream>
121 #include <string>
122 #include <vector>
123 
124 const char *tab1 = " ";
125 const char *tab2 = " ";
126 const char *tab3 = " ";
127 const char *tab4 = " ";
128 
129 const char *names_xmlfileclass = "TXmlFile";
130 
132 
133 ////////////////////////////////////////////////////////////////////////////////
134 /// default constructor
135 
137 {
138 }
139 
140 ////////////////////////////////////////////////////////////////////////////////
141 /// destructor of TXMLPlayer object
142 
144 {
145 }
146 
147 ////////////////////////////////////////////////////////////////////////////////
148 /// returns streamer function name for given class
149 
151 {
152  if (cl == 0)
153  return "";
154  TString res = cl->GetName();
155  res += "_streamer";
156  return res;
157 }
158 
159 ////////////////////////////////////////////////////////////////////////////////
160 /// Produce streamers for provide class list
161 /// TList should include list of classes, for which code should be generated.
162 /// filename specify name of file (without extension), where streamers should be
163 /// created. Function produces two files: header file and source file.
164 /// For instance, if filename is "streamers", files "streamers.h" and "streamers.cxx"
165 /// will be created.
166 
167 Bool_t TXMLPlayer::ProduceCode(TList *cllist, const char *filename)
168 {
169  if ((cllist == 0) || (filename == 0))
170  return kFALSE;
171 
172  std::ofstream fh(TString(filename) + ".h");
173  std::ofstream fs(TString(filename) + ".cxx");
174 
175  fh << "// generated header file" << std::endl << std::endl;
176  fh << "#ifndef " << filename << "_h" << std::endl;
177  fh << "#define " << filename << "_h" << std::endl << std::endl;
178 
179  fh << "#include \"" << names_xmlfileclass << ".h\"" << std::endl << std::endl;
180 
181  fs << "// generated source file" << std::endl << std::endl;
182  fs << "#include \"" << filename << ".h\"" << std::endl << std::endl;
183 
184  // produce appropriate include for all classes
185 
186  TObjArray inclfiles;
187  TIter iter(cllist);
188  TClass *cl = 0;
189  while ((cl = (TClass *)iter()) != 0) {
190  if (inclfiles.FindObject(cl->GetDeclFileName()) == 0) {
191  fs << "#include \"" << cl->GetDeclFileName() << "\"" << std::endl;
192  inclfiles.Add(new TNamed(cl->GetDeclFileName(), ""));
193  }
194  }
195  inclfiles.Delete();
196 
197  fh << std::endl;
198  fs << std::endl;
199 
200  // produce streamers declarations and implementations
201 
202  iter.Reset();
203 
204  while ((cl = (TClass *)iter()) != 0) {
205 
206  fh << "extern void* " << GetStreamerName(cl) << "(" << names_xmlfileclass
207  << " &buf, void* ptr = 0, bool checktypes = true);" << std::endl
208  << std::endl;
209 
210  ProduceStreamerSource(fs, cl, cllist);
211  }
212 
213  fh << "#endif" << std::endl << std::endl;
214  fs << std::endl << std::endl;
215 
216  return kTRUE;
217 }
218 
219 ////////////////////////////////////////////////////////////////////////////////
220 /// returns name of simple data type for given data member
221 
223 {
224  if (member == 0)
225  return "int";
226 
227  if (member->IsBasic())
228  switch (member->GetDataType()->GetType()) {
229  case kChar_t: return "char";
230  case kShort_t: return "short";
231  case kInt_t: return "int";
232  case kLong_t: return "long";
233  case kLong64_t: return "long long";
234  case kFloat16_t:
235  case kFloat_t: return "float";
236  case kDouble32_t:
237  case kDouble_t: return "double";
238  case kUChar_t: {
239  char first = member->GetDataType()->GetTypeName()[0];
240  if ((first == 'B') || (first == 'b'))
241  return "bool";
242  return "unsigned char";
243  }
244  case kBool_t: return "bool";
245  case kUShort_t: return "unsigned short";
246  case kUInt_t: return "unsigned int";
247  case kULong_t: return "unsigned long";
248  case kULong64_t: return "unsigned long long";
249  }
250 
251  if (member->IsEnum())
252  return "int";
253 
254  return member->GetTypeName();
255 }
256 
257 ////////////////////////////////////////////////////////////////////////////////
258 /// return simple data types for given TStreamerElement object
259 
261 {
263  return "int";
264 
265  switch (el->GetType() % 20) {
266  case TVirtualStreamerInfo::kChar: return "char";
267  case TVirtualStreamerInfo::kShort: return "short";
268  case TVirtualStreamerInfo::kInt: return "int";
269  case TVirtualStreamerInfo::kLong: return "long";
270  case TVirtualStreamerInfo::kLong64: return "long long";
272  case TVirtualStreamerInfo::kFloat: return "float";
274  case TVirtualStreamerInfo::kDouble: return "double";
276  char first = el->GetTypeNameBasic()[0];
277  if ((first == 'B') || (first == 'b'))
278  return "bool";
279  return "unsigned char";
280  }
281  case TVirtualStreamerInfo::kBool: return "bool";
282  case TVirtualStreamerInfo::kUShort: return "unsigned short";
283  case TVirtualStreamerInfo::kUInt: return "unsigned int";
284  case TVirtualStreamerInfo::kULong: return "unsigned long";
285  case TVirtualStreamerInfo::kULong64: return "unsigned long long";
286  }
287  return "int";
288 }
289 
290 ////////////////////////////////////////////////////////////////////////////////
291 /// return functions name to read simple data type from xml file
292 
294 {
296  return "ReadInt";
297 
298  switch (type % 20) {
299  case TVirtualStreamerInfo::kChar: return "ReadChar";
300  case TVirtualStreamerInfo::kShort: return "ReadShort";
301  case TVirtualStreamerInfo::kInt: return "ReadInt";
302  case TVirtualStreamerInfo::kLong: return "ReadLong";
303  case TVirtualStreamerInfo::kLong64: return "ReadLong64";
305  case TVirtualStreamerInfo::kFloat: return "ReadFloat";
307  case TVirtualStreamerInfo::kDouble: return "ReadDouble";
309  Bool_t isbool = false;
310  if (realname != 0)
311  isbool = (TString(realname).Index("bool", 0, TString::kIgnoreCase) >= 0);
312  if (isbool)
313  return "ReadBool";
314  return "ReadUChar";
315  }
316  case TVirtualStreamerInfo::kBool: return "ReadBool";
317  case TVirtualStreamerInfo::kUShort: return "ReadUShort";
318  case TVirtualStreamerInfo::kUInt: return "ReadUInt";
319  case TVirtualStreamerInfo::kULong: return "ReadULong";
320  case TVirtualStreamerInfo::kULong64: return "ReadULong64";
321  }
322  return "ReadValue";
323 }
324 
325 ////////////////////////////////////////////////////////////////////////////////
326 /// produce code to access member of given class.
327 /// Parameter specials has following meaning:
328 /// 0 - nothing special
329 /// 1 - cast to data type
330 /// 2 - produce pointer on given member
331 /// 3 - skip casting when produce pointer by buf.P() function
332 
333 const char *TXMLPlayer::ElementGetter(TClass *cl, const char *membername, int specials)
334 {
335  TClass *membercl = cl ? cl->GetBaseDataMember(membername) : 0;
336  TDataMember *member = membercl ? membercl->GetDataMember(membername) : 0;
337  TMethodCall *mgetter = member ? member->GetterMethod(0) : 0;
338 
339  if ((mgetter != 0) && (mgetter->GetMethod()->Property() & kIsPublic)) {
340  fGetterName = "obj->";
341  fGetterName += mgetter->GetMethodName();
342  fGetterName += "()";
343  } else if ((member == 0) || ((member->Property() & kIsPublic) != 0)) {
344  fGetterName = "obj->";
345  fGetterName += membername;
346  } else {
347  fGetterName = "";
348  Bool_t deref = (member->GetArrayDim() == 0) && (specials != 2);
349  if (deref)
350  fGetterName += "*(";
351  if (specials != 3) {
352  fGetterName += "(";
353  if (member->Property() & kIsConstant)
354  fGetterName += "const ";
355  fGetterName += GetMemberTypeName(member);
356  if (member->IsaPointer())
357  fGetterName += "*";
358  fGetterName += "*) ";
359  }
360  fGetterName += "buf.P(obj,";
361  fGetterName += member->GetOffset();
362  fGetterName += ")";
363  if (deref)
364  fGetterName += ")";
365  specials = 0;
366  }
367 
368  if ((specials == 1) && (member != 0)) {
369  TString cast = "(";
370  cast += GetMemberTypeName(member);
371  if (member->IsaPointer() || (member->GetArrayDim() > 0))
372  cast += "*";
373  cast += ") ";
374  cast += fGetterName;
375  fGetterName = cast;
376  }
377 
378  if ((specials == 2) && (member != 0)) {
379  TString buf = "&(";
380  buf += fGetterName;
381  buf += ")";
382  fGetterName = buf;
383  }
384 
385  return fGetterName.Data();
386 }
387 
388 ////////////////////////////////////////////////////////////////////////////////
389 /// Produce code to set value to given data member.
390 /// endch should be output after value is specified.
391 
392 const char *TXMLPlayer::ElementSetter(TClass *cl, const char *membername, char *endch)
393 {
394  strcpy(endch, "");
395 
396  TClass *membercl = cl ? cl->GetBaseDataMember(membername) : 0;
397  TDataMember *member = membercl ? membercl->GetDataMember(membername) : 0;
398  TMethodCall *msetter = member ? member->SetterMethod(cl) : 0;
399 
400  if ((msetter != 0) && (msetter->GetMethod()->Property() & kIsPublic)) {
401  fSetterName = "obj->";
402  fSetterName += msetter->GetMethodName();
403  fSetterName += "(";
404  strcpy(endch, ")");
405  } else if ((member == 0) || (member->Property() & kIsPublic) != 0) {
406  fSetterName = "obj->";
407  fSetterName += membername;
408  fSetterName += " = ";
409  } else {
410  fSetterName = "";
411  if (member->GetArrayDim() == 0)
412  fSetterName += "*";
413  fSetterName += "((";
414  if (member->Property() & kIsConstant)
415  fSetterName += "const ";
416  fSetterName += GetMemberTypeName(member);
417  if (member->IsaPointer())
418  fSetterName += "*";
419  fSetterName += "*) buf.P(obj,";
420  fSetterName += member->GetOffset();
421  fSetterName += ")) = ";
422  }
423  return fSetterName.Data();
424 }
425 
426 ////////////////////////////////////////////////////////////////////////////////
427 /// Produce source code of streamer function for specified class
428 
429 void TXMLPlayer::ProduceStreamerSource(std::ostream &fs, TClass *cl, TList *cllist)
430 {
431  if (cl == 0)
432  return;
434  TObjArray *elements = info->GetElements();
435  if (elements == 0)
436  return;
437 
438  fs << "//__________________________________________________________________________" << std::endl;
439  fs << "void* " << GetStreamerName(cl) << "(" << names_xmlfileclass << " &buf, void* ptr, bool checktypes)"
440  << std::endl;
441  fs << "{" << std::endl;
442  fs << tab1 << cl->GetName() << " *obj = (" << cl->GetName() << "*) ptr;" << std::endl;
443 
444  fs << tab1 << "if (buf.IsReading()) { " << std::endl;
445 
446  TIter iter(cllist);
447  TClass *c1 = 0;
448  Bool_t firstchild = true;
449 
450  while ((c1 = (TClass *)iter()) != 0) {
451  if (c1 == cl)
452  continue;
453  if (c1->GetListOfBases()->FindObject(cl->GetName()) == 0)
454  continue;
455  if (firstchild) {
456  fs << tab2 << "if (checktypes) {" << std::endl;
457  fs << tab3 << "void* ";
458  firstchild = false;
459  } else
460  fs << tab3;
461  fs << "res = " << GetStreamerName(c1) << "(buf, dynamic_cast<" << c1->GetName() << "*>(obj));" << std::endl;
462  fs << tab3 << "if (res) return dynamic_cast<" << cl->GetName() << "*>((" << c1->GetName() << " *) res);"
463  << std::endl;
464  }
465  if (!firstchild)
466  fs << tab2 << "}" << std::endl;
467 
468  fs << tab2 << "if (!buf.CheckClassNode(\"" << cl->GetName() << "\", " << info->GetClassVersion() << ")) return 0;"
469  << std::endl;
470 
471  fs << tab2 << "if (obj==0) obj = new " << cl->GetName() << ";" << std::endl;
472 
473  int n;
474  for (n = 0; n <= elements->GetLast(); n++) {
475 
476  TStreamerElement *el = dynamic_cast<TStreamerElement *>(elements->At(n));
477  if (el == 0)
478  continue;
479 
480  Int_t typ = el->GetType();
481 
482  switch (typ) {
483  // basic types
500  char endch[5];
501  fs << tab2 << ElementSetter(cl, el->GetName(), endch);
502  fs << "buf." << GetBasicTypeReaderMethodName(el->GetType(), 0) << "(\"" << el->GetName() << "\")" << endch
503  << ";" << std::endl;
504  continue;
505  }
506 
507  // array of basic types like bool[10]
523  fs << tab2 << "buf.ReadArray(" << ElementGetter(cl, el->GetName(), (el->GetArrayDim() > 1) ? 1 : 0);
524  fs << ", " << el->GetArrayLength() << ", \"" << el->GetName() << "\");" << std::endl;
525  continue;
526  }
527 
528  // array of basic types like bool[n]
544  TStreamerBasicPointer *elp = dynamic_cast<TStreamerBasicPointer *>(el);
545  if (elp == 0) {
546  std::cout << "fatal error with TStreamerBasicPointer" << std::endl;
547  continue;
548  }
549  char endch[5];
550 
551  fs << tab2 << ElementSetter(cl, el->GetName(), endch);
552  fs << "buf.ReadArray(" << ElementGetter(cl, el->GetName());
553  fs << ", " << ElementGetter(cl, elp->GetCountName());
554  fs << ", \"" << el->GetName() << "\", true)" << endch << ";" << std::endl;
555  continue;
556  }
557 
559  char endch[5];
560  fs << tab2 << ElementSetter(cl, el->GetName(), endch);
561  fs << "buf.ReadCharStar(" << ElementGetter(cl, el->GetName());
562  fs << ", \"" << el->GetName() << "\")" << endch << ";" << std::endl;
563  continue;
564  }
565 
567  fs << tab2 << GetStreamerName(el->GetClassPointer()) << "(buf, dynamic_cast<"
568  << el->GetClassPointer()->GetName() << "*>(obj), false);" << std::endl;
569  continue;
570  }
571 
572  // Class* Class not derived from TObject and with comment field //->
575  if (el->GetArrayLength() > 0) {
576  fs << tab2 << "buf.ReadObjectArr(" << ElementGetter(cl, el->GetName());
577  fs << ", " << el->GetArrayLength() << ", -1"
578  << ", \"" << el->GetName() << "\", " << GetStreamerName(el->GetClassPointer()) << ");" << std::endl;
579  } else {
580  fs << tab2 << "buf.ReadObject(" << ElementGetter(cl, el->GetName());
581  fs << ", \"" << el->GetName() << "\", " << GetStreamerName(el->GetClassPointer()) << ");" << std::endl;
582  }
583  continue;
584  }
585 
586  // Class* Class not derived from TObject and no comment
589  if (el->GetArrayLength() > 0) {
590  fs << tab2 << "for (int n=0;n<" << el->GetArrayLength() << ";n++) "
591  << "delete (" << ElementGetter(cl, el->GetName()) << ")[n];" << std::endl;
592  fs << tab2 << "buf.ReadObjectPtrArr((void**) " << ElementGetter(cl, el->GetName(), 3);
593  fs << ", " << el->GetArrayLength() << ", \"" << el->GetName() << "\", "
594  << GetStreamerName(el->GetClassPointer()) << ");" << std::endl;
595  } else {
596  char endch[5];
597 
598  fs << tab2 << "delete " << ElementGetter(cl, el->GetName()) << ";" << std::endl;
599  fs << tab2 << ElementSetter(cl, el->GetName(), endch);
600  fs << "(" << el->GetClassPointer()->GetName() << "*) buf.ReadObjectPtr(\"" << el->GetName() << "\", "
601  << GetStreamerName(el->GetClassPointer()) << ")" << endch << ";" << std::endl;
602  }
603  continue;
604  }
605 
606  // Class NOT derived from TObject
608  fs << tab2 << "buf.ReadObject(" << ElementGetter(cl, el->GetName(), 2);
609  fs << ", \"" << el->GetName() << "\", " << GetStreamerName(el->GetClassPointer()) << ");" << std::endl;
610  continue;
611  }
612 
613  // Class NOT derived from TObject, array
615  fs << tab2 << "buf.ReadObjectArr(" << ElementGetter(cl, el->GetName());
616  fs << ", " << el->GetArrayLength() << ", sizeof(" << el->GetClassPointer()->GetName() << "), \""
617  << el->GetName() << "\", " << GetStreamerName(el->GetClassPointer()) << ");" << std::endl;
618  continue;
619  }
620 
621  // container with no virtual table (stl) and no comment
626  TStreamerSTL *elstl = dynamic_cast<TStreamerSTL *>(el);
627  if (elstl == 0)
628  break; // to make skip
629 
630  if (ProduceSTLstreamer(fs, cl, elstl, false))
631  continue;
632 
633  fs << tab2 << "// STL type = " << elstl->GetSTLtype() << std::endl;
634  break;
635  }
636  }
637  fs << tab2 << "buf.SkipMember(\"" << el->GetName() << "\"); // sinfo type " << el->GetType() << " of class "
638  << el->GetClassPointer()->GetName() << " not supported" << std::endl;
639  }
640 
641  fs << tab2 << "buf.EndClassNode();" << std::endl;
642 
643  fs << tab1 << "} else {" << std::endl;
644 
645  // generation of writing part of class streamer
646 
647  fs << tab2 << "if (obj==0) return 0;" << std::endl;
648 
649  firstchild = true;
650  iter.Reset();
651  while ((c1 = (TClass *)iter()) != 0) {
652  if (c1 == cl)
653  continue;
654  if (c1->GetListOfBases()->FindObject(cl->GetName()) == 0)
655  continue;
656  if (firstchild) {
657  firstchild = false;
658  fs << tab2 << "if (checktypes) {" << std::endl;
659  }
660  fs << tab3 << "if (dynamic_cast<" << c1->GetName() << "*>(obj))" << std::endl;
661  fs << tab4 << "return " << GetStreamerName(c1) << "(buf, dynamic_cast<" << c1->GetName() << "*>(obj));"
662  << std::endl;
663  }
664  if (!firstchild)
665  fs << tab2 << "}" << std::endl;
666 
667  fs << tab2 << "buf.StartClassNode(\"" << cl->GetName() << "\", " << info->GetClassVersion() << ");" << std::endl;
668 
669  for (n = 0; n <= elements->GetLast(); n++) {
670 
671  TStreamerElement *el = dynamic_cast<TStreamerElement *>(elements->At(n));
672  if (el == 0)
673  continue;
674 
675  Int_t typ = el->GetType();
676 
677  switch (typ) {
678  // write basic types
695  fs << tab2 << "buf.WriteValue(";
696  if (typ == TVirtualStreamerInfo::kUChar)
697  fs << "(unsigned char) " << ElementGetter(cl, el->GetName());
698  else
699  fs << ElementGetter(cl, el->GetName());
700  fs << ", \"" << el->GetName() << "\");" << std::endl;
701  continue;
702  }
703 
704  // array of basic types
720  fs << tab2 << "buf.WriteArray(" << ElementGetter(cl, el->GetName(), (el->GetArrayDim() > 1) ? 1 : 0);
721  fs << ", " << el->GetArrayLength() << ", \"" << el->GetName() << "\");" << std::endl;
722  continue;
723  }
724 
740  TStreamerBasicPointer *elp = dynamic_cast<TStreamerBasicPointer *>(el);
741  if (elp == 0) {
742  std::cout << "fatal error with TStreamerBasicPointer" << std::endl;
743  continue;
744  }
745  fs << tab2 << "buf.WriteArray(" << ElementGetter(cl, el->GetName());
746  fs << ", " << ElementGetter(cl, elp->GetCountName()) << ", \"" << el->GetName() << "\", true);" << std::endl;
747  continue;
748  }
749 
751  fs << tab2 << "buf.WriteCharStar(" << ElementGetter(cl, el->GetName()) << ", \"" << el->GetName() << "\");"
752  << std::endl;
753  continue;
754  }
755 
757  fs << tab2 << GetStreamerName(el->GetClassPointer()) << "(buf, dynamic_cast<"
758  << el->GetClassPointer()->GetName() << "*>(obj), false);" << std::endl;
759  continue;
760  }
761 
762  // Class* Class not derived from TObject and with comment field //->
765  if (el->GetArrayLength() > 0) {
766  fs << tab2 << "buf.WriteObjectArr(" << ElementGetter(cl, el->GetName());
767  fs << ", " << el->GetArrayLength() << ", -1"
768  << ", \"" << el->GetName() << "\", " << GetStreamerName(el->GetClassPointer()) << ");" << std::endl;
769  } else {
770  fs << tab2 << "buf.WriteObject(" << ElementGetter(cl, el->GetName());
771  fs << ", \"" << el->GetName() << "\", " << GetStreamerName(el->GetClassPointer()) << ");" << std::endl;
772  }
773  continue;
774  }
775 
776  // Class* Class not derived from TObject and no comment
779  if (el->GetArrayLength() > 0) {
780  fs << tab2 << "buf.WriteObjectPtrArr((void**) " << ElementGetter(cl, el->GetName(), 3);
781  fs << ", " << el->GetArrayLength() << ", \"" << el->GetName() << "\", "
782  << GetStreamerName(el->GetClassPointer()) << ");" << std::endl;
783  } else {
784  fs << tab2 << "buf.WriteObjectPtr(" << ElementGetter(cl, el->GetName());
785  fs << ", \"" << el->GetName() << "\", " << GetStreamerName(el->GetClassPointer()) << ");" << std::endl;
786  }
787  continue;
788  }
789 
790  case TVirtualStreamerInfo::kAny: { // Class NOT derived from TObject
791  fs << tab2 << "buf.WriteObject(" << ElementGetter(cl, el->GetName(), 2);
792  fs << ", \"" << el->GetName() << "\", " << GetStreamerName(el->GetClassPointer()) << ");" << std::endl;
793  continue;
794  }
795 
797  fs << tab2 << "buf.WriteObjectArr(" << ElementGetter(cl, el->GetName());
798  fs << ", " << el->GetArrayLength() << ", sizeof(" << el->GetClassPointer()->GetName() << "), \""
799  << el->GetName() << "\", " << GetStreamerName(el->GetClassPointer()) << ");" << std::endl;
800  continue;
801  }
802 
803  // container with no virtual table (stl) and no comment
808  TStreamerSTL *elstl = dynamic_cast<TStreamerSTL *>(el);
809  if (elstl == 0)
810  break; // to make skip
811 
812  if (ProduceSTLstreamer(fs, cl, elstl, true))
813  continue;
814  fs << tab2 << "// STL type = " << elstl->GetSTLtype() << std::endl;
815  break;
816  }
817  }
818  fs << tab2 << "buf.MakeEmptyMember(\"" << el->GetName() << "\"); // sinfo type " << el->GetType()
819  << " of class " << el->GetClassPointer()->GetName() << " not supported" << std::endl;
820  }
821 
822  fs << tab2 << "buf.EndClassNode();" << std::endl;
823 
824  fs << tab1 << "}" << std::endl;
825  fs << tab1 << "return obj;" << std::endl;
826  fs << "}" << std::endl << std::endl;
827 }
828 
829 ////////////////////////////////////////////////////////////////////////////////
830 /// Produce code to read argument of stl container from xml file
831 
832 void TXMLPlayer::ReadSTLarg(std::ostream &fs, TString &argname, int argtyp, Bool_t isargptr, TClass *argcl,
833  TString &tname, TString &ifcond)
834 {
835  switch (argtyp) {
852  fs << tname << " " << argname << " = buf." << GetBasicTypeReaderMethodName(argtyp, tname.Data()) << "(0);"
853  << std::endl;
854  break;
855  }
856 
858  fs << tname << (isargptr ? " " : " *") << argname << " = "
859  << "(" << argcl->GetName() << "*)"
860  << "buf.ReadObjectPtr(0, " << GetStreamerName(argcl) << ");" << std::endl;
861  if (!isargptr) {
862  if (ifcond.Length() > 0)
863  ifcond += " && ";
864  ifcond += argname;
865  TString buf = "*";
866  buf += argname;
867  argname = buf;
868  }
869  break;
870  }
871 
873  fs << "string *" << argname << " = "
874  << "buf.ReadSTLstring();" << std::endl;
875  if (!isargptr) {
876  if (ifcond.Length() > 0)
877  ifcond += " && ";
878  ifcond += argname;
879  TString buf = "*";
880  buf += argname;
881  argname = buf;
882  }
883  break;
884  }
885 
886  default: fs << "/* argument " << argname << " not supported */";
887  }
888 }
889 
890 ////////////////////////////////////////////////////////////////////////////////
891 /// Produce code to write argument of stl container to xml file
892 
893 void TXMLPlayer::WriteSTLarg(std::ostream &fs, const char *accname, int argtyp, Bool_t isargptr, TClass *argcl)
894 {
895  switch (argtyp) {
912  fs << "buf.WriteValue(" << accname << ", 0);" << std::endl;
913  break;
914  }
915 
917  fs << "buf.WriteObjectPtr(";
918  if (isargptr)
919  fs << accname;
920  else
921  fs << "&(" << accname << ")";
922  fs << ", 0, " << GetStreamerName(argcl) << ");" << std::endl;
923  break;
924  }
925 
927  fs << "buf.WriteSTLstring(";
928  if (isargptr)
929  fs << accname;
930  else
931  fs << "&(" << accname << ")";
932  fs << ");" << std::endl;
933  break;
934  }
935 
936  default: fs << "/* argument not supported */" << std::endl;
937  }
938 }
939 
940 ////////////////////////////////////////////////////////////////////////////////
941 /// Produce code of xml streamer for data member of stl type
942 
943 Bool_t TXMLPlayer::ProduceSTLstreamer(std::ostream &fs, TClass *cl, TStreamerSTL *el, Bool_t isWriting)
944 {
945  if ((cl == 0) || (el == 0))
946  return false;
947 
948  TClass *contcl = el->GetClassPointer();
949 
950  Bool_t isstr = (el->GetSTLtype() == ROOT::kSTLstring);
951  Bool_t isptr = el->IsaPointer();
952  Bool_t isarr = (el->GetArrayLength() > 0);
953  Bool_t isparent = (strcmp(el->GetName(), contcl->GetName()) == 0);
954 
955  int stltyp = -1;
956  int narg = 0;
957  int argtype[2];
958  Bool_t isargptr[2];
959  TClass *argcl[2];
960  TString argtname[2];
961 
962  if (!isstr && contcl->GetCollectionType() != ROOT::kNotSTL) {
963  int nestedLoc = 0;
964  std::vector<std::string> splitName;
965  TClassEdit::GetSplit(contcl->GetName(), splitName, nestedLoc);
966 
967  stltyp = contcl->GetCollectionType();
968  switch (stltyp) {
969  case ROOT::kSTLvector: narg = 1; break;
970  case ROOT::kSTLlist: narg = 1; break;
971  case ROOT::kSTLforwardlist: narg = 1; break;
972  case ROOT::kSTLdeque: narg = 1; break;
973  case ROOT::kSTLmap: narg = 2; break;
974  case ROOT::kSTLmultimap: narg = 2; break;
975  case ROOT::kSTLset: narg = 1; break;
976  case ROOT::kSTLmultiset: narg = 1; break;
977  case ROOT::kSTLunorderedset: narg = 1; break;
978  case ROOT::kSTLunorderedmultiset: narg = 1; break;
979  case ROOT::kSTLunorderedmap: narg = 2; break;
980  case ROOT::kSTLunorderedmultimap: narg = 2; break;
981 
982  default: return false;
983  }
984 
985  for (int n = 0; n < narg; n++) {
986  argtype[n] = -1;
987  isargptr[n] = false;
988  argcl[n] = 0;
989  argtname[n] = "";
990 
991  TString buf = splitName[n + 1];
992 
993  argtname[n] = buf;
994 
995  // nested STL containers not yet supported
996  if (TClassEdit::IsSTLCont(buf.Data()))
997  return false;
998 
999  int pstar = buf.Index("*");
1000 
1001  if (pstar > 0) {
1002  isargptr[n] = true;
1003  pstar--;
1004  while ((pstar > 0) && (buf[pstar] == ' '))
1005  pstar--;
1006  buf.Remove(pstar + 1);
1007  } else
1008  isargptr[n] = false;
1009 
1010  if (buf.Index("const ") == 0) {
1011  buf.Remove(0, 6);
1012  while ((buf.Length() > 0) && (buf[0] == ' '))
1013  buf.Remove(0, 1);
1014  }
1015 
1016  TDataType *dt = (TDataType *)gROOT->GetListOfTypes()->FindObject(buf);
1017  if (dt)
1018  argtype[n] = dt->GetType();
1019  else if (buf == "string")
1021  else {
1022  argcl[n] = TClass::GetClass(buf);
1023  if (argcl[n] != 0)
1024  argtype[n] = TVirtualStreamerInfo::kObject;
1025  }
1026  if (argtype[n] < 0)
1027  stltyp = -1;
1028  } // for narg
1029 
1030  if (stltyp < 0)
1031  return false;
1032  }
1033 
1034  Bool_t akaarrayaccess = (narg == 1) && (argtype[0] < 20);
1035 
1036  char tabs[30], tabs2[30];
1037 
1038  if (isWriting) {
1039 
1040  fs << tab2 << "if (buf.StartSTLnode(\"" << fXmlSetup.XmlGetElementName(el) << "\")) {" << std::endl;
1041 
1042  fs << tab3 << contcl->GetName() << " ";
1043 
1044  TString accname;
1045  if (isptr) {
1046  if (isarr) {
1047  fs << "**cont";
1048  accname = "(*cont)->";
1049  } else {
1050  fs << "*cont";
1051  accname = "cont->";
1052  }
1053  } else if (isarr) {
1054  fs << "*cont";
1055  accname = "cont->";
1056  } else {
1057  fs << "&cont";
1058  accname = "cont.";
1059  }
1060 
1061  fs << " = ";
1062 
1063  if (isparent)
1064  fs << "*dynamic_cast<" << contcl->GetName() << "*>(obj);" << std::endl;
1065  else
1066  fs << ElementGetter(cl, el->GetName()) << ";" << std::endl;
1067 
1068  if (isarr && el->GetArrayLength()) {
1069  strlcpy(tabs, tab4, sizeof(tabs));
1070  fs << tab3 << "for(int n=0;n<" << el->GetArrayLength() << ";n++) {" << std::endl;
1071  } else
1072  strlcpy(tabs, tab3, sizeof(tabs));
1073 
1074  strlcpy(tabs2, tabs, sizeof(tabs2));
1075 
1076  if (isptr) {
1077  strlcat(tabs2, tab1, sizeof(tabs2));
1078  fs << tabs << "if (" << (isarr ? "*cont" : "cont") << "==0) {" << std::endl;
1079  fs << tabs2 << "buf.WriteSTLsize(0" << (isstr ? ",true);" : ");") << std::endl;
1080  fs << tabs << "} else {" << std::endl;
1081  }
1082 
1083  fs << tabs2 << "buf.WriteSTLsize(" << accname << (isstr ? "length(), true);" : "size());") << std::endl;
1084 
1085  if (isstr) {
1086  fs << tabs2 << "buf.WriteSTLstringData(" << accname << "c_str());" << std::endl;
1087  } else {
1088  if (akaarrayaccess) {
1089  fs << tabs2 << argtname[0] << "* arr = new " << argtname[0] << "[" << accname << "size()];" << std::endl;
1090  fs << tabs2 << "int k = 0;" << std::endl;
1091  }
1092 
1093  fs << tabs2 << contcl->GetName() << "::const_iterator iter;" << std::endl;
1094  fs << tabs2 << "for (iter = " << accname << "begin(); iter != " << accname << "end(); iter++)";
1095  if (akaarrayaccess) {
1096  fs << std::endl << tabs2 << tab1 << "arr[k++] = *iter;" << std::endl;
1097  fs << tabs2 << "buf.WriteArray(arr, " << accname << "size(), 0, false);" << std::endl;
1098  fs << tabs2 << "delete[] arr;" << std::endl;
1099  } else if (narg == 1) {
1100  fs << std::endl << tabs2 << tab1;
1101  WriteSTLarg(fs, "*iter", argtype[0], isargptr[0], argcl[0]);
1102  } else if (narg == 2) {
1103  fs << " {" << std::endl;
1104  fs << tabs2 << tab1;
1105  WriteSTLarg(fs, "iter->first", argtype[0], isargptr[0], argcl[0]);
1106  fs << tabs2 << tab1;
1107  WriteSTLarg(fs, "iter->second", argtype[1], isargptr[1], argcl[1]);
1108  fs << tabs2 << "}" << std::endl;
1109  }
1110  } // if (isstr)
1111 
1112  if (isptr)
1113  fs << tabs << "}" << std::endl;
1114 
1115  if (isarr && el->GetArrayLength()) {
1116  if (isptr)
1117  fs << tabs << "cont++;" << std::endl;
1118  else
1119  fs << tabs << "(void*) cont = (char*) cont + sizeof(" << contcl->GetName() << ");" << std::endl;
1120  fs << tab3 << "}" << std::endl;
1121  }
1122 
1123  fs << tab3 << "buf.EndSTLnode();" << std::endl;
1124  fs << tab2 << "}" << std::endl;
1125 
1126  } else {
1127 
1128  fs << tab2 << "if (buf.VerifySTLnode(\"" << fXmlSetup.XmlGetElementName(el) << "\")) {" << std::endl;
1129 
1130  fs << tab3 << contcl->GetName() << " ";
1131  TString accname, accptr;
1132  if (isptr) {
1133  if (isarr) {
1134  fs << "**cont";
1135  accname = "(*cont)->";
1136  accptr = "*cont";
1137  } else {
1138  fs << "*cont";
1139  accname = "cont->";
1140  accptr = "cont";
1141  }
1142  } else if (isarr) {
1143  fs << "*cont";
1144  accname = "cont->";
1145  } else {
1146  fs << "&cont";
1147  accname = "cont.";
1148  }
1149 
1150  fs << " = ";
1151 
1152  if (isparent)
1153  fs << "*dynamic_cast<" << contcl->GetName() << "*>(obj);" << std::endl;
1154  else
1155  fs << ElementGetter(cl, el->GetName()) << ";" << std::endl;
1156 
1157  if (isarr && el->GetArrayLength()) {
1158  strlcpy(tabs, tab4, sizeof(tabs));
1159  fs << tab3 << "for(int n=0;n<" << el->GetArrayLength() << ";n++) {" << std::endl;
1160  } else
1161  strlcpy(tabs, tab3, sizeof(tabs));
1162 
1163  fs << tabs << "int size = buf.ReadSTLsize(" << (isstr ? "true);" : ");") << std::endl;
1164 
1165  if (isptr) {
1166  fs << tabs << "delete " << accptr << ";" << std::endl;
1167  fs << tabs << "if (size==0) " << accptr << " = 0;" << std::endl;
1168  fs << tabs << " else " << accptr << " = new " << contcl->GetName() << ";" << std::endl;
1169  if (!isarr) {
1170  char endch[5];
1171  fs << tabs << ElementSetter(cl, el->GetName(), endch);
1172  fs << "cont" << endch << ";" << std::endl;
1173  }
1174  } else {
1175  fs << tabs << accname << (isstr ? "erase();" : "clear();") << std::endl;
1176  }
1177 
1178  if (isstr) {
1179  fs << tabs << "if (size>0) " << accname << "assign(buf.ReadSTLstringData(size));" << std::endl;
1180  } else {
1181  if (akaarrayaccess) {
1182  fs << tabs << argtname[0] << "* arr = new " << argtname[0] << "[size];" << std::endl;
1183  fs << tabs << "buf.ReadArray(arr, size, 0, false);" << std::endl;
1184  }
1185 
1186  fs << tabs << "for(int k=0;k<size;k++)";
1187 
1188  if (akaarrayaccess) {
1189  fs << std::endl << tabs << tab1 << accname;
1190  if ((stltyp == ROOT::kSTLset) || (stltyp == ROOT::kSTLmultiset))
1191  fs << "insert";
1192  else
1193  fs << "push_back";
1194  fs << "(arr[k]);" << std::endl;
1195  fs << tabs << "delete[] arr;" << std::endl;
1196  } else if (narg == 1) {
1197  TString arg1("arg"), ifcond;
1198  fs << " {" << std::endl << tabs << tab1;
1199  ReadSTLarg(fs, arg1, argtype[0], isargptr[0], argcl[0], argtname[0], ifcond);
1200  fs << tabs << tab1;
1201  if (ifcond.Length() > 0)
1202  fs << "if (" << ifcond << ") ";
1203  fs << accname;
1204  if ((stltyp == ROOT::kSTLset) || (stltyp == ROOT::kSTLmultiset))
1205  fs << "insert";
1206  else
1207  fs << "push_back";
1208  fs << "(" << arg1 << ");" << std::endl;
1209  fs << tabs << "}" << std::endl;
1210  } else if (narg == 2) {
1211  TString arg1("arg1"), arg2("arg2"), ifcond;
1212  fs << " {" << std::endl << tabs << tab1;
1213  ReadSTLarg(fs, arg1, argtype[0], isargptr[0], argcl[0], argtname[0], ifcond);
1214  fs << tabs << tab1;
1215  ReadSTLarg(fs, arg2, argtype[1], isargptr[1], argcl[1], argtname[1], ifcond);
1216  fs << tabs << tab1;
1217  if (ifcond.Length() > 0)
1218  fs << "if (" << ifcond << ") ";
1219  fs << accname << "insert(make_pair(" << arg1 << ", " << arg2 << "));" << std::endl;
1220  fs << tabs << "}" << std::endl;
1221  }
1222  }
1223 
1224  if (isarr && el->GetArrayLength()) {
1225  if (isptr)
1226  fs << tabs << "cont++;" << std::endl;
1227  else
1228  fs << tabs << "(void*) cont = (char*) cont + sizeof(" << contcl->GetName() << ");" << std::endl;
1229  fs << tab3 << "}" << std::endl;
1230  }
1231 
1232  fs << tab3 << "buf.EndSTLnode();" << std::endl;
1233  fs << tab2 << "}" << std::endl;
1234  }
1235  return true;
1236 }
kULong64_t
@ kULong64_t
Definition: TDataType.h:38
TXMLPlayer::fGetterName
TString fGetterName
Definition: TXMLPlayer.h:48
TClass::GetStreamerInfo
TVirtualStreamerInfo * GetStreamerInfo(Int_t version=0) const
returns a pointer to the TVirtualStreamerInfo object for version If the object does not exist,...
Definition: TClass.cxx:4509
TXMLPlayer::ReadSTLarg
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.
Definition: TXMLPlayer.cxx:832
tab3
const char * tab3
Definition: TXMLPlayer.cxx:126
TDataMember::GetTypeName
const char * GetTypeName() const
Get type of data member, e,g.: "class TDirectory*" -> "TDirectory".
Definition: TDataMember.cxx:604
TVirtualStreamerInfo::kLong64
@ kLong64
Definition: TVirtualStreamerInfo.h:88
kDouble_t
@ kDouble_t
Definition: TDataType.h:37
n
const Int_t n
Definition: legend1.C:16
ROOT::kSTLdeque
@ kSTLdeque
Definition: ESTLType.h:44
kUChar_t
@ kUChar_t
Definition: TDataType.h:35
kInt_t
@ kInt_t
Definition: TDataType.h:36
TVirtualStreamerInfo::kUInt
@ kUInt
Definition: TVirtualStreamerInfo.h:87
first
Definition: first.py:1
TClass::GetBaseDataMember
TClass * GetBaseDataMember(const char *datamember)
Return pointer to (base) class that contains datamember.
Definition: TClass.cxx:2784
TVirtualCollectionProxy.h
ROOT::kSTLvector
@ kSTLvector
Definition: ESTLType.h:42
ROOT::kSTLset
@ kSTLset
Definition: ESTLType.h:47
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TObjArray::Delete
virtual void Delete(Option_t *option="")
Remove all objects from the array AND delete all heap based objects.
Definition: TObjArray.cxx:356
ROOT::kSTLunorderedmultimap
@ kSTLunorderedmultimap
Definition: ESTLType.h:57
TStreamerSTL::IsaPointer
Bool_t IsaPointer() const
Return true if the data member is a pointer.
Definition: TStreamerElement.cxx:1853
TObjArray
Definition: TObjArray.h:37
TVirtualStreamerInfo::kUChar
@ kUChar
Definition: TVirtualStreamerInfo.h:87
kLong_t
@ kLong_t
Definition: TDataType.h:36
kChar_t
@ kChar_t
Definition: TDataType.h:35
TXMLPlayer
Definition: TXMLPlayer.h:25
kULong_t
@ kULong_t
Definition: TDataType.h:36
TVirtualStreamerInfo::kULong64
@ kULong64
Definition: TVirtualStreamerInfo.h:88
TString::Data
const char * Data() const
Definition: TString.h:369
TXMLPlayer::fSetterName
TString fSetterName
buffer for name of getter method
Definition: TXMLPlayer.h:49
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
ROOT::kSTLunorderedmultiset
@ kSTLunorderedmultiset
Definition: ESTLType.h:55
ROOT::kNotSTL
@ kNotSTL
Definition: ESTLType.h:41
TStreamerElement.h
TDataType::GetType
Int_t GetType() const
Definition: TDataType.h:68
TXMLPlayer::~TXMLPlayer
virtual ~TXMLPlayer()
destructor of TXMLPlayer object
Definition: TXMLPlayer.cxx:143
TMethod.h
TVirtualStreamerInfo::kDouble32
@ kDouble32
Definition: TVirtualStreamerInfo.h:86
TVirtualStreamerInfo::kFloat
@ kFloat
Definition: TVirtualStreamerInfo.h:85
TVirtualStreamerInfo::kFloat16
@ kFloat16
Definition: TVirtualStreamerInfo.h:88
TString::kIgnoreCase
@ kIgnoreCase
Definition: TString.h:268
TVirtualStreamerInfo::kSTL
@ kSTL
Definition: TVirtualStreamerInfo.h:94
TVirtualStreamerInfo::kOffsetL
@ kOffsetL
Definition: TVirtualStreamerInfo.h:84
TDataMember::GetterMethod
TMethodCall * GetterMethod(TClass *cl=0)
Return a TMethodCall method responsible for getting the value of data member.
Definition: TDataMember.cxx:813
TDataMember.h
TVirtualStreamerInfo::kCounter
@ kCounter
Definition: TVirtualStreamerInfo.h:84
TVirtualStreamerInfo::kAnyp
@ kAnyp
Definition: TVirtualStreamerInfo.h:90
TDataMember
Definition: TDataMember.h:31
TVirtualStreamerInfo::kBase
@ kBase
Definition: TVirtualStreamerInfo.h:84
kUInt_t
@ kUInt_t
Definition: TDataType.h:36
TVirtualStreamerInfo::kShort
@ kShort
Definition: TVirtualStreamerInfo.h:85
TString::Length
Ssiz_t Length() const
Definition: TString.h:410
TClass.h
TList.h
TStreamerBasicPointer::GetCountName
const char * GetCountName() const
Definition: TStreamerElement.h:218
TXMLPlayer::WriteSTLarg
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.
Definition: TXMLPlayer.cxx:893
TIter::Reset
void Reset()
Definition: TCollection.h:252
TXMLPlayer.h
TDataMember::IsEnum
Bool_t IsEnum() const
Return true if data member is an enum.
Definition: TDataMember.cxx:721
TVirtualStreamerInfo::kObject
@ kObject
Definition: TVirtualStreamerInfo.h:89
TVirtualStreamerInfo::kCharStar
@ kCharStar
Definition: TVirtualStreamerInfo.h:84
TObjArray::At
TObject * At(Int_t idx) const
Definition: TObjArray.h:166
TString
Definition: TString.h:136
ROOT::kSTLlist
@ kSTLlist
Definition: ESTLType.h:43
tab1
const char * tab1
Definition: TXMLPlayer.cxx:124
TVirtualStreamerInfo::kAnyP
@ kAnyP
Definition: TVirtualStreamerInfo.h:90
TVirtualStreamerInfo
Definition: TVirtualStreamerInfo.h:37
bool
TXMLPlayer::GetMemberTypeName
TString GetMemberTypeName(TDataMember *member)
returns name of simple data type for given data member
Definition: TXMLPlayer.cxx:222
kFloat16_t
@ kFloat16_t
Definition: TDataType.h:39
TObjArray::Add
void Add(TObject *obj)
Definition: TObjArray.h:74
ROOT::kSTLmap
@ kSTLmap
Definition: ESTLType.h:45
TClass::GetDataMember
TDataMember * GetDataMember(const char *datamember) const
Return pointer to datamember object with name "datamember".
Definition: TClass.cxx:3318
TStreamerBasicPointer
Definition: TStreamerElement.h:198
TDataMember::IsBasic
Bool_t IsBasic() const
Return true if data member is a basic type, e.g. char, int, long...
Definition: TDataMember.cxx:712
TXMLPlayer::ElementGetter
const char * ElementGetter(TClass *cl, const char *membername, int specials=0)
produce code to access member of given class.
Definition: TXMLPlayer.cxx:333
TROOT.h
TXMLSetup::XmlGetElementName
const char * XmlGetElementName(const TStreamerElement *el)
return converted name for TStreamerElement
Definition: TXMLSetup.cxx:238
kIsConstant
@ kIsConstant
Definition: TDictionary.h:86
ROOT::kSTLstring
@ kSTLstring
Definition: ESTLType.h:60
TDataMember::Property
Long_t Property() const
Get property description word. For meaning of bits see EProperty.
Definition: TDataMember.cxx:776
TMethodCall::GetMethodName
const char * GetMethodName() const
Definition: TMethodCall.h:90
TObjArray::GetLast
Int_t GetLast() const
Return index of last object in array.
Definition: TObjArray.cxx:577
TDataType.h
kDouble32_t
@ kDouble32_t
Definition: TDataType.h:37
TClassEdit::IsSTLCont
ROOT::ESTLType IsSTLCont(std::string_view type)
type : type name: vector<list<classA,allocator>,allocator> result: 0 : not stl container code of cont...
Definition: TClassEdit.cxx:1320
TStreamerElement::GetTypeNameBasic
const char * GetTypeNameBasic() const
Return type name of this element in case the type name is not a standard basic type,...
Definition: TStreamerElement.cxx:405
TDataMember::GetArrayDim
Int_t GetArrayDim() const
Return number of array dimensions.
Definition: TDataMember.cxx:545
ROOT::kSTLmultiset
@ kSTLmultiset
Definition: ESTLType.h:48
TClass::GetCollectionType
ROOT::ESTLType GetCollectionType() const
Return the 'type' of the STL the TClass is representing.
Definition: TClass.cxx:2843
TVirtualStreamerInfo::kChar
@ kChar
Definition: TVirtualStreamerInfo.h:85
TFunction::Property
Long_t Property() const
Get property description word. For meaning of bits see EProperty.
Definition: TFunction.cxx:184
TXMLPlayer::ProduceStreamerSource
void ProduceStreamerSource(std::ostream &fs, TClass *cl, TList *cllist)
Produce source code of streamer function for specified class.
Definition: TXMLPlayer.cxx:429
ROOT::kSTLforwardlist
@ kSTLforwardlist
Definition: ESTLType.h:53
TVirtualStreamerInfo::kULong
@ kULong
Definition: TVirtualStreamerInfo.h:87
TDataType
Definition: TDataType.h:44
TString::Remove
TString & Remove(Ssiz_t pos)
Definition: TString.h:673
TNamed
Definition: TNamed.h:29
TVirtualStreamerInfo::kInt
@ kInt
Definition: TVirtualStreamerInfo.h:85
TStreamerElement::GetClassPointer
virtual TClass * GetClassPointer() const
Returns a pointer to the TClass of this element.
Definition: TStreamerElement.cxx:292
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
kUShort_t
@ kUShort_t
Definition: TDataType.h:35
TVirtualStreamerInfo::kSTLstring
@ kSTLstring
Definition: TVirtualStreamerInfo.h:95
TDataMember::GetDataType
TDataType * GetDataType() const
Definition: TDataMember.h:74
TClass::GetDeclFileName
const char * GetDeclFileName() const
Return name of the file containing the declaration of this class.
Definition: TClass.cxx:3342
TStreamerElement::GetType
Int_t GetType() const
Definition: TStreamerElement.h:119
ROOT::kSTLunorderedset
@ kSTLunorderedset
Definition: ESTLType.h:54
ROOT::kSTLmultimap
@ kSTLmultimap
Definition: ESTLType.h:46
TClass::GetClass
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.
Definition: TClass.cxx:2925
TVirtualStreamerInfo::kLong
@ kLong
Definition: TVirtualStreamerInfo.h:85
TStreamerElement::GetArrayLength
Int_t GetArrayLength() const
Definition: TStreamerElement.h:107
kLong64_t
@ kLong64_t
Definition: TDataType.h:38
TXMLPlayer::GetStreamerName
TString GetStreamerName(TClass *cl)
returns streamer function name for given class
Definition: TXMLPlayer.cxx:150
kFloat_t
@ kFloat_t
Definition: TDataType.h:37
TStreamerSTL
Definition: TStreamerElement.h:391
TXMLPlayer::TXMLPlayer
TXMLPlayer()
default constructor
Definition: TXMLPlayer.cxx:136
tab4
const char * tab4
Definition: TXMLPlayer.cxx:127
TMethodCall::GetMethod
TFunction * GetMethod()
Returns the TMethod describing the method to be executed.
Definition: TMethodCall.cxx:383
TVirtualStreamerInfo::kSTLp
@ kSTLp
Definition: TVirtualStreamerInfo.h:91
TString::Index
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:639
TVirtualStreamerInfo::GetClassVersion
virtual Int_t GetClassVersion() const =0
TVirtualStreamerInfo.h
TDataMember::GetOffset
Long_t GetOffset() const
Get offset from "this".
Definition: TDataMember.cxx:631
TClassEdit::GetSplit
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.
Definition: TClassEdit.cxx:981
TXMLPlayer::GetBasicTypeReaderMethodName
TString GetBasicTypeReaderMethodName(Int_t type, const char *realname)
return functions name to read simple data type from xml file
Definition: TXMLPlayer.cxx:293
TXMLPlayer::fXmlSetup
TXMLSetup fXmlSetup
buffer for name of setter method
Definition: TXMLPlayer.h:50
TVirtualStreamerInfo::kBool
@ kBool
Definition: TVirtualStreamerInfo.h:88
tab2
const char * tab2
Definition: TXMLPlayer.cxx:125
names_xmlfileclass
const char * names_xmlfileclass
Definition: TXMLPlayer.cxx:129
TObjArray.h
TClassEdit.h
TObjArray::FindObject
virtual TObject * FindObject(const char *name) const
Find an object in this collection using its name.
Definition: TObjArray.cxx:415
TClass
Definition: TClass.h:80
TDataMember::IsaPointer
Bool_t IsaPointer() const
Return true if data member is a pointer.
Definition: TDataMember.cxx:730
TStreamerSTL::GetSTLtype
Int_t GetSTLtype() const
Definition: TStreamerElement.h:412
TObject
Definition: TObject.h:37
TXMLPlayer::ElementSetter
const char * ElementSetter(TClass *cl, const char *membername, char *endch)
Produce code to set value to given data member.
Definition: TXMLPlayer.cxx:392
TDataType::GetTypeName
TString GetTypeName()
Get basic type of typedef, e,g.
Definition: TDataType.cxx:149
TXMLPlayer::GetBasicTypeName
TString GetBasicTypeName(TStreamerElement *el)
return simple data types for given TStreamerElement object
Definition: TXMLPlayer.cxx:260
kIsPublic
@ kIsPublic
Definition: TDictionary.h:74
ROOT::kSTLunorderedmap
@ kSTLunorderedmap
Definition: ESTLType.h:56
TXMLPlayer::ProduceCode
Bool_t ProduceCode(TList *cllist, const char *filename)
Produce streamers for provide class list TList should include list of classes, for which code should ...
Definition: TXMLPlayer.cxx:167
TVirtualStreamerInfo::kDouble
@ kDouble
Definition: TVirtualStreamerInfo.h:86
TIter
Definition: TCollection.h:233
TVirtualStreamerInfo::kAny
@ kAny
Definition: TVirtualStreamerInfo.h:89
TMethodCall
Definition: TMethodCall.h:37
TXMLPlayer::ProduceSTLstreamer
Bool_t ProduceSTLstreamer(std::ostream &fs, TClass *cl, TStreamerSTL *el, Bool_t isWriting)
Produce code of xml streamer for data member of stl type.
Definition: TXMLPlayer.cxx:943
TNamed::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:53
type
int type
Definition: TGX11.cxx:121
TVirtualStreamerInfo::kUShort
@ kUShort
Definition: TVirtualStreamerInfo.h:87
TVirtualStreamerInfo::kOffsetP
@ kOffsetP
Definition: TVirtualStreamerInfo.h:84
kShort_t
@ kShort_t
Definition: TDataType.h:35
kBool_t
@ kBool_t
Definition: TDataType.h:38
TStreamerElement::GetArrayDim
Int_t GetArrayDim() const
Definition: TStreamerElement.h:106
TStreamerElement
Definition: TStreamerElement.h:33
TDataMember::SetterMethod
TMethodCall * SetterMethod(TClass *cl)
Return a TMethodCall method responsible for setting the value of data member.
Definition: TDataMember.cxx:857
TList
Definition: TList.h:44
TVirtualStreamerInfo::GetElements
virtual TObjArray * GetElements() const =0
gROOT
#define gROOT
Definition: TROOT.h:406
int
c1
return c1
Definition: legend1.C:41
TMethodCall.h