Logo ROOT   6.14/05
Reference Guide
TBufferXML.cxx
Go to the documentation of this file.
1 // @(#)root/:$Id: 5400e36954e1dc109fcfc306242c30234beb7312 $
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 \class TBufferXML
14 \ingroup IO
15 
16 Class for serializing/deserializing object to/from xml.
17 
18 The simple way to create XML representation is:
19 ~~~{.cpp}
20  TNamed *obj = new TNamed("name", "title");
21  TString xml = TBufferXML::ToXML(obj);
22 ~~~
23 Produced xml can be decoded into new object:
24 ~~~{.cpp}
25  TNamed *obj2 = nullptr;
26  TBufferXML::FromXML(obj2, xml);
27 ~~~
28 
29 TBufferXML class uses streaming mechanism, provided by ROOT system,
30 therefore most of ROOT and user classes can be stored to xml.
31 There are limitations for complex objects like TTree, which can not be converted to xml.
32 */
33 
34 #include "TBufferXML.h"
35 
36 #include "Compression.h"
37 #include "TXMLFile.h"
38 #include "TObjArray.h"
39 #include "TROOT.h"
40 #include "TError.h"
41 #include "TClass.h"
42 #include "TClassTable.h"
43 #include "TDataType.h"
44 #include "TExMap.h"
45 #include "TMethodCall.h"
46 #include "TStreamerInfo.h"
47 #include "TStreamerElement.h"
48 #include "TFile.h"
49 #include "TMemberStreamer.h"
50 #include "TStreamer.h"
51 #include "RZip.h"
52 
54 
55 ////////////////////////////////////////////////////////////////////////////////
56 /// Default constructor
57 
59  : TBufferText(), TXMLSetup(), fXML(nullptr), fStack(), fVersionBuf(-111), fErrorFlag(0), fCanUseCompact(kFALSE),
60  fExpectedBaseClass(nullptr), fCompressLevel(0), fIOVersion(3)
61 {
62 }
63 
64 ////////////////////////////////////////////////////////////////////////////////
65 /// Creates buffer object to serialize/deserialize data to/from xml.
66 /// Mode should be either TBuffer::kRead or TBuffer::kWrite.
67 
69  : TBufferText(mode), TXMLSetup(), fXML(nullptr), fStack(), fVersionBuf(-111), fErrorFlag(0), fCanUseCompact(kFALSE),
71 {
72 }
73 
74 ////////////////////////////////////////////////////////////////////////////////
75 /// Creates buffer object to serialize/deserialize data to/from xml.
76 /// This constructor should be used, if data from buffer supposed to be stored in file.
77 /// Mode should be either TBuffer::kRead or TBuffer::kWrite.
78 
80  : TBufferText(mode, file), TXMLSetup(*file), fXML(nullptr), fStack(), fVersionBuf(-111), fErrorFlag(0),
82 {
83  // this is for the case when StreamerInfo reads elements from
84  // buffer as ReadFastArray. When it checks if size of buffer is
85  // too small and skip reading. Actually, more improved method should
86  // be used here.
87 
88  if (XmlFile()) {
89  SetXML(XmlFile()->XML());
92  }
93 }
94 
95 ////////////////////////////////////////////////////////////////////////////////
96 /// Destroy xml buffer.
97 
99 {
100  while (fStack.size() > 0)
101  PopStack();
102 }
103 
104 ////////////////////////////////////////////////////////////////////////////////
105 /// Returns pointer to TXMLFile object.
106 /// Access to file is necessary to produce unique identifier for object references.
107 
109 {
110  return dynamic_cast<TXMLFile *>(GetParent());
111 }
112 
113 ////////////////////////////////////////////////////////////////////////////////
114 /// Converts object, inherited from TObject class, to XML string
115 /// GenericLayout defines layout choice for XML file
116 /// UseNamespaces allow XML namespaces.
117 /// See TXMLSetup class for details
118 
119 TString TBufferXML::ConvertToXML(const TObject *obj, Bool_t GenericLayout, Bool_t UseNamespaces)
120 {
121  TClass *clActual = nullptr;
122  void *ptr = (void *)obj;
123 
124  if (obj) {
125  clActual = TObject::Class()->GetActualClass(obj);
126  if (!clActual)
127  clActual = TObject::Class();
128  else if (clActual != TObject::Class())
129  ptr = (void *)((Long_t)obj - clActual->GetBaseClassOffset(TObject::Class()));
130  }
131 
132  return ConvertToXML(ptr, clActual, GenericLayout, UseNamespaces);
133 }
134 
135 ////////////////////////////////////////////////////////////////////////////////
136 /// Converts any type of object to XML string.
137 /// GenericLayout defines layout choice for XML file
138 /// UseNamespaces allow XML namespaces.
139 /// See TXMLSetup class for details
140 
141 TString TBufferXML::ConvertToXML(const void *obj, const TClass *cl, Bool_t GenericLayout, Bool_t UseNamespaces)
142 {
143  TXMLEngine xml;
144 
146  buf.SetXML(&xml);
147  buf.InitMap();
148 
150  buf.SetUseNamespaces(UseNamespaces);
151 
152  XMLNodePointer_t xmlnode = buf.XmlWriteAny(obj, cl);
153 
154  TString res;
155 
156  xml.SaveSingleNode(xmlnode, &res);
157 
158  xml.FreeNode(xmlnode);
159 
160  return res;
161 }
162 
163 ////////////////////////////////////////////////////////////////////////////////
164 /// Read object from XML, produced by ConvertToXML() method.
165 /// If object does not inherit from TObject class, return 0.
166 /// GenericLayout and UseNamespaces should be the same as in ConvertToXML()
167 
168 TObject *TBufferXML::ConvertFromXML(const char *str, Bool_t GenericLayout, Bool_t UseNamespaces)
169 {
170  TClass *cl = nullptr;
171  void *obj = ConvertFromXMLAny(str, &cl, GenericLayout, UseNamespaces);
172 
173  if (!cl || !obj)
174  return nullptr;
175 
176  Int_t delta = cl->GetBaseClassOffset(TObject::Class());
177 
178  if (delta < 0) {
179  cl->Destructor(obj);
180  return nullptr;
181  }
182 
183  return (TObject *)(((char *)obj) + delta);
184 }
185 
186 ////////////////////////////////////////////////////////////////////////////////
187 /// Read object of any class from XML, produced by ConvertToXML() method.
188 /// If cl!=0, return actual class of object.
189 /// GenericLayout and UseNamespaces should be the same as in ConvertToXML()
190 
191 void *TBufferXML::ConvertFromXMLAny(const char *str, TClass **cl, Bool_t GenericLayout, Bool_t UseNamespaces)
192 {
193  TXMLEngine xml;
195 
196  buf.SetXML(&xml);
197  buf.InitMap();
198 
200  buf.SetUseNamespaces(UseNamespaces);
201 
202  XMLNodePointer_t xmlnode = xml.ReadSingleNode(str);
203 
204  void *obj = buf.XmlReadAny(xmlnode, nullptr, cl);
205 
206  xml.FreeNode(xmlnode);
207 
208  return obj;
209 }
210 
211 ////////////////////////////////////////////////////////////////////////////////
212 /// Convert from XML and check if object derived from specified class
213 /// When possible, cast to given class
214 
215 void *TBufferXML::ConvertFromXMLChecked(const char *xml, const TClass *expectedClass, Bool_t GenericLayout,
216  Bool_t UseNamespaces)
217 {
218  TClass *objClass = nullptr;
219  void *res = ConvertFromXMLAny(xml, &objClass, GenericLayout, UseNamespaces);
220 
221  if (!res || !objClass)
222  return nullptr;
223 
224  if (objClass == expectedClass)
225  return res;
226 
227  Int_t offset = objClass->GetBaseClassOffset(expectedClass);
228  if (offset < 0) {
229  ::Error("TBufferXML::ConvertFromXMLChecked", "expected class %s is not base for read class %s",
230  expectedClass->GetName(), objClass->GetName());
231  objClass->Destructor(res);
232  return nullptr;
233  }
234 
235  return (char *)res - offset;
236 }
237 
238 ////////////////////////////////////////////////////////////////////////////////
239 /// Convert object of any class to xml structures
240 /// Return pointer on top xml element
241 
243 {
244  fErrorFlag = 0;
245 
246  if (!fXML)
247  return nullptr;
248 
249  XMLNodePointer_t res = XmlWriteObject(obj, cl, kTRUE);
250 
251  return res;
252 }
253 
254 ////////////////////////////////////////////////////////////////////////////////
255 /// Recreate object from xml structure.
256 /// Return pointer to read object.
257 /// if (cl!=0) returns pointer to class of object
258 
259 void *TBufferXML::XmlReadAny(XMLNodePointer_t node, void *obj, TClass **cl)
260 {
261  if (!node)
262  return nullptr;
263 
264  if (cl)
265  *cl = nullptr;
266 
267  fErrorFlag = 0;
268 
269  if (!fXML)
270  return nullptr;
271 
272  PushStack(node, kTRUE);
273 
274  void *res = XmlReadObject(obj, cl);
275 
276  PopStack();
277 
278  return res;
279 }
280 
281 // TXMLStackObj is used to keep stack of object hierarchy,
282 // stored in TBuffer. For example, data for parent class(es)
283 // stored in subnodes, but initial object node will be kept.
284 
285 class TXMLStackObj : public TObject {
286 public:
287  TXMLStackObj(XMLNodePointer_t node)
288  : TObject(), fNode(node), fInfo(nullptr), fElem(nullptr), fElemNumber(0), fCompressedClassNode(kFALSE),
289  fClassNs(nullptr), fIsStreamerInfo(kFALSE), fIsElemOwner(kFALSE)
290  {
291  }
292 
293  virtual ~TXMLStackObj()
294  {
295  if (fIsElemOwner)
296  delete fElem;
297  }
298 
299  Bool_t IsStreamerInfo() const { return fIsStreamerInfo; }
300 
301  XMLNodePointer_t fNode;
302  TStreamerInfo *fInfo;
303  TStreamerElement *fElem;
304  Int_t fElemNumber;
305  Bool_t fCompressedClassNode;
306  XMLNsPointer_t fClassNs;
307  Bool_t fIsStreamerInfo;
308  Bool_t fIsElemOwner;
309 };
310 
311 ////////////////////////////////////////////////////////////////////////////////
312 /// Add new level to xml stack.
313 
314 TXMLStackObj *TBufferXML::PushStack(XMLNodePointer_t current, Bool_t simple)
315 {
316  if (IsReading() && !simple) {
317  current = fXML->GetChild(current);
318  fXML->SkipEmpty(current);
319  }
320 
321  TXMLStackObj *stack = new TXMLStackObj(current);
322  fStack.push_back(stack);
323  return stack;
324 }
325 
326 ////////////////////////////////////////////////////////////////////////////////
327 /// Remove one level from xml stack.
328 
329 TXMLStackObj *TBufferXML::PopStack()
330 {
331  if (fStack.size() > 0) {
332  delete fStack.back();
333  fStack.pop_back();
334  }
335  return fStack.size() > 0 ? Stack() : nullptr;
336 }
337 
338 ////////////////////////////////////////////////////////////////////////////////
339 /// Return pointer on current xml node.
340 
342 {
343  TXMLStackObj *stack = Stack();
344  return stack ? stack->fNode : nullptr;
345 }
346 
347 ////////////////////////////////////////////////////////////////////////////////
348 /// Shift stack node to next.
349 
350 void TBufferXML::ShiftStack(const char *errinfo)
351 {
352  TXMLStackObj *stack = Stack();
353  if (stack) {
354  fXML->ShiftToNext(stack->fNode);
355  if (gDebug > 4)
356  Info("ShiftStack", "%s to node %s", errinfo, fXML->GetNodeName(stack->fNode));
357  }
358 }
359 
360 ////////////////////////////////////////////////////////////////////////////////
361 /// See comments for function SetCompressionSettings.
362 
364 {
365  if (algorithm < 0 || algorithm >= ROOT::kUndefinedCompressionAlgorithm)
366  algorithm = 0;
367  if (fCompressLevel < 0) {
368  // if the level is not defined yet use 1 as a default
369  fCompressLevel = 100 * algorithm + 1;
370  } else {
371  int level = fCompressLevel % 100;
372  fCompressLevel = 100 * algorithm + level;
373  }
374 }
375 
376 ////////////////////////////////////////////////////////////////////////////////
377 /// See comments for function SetCompressionSettings.
378 
380 {
381  if (level < 0)
382  level = 0;
383  if (level > 99)
384  level = 99;
385  if (fCompressLevel < 0) {
386  // if the algorithm is not defined yet use 0 as a default
387  fCompressLevel = level;
388  } else {
389  int algorithm = fCompressLevel / 100;
390  if (algorithm >= ROOT::kUndefinedCompressionAlgorithm)
391  algorithm = 0;
392  fCompressLevel = 100 * algorithm + level;
393  }
394 }
395 
396 ////////////////////////////////////////////////////////////////////////////////
397 /// Used to specify the compression level and algorithm.
398 ///
399 /// See TFile constructor for the details.
400 
402 {
403  fCompressLevel = settings;
404 }
405 
406 ////////////////////////////////////////////////////////////////////////////////
407 /// Write binary data block from buffer to xml.
408 /// This data can be produced only by direct call of TBuffer::WriteBuf() functions.
409 
411 {
412  if (!node || (Length() == 0))
413  return;
414 
415  const char *src = Buffer();
416  int srcSize = Length();
417 
418  char *fZipBuffer = 0;
419 
420  Int_t compressionLevel = GetCompressionLevel();
421  ROOT::ECompressionAlgorithm compressionAlgorithm =
423 
424  if ((Length() > 512) && (compressionLevel > 0)) {
425  int zipBufferSize = Length();
426  fZipBuffer = new char[zipBufferSize + 9];
427  int dataSize = Length();
428  int compressedSize = 0;
429  R__zipMultipleAlgorithm(compressionLevel, &dataSize, Buffer(), &zipBufferSize, fZipBuffer, &compressedSize,
430  compressionAlgorithm);
431  if (compressedSize > 0) {
432  src = fZipBuffer;
433  srcSize = compressedSize;
434  } else {
435  delete[] fZipBuffer;
436  fZipBuffer = nullptr;
437  }
438  }
439 
440  TString res;
441  char sbuf[500];
442  int block = 0;
443  char *tgt = sbuf;
444  int srcCnt = 0;
445 
446  while (srcCnt++ < srcSize) {
447  tgt += sprintf(tgt, " %02x", (unsigned char)*src);
448  src++;
449  if (block++ == 100) {
450  res += sbuf;
451  block = 0;
452  tgt = sbuf;
453  }
454  }
455 
456  if (block > 0)
457  res += sbuf;
458 
459  XMLNodePointer_t blocknode = fXML->NewChild(node, nullptr, xmlio::XmlBlock, res);
460  fXML->NewIntAttr(blocknode, xmlio::Size, Length());
461 
462  if (fZipBuffer) {
463  fXML->NewIntAttr(blocknode, xmlio::Zip, srcSize);
464  delete[] fZipBuffer;
465  }
466 }
467 
468 ////////////////////////////////////////////////////////////////////////////////
469 /// Read binary block of data from xml.
470 
472 {
473  if (!blocknode)
474  return;
475 
476  Int_t blockSize = fXML->GetIntAttr(blocknode, xmlio::Size);
477  Bool_t blockCompressed = fXML->HasAttr(blocknode, xmlio::Zip);
478  char *fUnzipBuffer = nullptr;
479 
480  if (gDebug > 2)
481  Info("XmlReadBlock", "Block size = %d, Length = %d, Compressed = %d", blockSize, Length(), blockCompressed);
482 
483  if (blockSize > BufferSize())
484  Expand(blockSize);
485 
486  char *tgt = Buffer();
487  Int_t readSize = blockSize;
488 
489  TString content = fXML->GetNodeContent(blocknode);
490 
491  if (blockCompressed) {
492  Int_t zipSize = fXML->GetIntAttr(blocknode, xmlio::Zip);
493  fUnzipBuffer = new char[zipSize];
494 
495  tgt = fUnzipBuffer;
496  readSize = zipSize;
497  }
498 
499  char *ptr = (char *)content.Data();
500 
501  if (gDebug > 3)
502  Info("XmlReadBlock", "Content %s", ptr);
503 
504  for (int i = 0; i < readSize; i++) {
505  while ((*ptr < 48) || ((*ptr > 57) && (*ptr < 97)) || (*ptr > 102))
506  ptr++;
507 
508  int b_hi = (*ptr > 57) ? *ptr - 87 : *ptr - 48;
509  ptr++;
510  int b_lo = (*ptr > 57) ? *ptr - 87 : *ptr - 48;
511  ptr++;
512 
513  *tgt = b_hi * 16 + b_lo;
514  tgt++;
515 
516  if (gDebug > 4)
517  Info("XmlReadBlock", " Buf[%d] = %d", i, b_hi * 16 + b_lo);
518  }
519 
520  if (fUnzipBuffer) {
521 
522  int srcsize(0), tgtsize(0), unzipRes(0);
523  int status = R__unzip_header(&srcsize, (UChar_t *)fUnzipBuffer, &tgtsize);
524 
525  if (status == 0)
526  R__unzip(&readSize, (unsigned char *)fUnzipBuffer, &blockSize, (unsigned char *)Buffer(), &unzipRes);
527 
528  if (status != 0 || unzipRes != blockSize)
529  Error("XmlReadBlock", "Decompression error %d", unzipRes);
530  else if (gDebug > 2)
531  Info("XmlReadBlock", "Unzip ok");
532 
533  delete[] fUnzipBuffer;
534  }
535 }
536 
537 ////////////////////////////////////////////////////////////////////////////////
538 /// Add "ptr" attribute to node, if ptr is null or
539 /// if ptr is pointer on object, which is already saved in buffer
540 /// Automatically add "ref" attribute to node, where referenced object is stored
541 
543 {
544  if (!node)
545  return kFALSE;
546 
547  TString refvalue;
548 
549  if (!ptr) {
550  refvalue = xmlio::Null; // null
551  } else {
553  if (!refnode)
554  return kFALSE;
555 
556  if (fXML->HasAttr(refnode, xmlio::Ref)) {
557  refvalue = fXML->GetAttr(refnode, xmlio::Ref);
558  } else {
559  refvalue = xmlio::IdBase;
560  if (XmlFile())
561  refvalue += XmlFile()->GetNextRefCounter();
562  else
563  refvalue += GetNextRefCounter();
564  fXML->NewAttr(refnode, nullptr, xmlio::Ref, refvalue.Data());
565  }
566  }
567  if (refvalue.Length() > 0) {
568  fXML->NewAttr(node, nullptr, xmlio::Ptr, refvalue.Data());
569  return kTRUE;
570  }
571 
572  return kFALSE;
573 }
574 
575 ////////////////////////////////////////////////////////////////////////////////
576 /// Searches for "ptr" attribute and returns pointer to object and class,
577 /// if "ptr" attribute reference to read object
578 
580 {
581  cl = nullptr;
582 
583  if (!fXML->HasAttr(node, xmlio::Ptr))
584  return kFALSE;
585 
586  const char *ptrid = fXML->GetAttr(node, xmlio::Ptr);
587 
588  if (!ptrid)
589  return kFALSE;
590 
591  // null
592  if (strcmp(ptrid, xmlio::Null) == 0) {
593  ptr = nullptr;
594  return kTRUE;
595  }
596 
597  if (strncmp(ptrid, xmlio::IdBase, strlen(xmlio::IdBase)) != 0) {
598  Error("ExtractPointer", "Pointer tag %s not started from %s", ptrid, xmlio::IdBase);
599  return kFALSE;
600  }
601 
602  Int_t id = TString(ptrid + strlen(xmlio::IdBase)).Atoi();
603 
604  GetMappedObject(id + 1, ptr, cl);
605 
606  if (!ptr || !cl)
607  Error("ExtractPointer", "not found ptr %s result %p %s", ptrid, ptr, (cl ? cl->GetName() : "null"));
608 
609  return ptr && cl;
610 }
611 
612 ////////////////////////////////////////////////////////////////////////////////
613 /// Analyze if node has "ref" attribute and register it to object map
614 
615 void TBufferXML::ExtractReference(XMLNodePointer_t node, const void *ptr, const TClass *cl)
616 {
617  if (!node || !ptr)
618  return;
619 
620  const char *refid = fXML->GetAttr(node, xmlio::Ref);
621 
622  if (!refid)
623  return;
624 
625  if (strncmp(refid, xmlio::IdBase, strlen(xmlio::IdBase)) != 0) {
626  Error("ExtractReference", "Reference tag %s not started from %s", refid, xmlio::IdBase);
627  return;
628  }
629 
630  Int_t id = TString(refid + strlen(xmlio::IdBase)).Atoi();
631 
632  MapObject(ptr, cl, id + 1);
633 
634  if (gDebug > 2)
635  Info("ExtractReference", "Find reference %s for object %p class %s", refid, ptr, (cl ? cl->GetName() : "null"));
636 }
637 
638 ////////////////////////////////////////////////////////////////////////////////
639 /// Check if node has specified name
640 
641 Bool_t TBufferXML::VerifyNode(XMLNodePointer_t node, const char *name, const char *errinfo)
642 {
643  if (!name || !node)
644  return kFALSE;
645 
646  if (strcmp(fXML->GetNodeName(node), name) != 0) {
647  if (errinfo) {
648  Error("VerifyNode", "Reading XML file (%s). Get: %s, expects: %s", errinfo, fXML->GetNodeName(node), name);
649  fErrorFlag = 1;
650  }
651  return kFALSE;
652  }
653  return kTRUE;
654 }
655 
656 ////////////////////////////////////////////////////////////////////////////////
657 /// Check, if stack node has specified name
658 
659 Bool_t TBufferXML::VerifyStackNode(const char *name, const char *errinfo)
660 {
661  return VerifyNode(StackNode(), name, errinfo);
662 }
663 
664 ////////////////////////////////////////////////////////////////////////////////
665 /// Checks, that attribute of specified name exists and has specified value
666 
667 Bool_t TBufferXML::VerifyAttr(XMLNodePointer_t node, const char *name, const char *value, const char *errinfo)
668 {
669  if (!node || !name || !value)
670  return kFALSE;
671 
672  const char *cont = fXML->GetAttr(node, name);
673  if ((!cont || (strcmp(cont, value) != 0))) {
674  if (errinfo) {
675  Error("VerifyAttr", "%s : attr %s = %s, expected: %s", errinfo, name, cont, value);
676  fErrorFlag = 1;
677  }
678  return kFALSE;
679  }
680  return kTRUE;
681 }
682 
683 ////////////////////////////////////////////////////////////////////////////////
684 /// Checks stack attribute
685 
686 Bool_t TBufferXML::VerifyStackAttr(const char *name, const char *value, const char *errinfo)
687 {
688  return VerifyAttr(StackNode(), name, value, errinfo);
689 }
690 
691 ////////////////////////////////////////////////////////////////////////////////
692 /// Create item node of specified name
693 
695 {
696  XMLNodePointer_t node = nullptr;
697  if (GetXmlLayout() == kGeneralized) {
698  node = fXML->NewChild(StackNode(), nullptr, xmlio::Item);
699  fXML->NewAttr(node, nullptr, xmlio::Name, name);
700  } else
701  node = fXML->NewChild(StackNode(), nullptr, name);
702  return node;
703 }
704 
705 ////////////////////////////////////////////////////////////////////////////////
706 /// Checks, if stack node is item and has specified name
707 
708 Bool_t TBufferXML::VerifyItemNode(const char *name, const char *errinfo)
709 {
710  Bool_t res = kTRUE;
711  if (GetXmlLayout() == kGeneralized)
712  res = VerifyStackNode(xmlio::Item, errinfo) && VerifyStackAttr(xmlio::Name, name, errinfo);
713  else
714  res = VerifyStackNode(name, errinfo);
715  return res;
716 }
717 
718 ////////////////////////////////////////////////////////////////////////////////
719 /// Create xml node correspondent to TStreamerElement object
720 
722 {
723  XMLNodePointer_t elemnode = nullptr;
724 
725  const char *elemxmlname = XmlGetElementName(elem);
726 
727  if (GetXmlLayout() == kGeneralized) {
728  elemnode = fXML->NewChild(StackNode(), nullptr, xmlio::Member);
729  fXML->NewAttr(elemnode, nullptr, xmlio::Name, elemxmlname);
730  } else {
731  // take namesapce for element only if it is not a base class or class name
732  XMLNsPointer_t ns = Stack()->fClassNs;
733  if ((elem->GetType() == TStreamerInfo::kBase) ||
734  ((elem->GetType() == TStreamerInfo::kTNamed) && !strcmp(elem->GetName(), TNamed::Class()->GetName())) ||
735  ((elem->GetType() == TStreamerInfo::kTObject) && !strcmp(elem->GetName(), TObject::Class()->GetName())) ||
736  ((elem->GetType() == TStreamerInfo::kTString) && !strcmp(elem->GetName(), TString::Class()->GetName())))
737  ns = nullptr;
738 
739  elemnode = fXML->NewChild(StackNode(), ns, elemxmlname);
740  }
741 
742  TXMLStackObj *curr = PushStack(elemnode);
743  curr->fElem = (TStreamerElement *)elem;
744 }
745 
746 ////////////////////////////////////////////////////////////////////////////////
747 /// Checks if stack node correspond to TStreamerElement object
748 
750 {
751  const char *elemxmlname = XmlGetElementName(elem);
752 
753  if (GetXmlLayout() == kGeneralized) {
755  return kFALSE;
756  if (!VerifyStackAttr(xmlio::Name, elemxmlname))
757  return kFALSE;
758  } else {
759  if (!VerifyStackNode(elemxmlname))
760  return kFALSE;
761  }
762 
764 
765  TXMLStackObj *curr = PushStack(StackNode()); // set pointer to first data inside element
766  curr->fElem = (TStreamerElement *)elem;
767  return kTRUE;
768 }
769 
770 ////////////////////////////////////////////////////////////////////////////////
771 /// Write object to buffer
772 /// If object was written before, only pointer will be stored
773 /// Return pointer to top xml node, representing object
774 
775 XMLNodePointer_t TBufferXML::XmlWriteObject(const void *obj, const TClass *cl, Bool_t cacheReuse)
776 {
777  XMLNodePointer_t objnode = fXML->NewChild(StackNode(), nullptr, xmlio::Object);
778 
779  if (!cl)
780  obj = nullptr;
781 
782  if (ProcessPointer(obj, objnode))
783  return objnode;
784 
785  TString clname = XmlConvertClassName(cl->GetName());
786 
787  fXML->NewAttr(objnode, nullptr, xmlio::ObjClass, clname);
788 
789  if (cacheReuse)
790  fMap->Add(Void_Hash(obj), (Long_t)obj, (Long_t)objnode);
791 
792  PushStack(objnode);
793 
794  ((TClass *)cl)->Streamer((void *)obj, *this);
795 
796  PopStack();
797 
798  if (gDebug > 1)
799  Info("XmlWriteObject", "Done write for class: %s", cl ? cl->GetName() : "null");
800 
801  return objnode;
802 }
803 
804 ////////////////////////////////////////////////////////////////////////////////
805 /// Read object from the buffer
806 
807 void *TBufferXML::XmlReadObject(void *obj, TClass **cl)
808 {
809  if (cl)
810  *cl = nullptr;
811 
812  XMLNodePointer_t objnode = StackNode();
813 
814  if (fErrorFlag > 0)
815  return obj;
816 
817  if (!objnode)
818  return obj;
819 
820  if (!VerifyNode(objnode, xmlio::Object, "XmlReadObjectNew"))
821  return obj;
822 
823  TClass *objClass = nullptr;
824 
825  if (ExtractPointer(objnode, obj, objClass)) {
826  ShiftStack("readobjptr");
827  if (cl)
828  *cl = objClass;
829  return obj;
830  }
831 
832  TString clname = fXML->GetAttr(objnode, xmlio::ObjClass);
833  objClass = XmlDefineClass(clname);
834  if (objClass == TDirectory::Class())
835  objClass = TDirectoryFile::Class();
836 
837  if (!objClass) {
838  Error("XmlReadObject", "Cannot find class %s", clname.Data());
839  ShiftStack("readobjerr");
840  return obj;
841  }
842 
843  if (gDebug > 1)
844  Info("XmlReadObject", "Reading object of class %s", clname.Data());
845 
846  if (!obj)
847  obj = objClass->New();
848 
849  ExtractReference(objnode, obj, objClass);
850 
851  PushStack(objnode);
852 
853  objClass->Streamer((void *)obj, *this);
854 
855  PopStack();
856 
857  ShiftStack("readobj");
858 
859  if (gDebug > 1)
860  Info("XmlReadObject", "Reading object of class %s done", clname.Data());
861 
862  if (cl)
863  *cl = objClass;
864 
865  return obj;
866 }
867 
868 ////////////////////////////////////////////////////////////////////////////////
869 /// Function is called from TStreamerInfo WriteBuffer and ReadBuffer functions
870 /// and indent new level in xml structure.
871 /// This call indicates, that TStreamerInfo functions starts streaming
872 /// object data of correspondent class
873 
875 {
876  WorkWithClass((TStreamerInfo *)info);
877 }
878 
879 ////////////////////////////////////////////////////////////////////////////////
880 /// Prepares buffer to stream data of specified class.
881 
883 {
885 
886  if (sinfo)
887  cl = sinfo->GetClass();
888 
889  if (!cl)
890  return;
891 
892  TString clname = XmlConvertClassName(cl->GetName());
893 
894  if (gDebug > 2)
895  Info("IncrementLevel", "Class: %s", clname.Data());
896 
897  Bool_t compressClassNode = (fExpectedBaseClass == cl);
898  fExpectedBaseClass = nullptr;
899 
900  TXMLStackObj *stack = Stack();
901 
902  if (IsWriting()) {
903 
904  XMLNodePointer_t classnode = nullptr;
905  if (compressClassNode) {
906  classnode = StackNode();
907  } else {
908  if (GetXmlLayout() == kGeneralized) {
909  classnode = fXML->NewChild(StackNode(), nullptr, xmlio::Class);
910  fXML->NewAttr(classnode, nullptr, "name", clname);
911  } else
912  classnode = fXML->NewChild(StackNode(), nullptr, clname);
913  stack = PushStack(classnode);
914  }
915 
916  if (fVersionBuf >= -1) {
917  if (fVersionBuf == -1)
918  fVersionBuf = 1;
920  fVersionBuf = -111;
921  }
922 
923  if (IsUseNamespaces() && (GetXmlLayout() != kGeneralized))
924  stack->fClassNs = fXML->NewNS(classnode, XmlClassNameSpaceRef(cl), clname);
925 
926  } else {
927  if (!compressClassNode) {
928  if (GetXmlLayout() == kGeneralized) {
929  if (!VerifyStackNode(xmlio::Class, "StartInfo"))
930  return;
931  if (!VerifyStackAttr("name", clname, "StartInfo"))
932  return;
933  } else if (!VerifyStackNode(clname, "StartInfo"))
934  return;
935  stack = PushStack(StackNode());
936  }
937  }
938 
939  stack->fCompressedClassNode = compressClassNode;
940  stack->fInfo = sinfo;
941  stack->fIsStreamerInfo = kTRUE;
942 }
943 
944 ////////////////////////////////////////////////////////////////////////////////
945 /// Function is called from TStreamerInfo WriteBuffer and ReadBuffer functions
946 /// and decrease level in xml structure.
947 
949 {
950  CheckVersionBuf();
951 
953 
954  if (gDebug > 2)
955  Info("DecrementLevel", "Class: %s", (info ? info->GetClass()->GetName() : "custom"));
956 
957  TXMLStackObj *stack = Stack();
958 
959  if (!stack->IsStreamerInfo()) {
961  stack = PopStack(); // remove stack of last element
962  }
963 
964  if (stack->fCompressedClassNode) {
965  stack->fInfo = nullptr;
966  stack->fIsStreamerInfo = kFALSE;
967  stack->fCompressedClassNode = kFALSE;
968  } else {
969  PopStack(); // back from data of stack info
970  if (IsReading())
971  ShiftStack("declevel"); // shift to next element after streamer info
972  }
973 }
974 
975 ////////////////////////////////////////////////////////////////////////////////
976 /// Function is called from TStreamerInfo WriteBuffer and ReadBuffer functions
977 /// and add/verify next element of xml structure
978 /// This calls allows separate data, correspondent to one class member, from another
979 
981 {
982  WorkWithElement(elem, comptype);
983 }
984 
985 ////////////////////////////////////////////////////////////////////////////////
986 /// This function is a part of SetStreamerElementNumber method.
987 /// It is introduced for reading of data for specified data member of class.
988 /// Used also in ReadFastArray methods to resolve problem of compressed data,
989 /// when several data members of the same basic type streamed with single ...FastArray call
990 
992 {
993  CheckVersionBuf();
994 
996  fExpectedBaseClass = nullptr;
997 
998  TXMLStackObj *stack = Stack();
999  if (!stack) {
1000  Error("SetStreamerElementNumber", "stack is empty");
1001  return;
1002  }
1003 
1004  if (!stack->IsStreamerInfo()) { // this is not a first element
1006  PopStack(); // go level back
1007  if (IsReading())
1008  ShiftStack("startelem"); // shift to next element, only for reading
1009  stack = Stack();
1010  }
1011 
1012  if (!stack) {
1013  Error("SetStreamerElementNumber", "Lost of stack");
1014  return;
1015  }
1016 
1017  if (!elem) {
1018  Error("SetStreamerElementNumber", "Problem in Inc/Dec level");
1019  return;
1020  }
1021 
1022  TStreamerInfo *info = stack->fInfo;
1023 
1024  if (!stack->IsStreamerInfo()) {
1025  Error("SetStreamerElementNumber", "Problem in Inc/Dec level");
1026  return;
1027  }
1028  Int_t number = info ? info->GetElements()->IndexOf(elem) : -1;
1029 
1030  if (gDebug > 4)
1031  Info("SetStreamerElementNumber", " Next element %s", elem->GetName());
1032 
1033  Bool_t isBasicType = (elem->GetType() > 0) && (elem->GetType() < 20);
1034 
1035  fCanUseCompact =
1036  isBasicType && ((elem->GetType() == comp_type) || (elem->GetType() == comp_type - TStreamerInfo::kConv) ||
1037  (elem->GetType() == comp_type - TStreamerInfo::kSkip));
1038 
1039  if ((elem->GetType() == TStreamerInfo::kBase) ||
1040  ((elem->GetType() == TStreamerInfo::kTNamed) && !strcmp(elem->GetName(), TNamed::Class()->GetName())))
1042 
1043  if (fExpectedBaseClass && (gDebug > 3))
1044  Info("SetStreamerElementNumber", " Expects base class %s with standard streamer",
1046 
1047  if (IsWriting()) {
1048  CreateElemNode(elem);
1049  } else {
1050  if (!VerifyElemNode(elem))
1051  return;
1052  }
1053 
1054  stack = Stack();
1055  stack->fElemNumber = number;
1056  stack->fIsElemOwner = (number < 0);
1057 }
1058 
1059 ////////////////////////////////////////////////////////////////////////////////
1060 /// Should be called at the beginning of custom class streamer.
1061 ///
1062 /// Informs buffer data about class which will be streamed now.
1063 /// ClassBegin(), ClassEnd() and ClassMemeber() should be used in
1064 /// custom class streamers to specify which kind of data are
1065 /// now streamed. Such information is used to correctly
1066 /// convert class data to XML. Without that functions calls
1067 /// classes with custom streamers cannot be used with TBufferXML
1068 
1070 {
1071  WorkWithClass(nullptr, cl);
1072 }
1073 
1074 ////////////////////////////////////////////////////////////////////////////////
1075 /// Should be called at the end of custom streamer
1076 /// See TBufferXML::ClassBegin for more details
1077 
1079 {
1080  DecrementLevel(0);
1081 }
1082 
1083 ////////////////////////////////////////////////////////////////////////////////
1084 /// Method indicates name and typename of class member,
1085 /// which should be now streamed in custom streamer
1086 ///
1087 /// Following combinations are supported:
1088 /// -# name = "ClassName", typeName = 0 or typename==ClassName.
1089 /// This is a case, when data of parent class "ClassName" should be streamed.
1090 /// For instance, if class directly inherited from TObject, custom streamer
1091 /// should include following code:
1092 /// ~~~{.cpp}
1093 /// b.ClassMember("TObject");
1094 /// TObject::Streamer(b);
1095 /// ~~~
1096 /// -# Basic data type
1097 /// ~~~{.cpp}
1098 /// b.ClassMember("fInt","Int_t");
1099 /// b >> fInt;
1100 /// ~~~
1101 /// -# Array of basic data types
1102 /// ~~~{.cpp}
1103 /// b.ClassMember("fArr","Int_t", 5);
1104 /// b.ReadFastArray(fArr, 5);
1105 /// ~~~
1106 /// -# Object as data member
1107 /// ~~~{.cpp}
1108 /// b.ClassMemeber("fName","TString");
1109 /// fName.Streamer(b);
1110 /// ~~~
1111 /// -# Pointer on object as data member
1112 /// ~~~{.cpp}
1113 /// b.ClassMemeber("fObj","TObject*");
1114 /// b.StreamObject(fObj);
1115 /// ~~~
1116 ///
1117 /// Arrsize1 and arrsize2 arguments (when specified) indicate first and
1118 /// second dimension of array. Can be used for array of basic types.
1119 /// See ClassBegin() method for more details.
1120 
1121 void TBufferXML::ClassMember(const char *name, const char *typeName, Int_t arrsize1, Int_t arrsize2)
1122 {
1123  if (!typeName)
1124  typeName = name;
1125 
1126  if (!name || (strlen(name) == 0)) {
1127  Error("ClassMember", "Invalid member name");
1128  fErrorFlag = 1;
1129  return;
1130  }
1131 
1132  TString tname = typeName;
1133 
1134  Int_t typ_id(-1), comp_type(-1);
1135 
1136  if (strcmp(typeName, "raw:data") == 0)
1137  typ_id = TStreamerInfo::kMissing;
1138 
1139  if (typ_id < 0) {
1140  TDataType *dt = gROOT->GetType(typeName);
1141  if (dt)
1142  if ((dt->GetType() > 0) && (dt->GetType() < 20))
1143  typ_id = dt->GetType();
1144  }
1145 
1146  if (typ_id < 0)
1147  if (strcmp(name, typeName) == 0) {
1148  TClass *cl = TClass::GetClass(tname.Data());
1149  if (cl)
1150  typ_id = TStreamerInfo::kBase;
1151  }
1152 
1153  if (typ_id < 0) {
1154  Bool_t isptr = kFALSE;
1155  if (tname[tname.Length() - 1] == '*') {
1156  tname.Resize(tname.Length() - 1);
1157  isptr = kTRUE;
1158  }
1159  TClass *cl = TClass::GetClass(tname.Data());
1160  if (!cl) {
1161  Error("ClassMember", "Invalid class specifier %s", typeName);
1162  fErrorFlag = 1;
1163  return;
1164  }
1165 
1166  if (cl->IsTObject())
1168  else
1169  typ_id = isptr ? TStreamerInfo::kAnyp : TStreamerInfo::kAny;
1170 
1171  if ((cl == TString::Class()) && !isptr)
1172  typ_id = TStreamerInfo::kTString;
1173  }
1174 
1175  TStreamerElement *elem = nullptr;
1176 
1177  if (typ_id == TStreamerInfo::kMissing) {
1178  elem = new TStreamerElement(name, "title", 0, typ_id, "raw:data");
1179  } else if (typ_id == TStreamerInfo::kBase) {
1180  TClass *cl = TClass::GetClass(tname.Data());
1181  if (cl) {
1182  TStreamerBase *b = new TStreamerBase(tname.Data(), "title", 0);
1183  b->SetBaseVersion(cl->GetClassVersion());
1184  elem = b;
1185  }
1186  } else if ((typ_id > 0) && (typ_id < 20)) {
1187  elem = new TStreamerBasicType(name, "title", 0, typ_id, typeName);
1188  comp_type = typ_id;
1189  } else if ((typ_id == TStreamerInfo::kObject) || (typ_id == TStreamerInfo::kTObject) ||
1190  (typ_id == TStreamerInfo::kTNamed)) {
1191  elem = new TStreamerObject(name, "title", 0, tname.Data());
1192  } else if (typ_id == TStreamerInfo::kObjectp) {
1193  elem = new TStreamerObjectPointer(name, "title", 0, tname.Data());
1194  } else if (typ_id == TStreamerInfo::kAny) {
1195  elem = new TStreamerObjectAny(name, "title", 0, tname.Data());
1196  } else if (typ_id == TStreamerInfo::kAnyp) {
1197  elem = new TStreamerObjectAnyPointer(name, "title", 0, tname.Data());
1198  } else if (typ_id == TStreamerInfo::kTString) {
1199  elem = new TStreamerString(name, "title", 0);
1200  }
1201 
1202  if (!elem) {
1203  Error("ClassMember", "Invalid combination name = %s type = %s", name, typeName);
1204  fErrorFlag = 1;
1205  return;
1206  }
1207 
1208  if (arrsize1 > 0) {
1209  elem->SetArrayDim(arrsize2 > 0 ? 2 : 1);
1210  elem->SetMaxIndex(0, arrsize1);
1211  if (arrsize2 > 0)
1212  elem->SetMaxIndex(1, arrsize2);
1213  }
1214 
1215  // we indicate that there is no streamerinfo
1216  WorkWithElement(elem, comp_type);
1217 }
1218 
1219 ////////////////////////////////////////////////////////////////////////////////
1220 /// Function is converts TObject and TString structures to more compact representation
1221 
1223 {
1224  if (GetXmlLayout() == kGeneralized)
1225  return;
1226 
1227  const TStreamerElement *elem = Stack()->fElem;
1228  XMLNodePointer_t elemnode = IsWriting() ? Stack()->fNode : Stack(1)->fNode;
1229 
1230  if (!elem || !elemnode)
1231  return;
1232 
1233  if (elem->GetType() == TStreamerInfo::kTString) {
1234 
1235  XMLNodePointer_t node = fXML->GetChild(elemnode);
1236  fXML->SkipEmpty(node);
1237 
1238  XMLNodePointer_t nodecharstar(nullptr), nodeuchar(nullptr), nodeint(nullptr), nodestring(nullptr);
1239 
1240  while (node) {
1241  const char *name = fXML->GetNodeName(node);
1242  if (strcmp(name, xmlio::String) == 0) {
1243  if (nodestring)
1244  return;
1245  nodestring = node;
1246  } else if (strcmp(name, xmlio::UChar) == 0) {
1247  if (nodeuchar)
1248  return;
1249  nodeuchar = node;
1250  } else if (strcmp(name, xmlio::Int) == 0) {
1251  if (nodeint)
1252  return;
1253  nodeint = node;
1254  } else if (strcmp(name, xmlio::CharStar) == 0) {
1255  if (nodecharstar)
1256  return;
1257  nodecharstar = node;
1258  } else
1259  return; // can not be something else
1260  fXML->ShiftToNext(node);
1261  }
1262 
1263  TString str;
1264 
1265  if (GetIOVersion() < 3) {
1266  if (!nodeuchar)
1267  return;
1268  if (nodecharstar)
1269  str = fXML->GetAttr(nodecharstar, xmlio::v);
1270  fXML->UnlinkFreeNode(nodeuchar);
1271  fXML->UnlinkFreeNode(nodeint);
1272  fXML->UnlinkFreeNode(nodecharstar);
1273  } else {
1274  if (nodestring)
1275  str = fXML->GetAttr(nodestring, xmlio::v);
1276  fXML->UnlinkFreeNode(nodestring);
1277  }
1278 
1279  fXML->NewAttr(elemnode, nullptr, "str", str);
1280  } else if (elem->GetType() == TStreamerInfo::kTObject) {
1281  XMLNodePointer_t node = fXML->GetChild(elemnode);
1282  fXML->SkipEmpty(node);
1283 
1284  XMLNodePointer_t vnode = nullptr, idnode = nullptr, bitsnode = nullptr, prnode = nullptr;
1285 
1286  while (node) {
1287  const char *name = fXML->GetNodeName(node);
1288 
1289  if (strcmp(name, xmlio::OnlyVersion) == 0) {
1290  if (vnode)
1291  return;
1292  vnode = node;
1293  } else if (strcmp(name, xmlio::UInt) == 0) {
1294  if (!idnode)
1295  idnode = node;
1296  else if (!bitsnode)
1297  bitsnode = node;
1298  else
1299  return;
1300  } else if (strcmp(name, xmlio::UShort) == 0) {
1301  if (prnode)
1302  return;
1303  prnode = node;
1304  } else
1305  return;
1306  fXML->ShiftToNext(node);
1307  }
1308 
1309  if (!vnode || !idnode || !bitsnode)
1310  return;
1311 
1312  TString str = fXML->GetAttr(idnode, xmlio::v);
1313  fXML->NewAttr(elemnode, nullptr, "fUniqueID", str);
1314 
1315  str = fXML->GetAttr(bitsnode, xmlio::v);
1316  UInt_t bits;
1317  sscanf(str.Data(), "%u", &bits);
1318 
1319  char sbuf[20];
1320  snprintf(sbuf, sizeof(sbuf), "%x", bits);
1321  fXML->NewAttr(elemnode, nullptr, "fBits", sbuf);
1322 
1323  if (prnode) {
1324  str = fXML->GetAttr(prnode, xmlio::v);
1325  fXML->NewAttr(elemnode, nullptr, "fProcessID", str);
1326  }
1327 
1328  fXML->UnlinkFreeNode(vnode);
1329  fXML->UnlinkFreeNode(idnode);
1330  fXML->UnlinkFreeNode(bitsnode);
1331  fXML->UnlinkFreeNode(prnode);
1332  }
1333 }
1334 
1335 ////////////////////////////////////////////////////////////////////////////////
1336 /// Function is unpack TObject and TString structures to be able read
1337 /// them from custom streamers of this objects
1338 
1340 {
1341  if (GetXmlLayout() == kGeneralized)
1342  return;
1343  if (!elem || !elemnode)
1344  return;
1345 
1346  if (elem->GetType() == TStreamerInfo::kTString) {
1347 
1348  if (!fXML->HasAttr(elemnode, "str"))
1349  return;
1350  TString str = fXML->GetAttr(elemnode, "str");
1351  fXML->FreeAttr(elemnode, "str");
1352 
1353  if (GetIOVersion() < 3) {
1354  Int_t len = str.Length();
1355  XMLNodePointer_t ucharnode = fXML->NewChild(elemnode, nullptr, xmlio::UChar);
1356  char sbuf[20];
1357  snprintf(sbuf, sizeof(sbuf), "%d", len);
1358  if (len < 255) {
1359  fXML->NewAttr(ucharnode, nullptr, xmlio::v, sbuf);
1360  } else {
1361  fXML->NewAttr(ucharnode, nullptr, xmlio::v, "255");
1362  XMLNodePointer_t intnode = fXML->NewChild(elemnode, nullptr, xmlio::Int);
1363  fXML->NewAttr(intnode, nullptr, xmlio::v, sbuf);
1364  }
1365  if (len > 0) {
1366  XMLNodePointer_t node = fXML->NewChild(elemnode, nullptr, xmlio::CharStar);
1367  fXML->NewAttr(node, nullptr, xmlio::v, str);
1368  }
1369  } else {
1370  XMLNodePointer_t node = fXML->NewChild(elemnode, nullptr, xmlio::String);
1371  fXML->NewAttr(node, nullptr, xmlio::v, str);
1372  }
1373  } else if (elem->GetType() == TStreamerInfo::kTObject) {
1374  if (!fXML->HasAttr(elemnode, "fUniqueID"))
1375  return;
1376  if (!fXML->HasAttr(elemnode, "fBits"))
1377  return;
1378 
1379  TString idstr = fXML->GetAttr(elemnode, "fUniqueID");
1380  TString bitsstr = fXML->GetAttr(elemnode, "fBits");
1381  TString prstr = fXML->GetAttr(elemnode, "fProcessID");
1382 
1383  fXML->FreeAttr(elemnode, "fUniqueID");
1384  fXML->FreeAttr(elemnode, "fBits");
1385  fXML->FreeAttr(elemnode, "fProcessID");
1386 
1387  XMLNodePointer_t node = fXML->NewChild(elemnode, nullptr, xmlio::OnlyVersion);
1388  fXML->NewAttr(node, nullptr, xmlio::v, "1");
1389 
1390  node = fXML->NewChild(elemnode, nullptr, xmlio::UInt);
1391  fXML->NewAttr(node, nullptr, xmlio::v, idstr);
1392 
1393  UInt_t bits;
1394  sscanf(bitsstr.Data(), "%x", &bits);
1395  char sbuf[20];
1396  snprintf(sbuf, sizeof(sbuf), "%u", bits);
1397 
1398  node = fXML->NewChild(elemnode, nullptr, xmlio::UInt);
1399  fXML->NewAttr(node, nullptr, xmlio::v, sbuf);
1400 
1401  if (prstr.Length() > 0) {
1402  node = fXML->NewChild(elemnode, nullptr, xmlio::UShort);
1403  fXML->NewAttr(node, nullptr, xmlio::v, prstr.Data());
1404  }
1405  }
1406 }
1407 
1408 ////////////////////////////////////////////////////////////////////////////////
1409 /// Function is called before any IO operation of TBuffer
1410 /// Now is used to store version value if no proper calls are discovered
1411 
1413 {
1414  CheckVersionBuf();
1415 }
1416 
1417 ////////////////////////////////////////////////////////////////////////////////
1418 /// Function to read class from buffer, used in old-style streamers
1419 
1421 {
1422  const char *clname = nullptr;
1423 
1425  clname = XmlReadValue(xmlio::Class);
1426 
1427  if (gDebug > 2)
1428  Info("ReadClass", "Try to read class %s", clname ? clname : "---");
1429 
1430  return clname ? gROOT->GetClass(clname) : nullptr;
1431 }
1432 
1433 ////////////////////////////////////////////////////////////////////////////////
1434 /// Function to write class into buffer, used in old-style streamers
1435 
1437 {
1438  if (gDebug > 2)
1439  Info("WriteClass", "Try to write class %s", cl->GetName());
1440 
1442 }
1443 
1444 ////////////////////////////////////////////////////////////////////////////////
1445 /// Read version value from buffer
1446 
1447 Version_t TBufferXML::ReadVersion(UInt_t *start, UInt_t *bcnt, const TClass * /*cl*/)
1448 {
1450 
1451  Version_t res = 0;
1452 
1453  if (start)
1454  *start = 0;
1455  if (bcnt)
1456  *bcnt = 0;
1457 
1460  } else if (fExpectedBaseClass && (fXML->HasAttr(Stack(1)->fNode, xmlio::ClassVersion))) {
1461  res = fXML->GetIntAttr(Stack(1)->fNode, xmlio::ClassVersion);
1462  } else if (fXML->HasAttr(StackNode(), xmlio::ClassVersion)) {
1464  } else {
1465  Error("ReadVersion", "No correspondent tags to read version");
1466  fErrorFlag = 1;
1467  }
1468 
1469  if (gDebug > 2)
1470  Info("ReadVersion", "Version = %d", res);
1471 
1472  return res;
1473 }
1474 
1475 ////////////////////////////////////////////////////////////////////////////////
1476 /// Checks buffer, filled by WriteVersion
1477 /// if next data is arriving, version should be stored in buffer
1478 
1480 {
1481  if (IsWriting() && (fVersionBuf >= -100)) {
1482  char sbuf[20];
1483  snprintf(sbuf, sizeof(sbuf), "%d", fVersionBuf);
1485  fVersionBuf = -111;
1486  }
1487 }
1488 
1489 ////////////////////////////////////////////////////////////////////////////////
1490 /// Copies class version to buffer, but not writes it to xml
1491 /// Version will be written with next I/O operation or
1492 /// will be added as attribute of class tag, created by IncrementLevel call
1493 
1495 {
1497 
1498  if (fExpectedBaseClass != cl)
1499  fExpectedBaseClass = nullptr;
1500 
1501  fVersionBuf = cl->GetClassVersion();
1502 
1503  if (gDebug > 2)
1504  Info("WriteVersion", "Class: %s, version = %d", cl->GetName(), fVersionBuf);
1505 
1506  return 0;
1507 }
1508 
1509 ////////////////////////////////////////////////////////////////////////////////
1510 /// Read object from buffer. Only used from TBuffer
1511 
1513 {
1515  if (gDebug > 2)
1516  Info("ReadObjectAny", "From node %s", fXML->GetNodeName(StackNode()));
1517  void *res = XmlReadObject(nullptr);
1518  return res;
1519 }
1520 
1521 ////////////////////////////////////////////////////////////////////////////////
1522 /// Skip any kind of object from buffer
1523 /// Actually skip only one node on current level of xml structure
1524 
1526 {
1527  ShiftStack("skipobjectany");
1528 }
1529 
1530 ////////////////////////////////////////////////////////////////////////////////
1531 /// Write object to buffer. Only used from TBuffer
1532 
1533 void TBufferXML::WriteObjectClass(const void *actualObjStart, const TClass *actualClass, Bool_t cacheReuse)
1534 {
1536  if (gDebug > 2)
1537  Info("WriteObject", "Class %s", (actualClass ? actualClass->GetName() : " null"));
1538  XmlWriteObject(actualObjStart, actualClass, cacheReuse);
1539 }
1540 
1541 ////////////////////////////////////////////////////////////////////////////////
1542 /// Template method to read array content
1543 
1544 template <typename T>
1546 {
1547  Int_t indx = 0, cnt, curr;
1548  while (indx < arrsize) {
1549  cnt = 1;
1550  if (fXML->HasAttr(StackNode(), xmlio::cnt))
1552  XmlReadBasic(arr[indx]);
1553  curr = indx++;
1554  while (cnt-- > 1)
1555  arr[indx++] = arr[curr];
1556  }
1557 }
1558 
1559 ////////////////////////////////////////////////////////////////////////////////
1560 /// Template method to read array with size attribute
1561 /// If necessary, array is created
1562 
1563 template <typename T>
1565 {
1567  if (!VerifyItemNode(xmlio::Array, is_static ? "ReadStaticArray" : "ReadArray"))
1568  return 0;
1570  if (n <= 0)
1571  return 0;
1572  if (!arr) {
1573  if (is_static)
1574  return 0;
1575  arr = new T[n];
1576  }
1577  PushStack(StackNode());
1578  XmlReadArrayContent(arr, n);
1579  PopStack();
1580  ShiftStack(is_static ? "readstatarr" : "readarr");
1581  return n;
1582 }
1583 
1584 ////////////////////////////////////////////////////////////////////////////////
1585 /// Read array of Bool_t from buffer
1586 
1588 {
1589  return XmlReadArray(b);
1590 }
1591 
1592 ////////////////////////////////////////////////////////////////////////////////
1593 /// Read array of Char_t from buffer
1594 
1596 {
1597  return XmlReadArray(c);
1598 }
1599 
1600 ////////////////////////////////////////////////////////////////////////////////
1601 /// Read array of UChar_t from buffer
1602 
1604 {
1605  return XmlReadArray(c);
1606 }
1607 
1608 ////////////////////////////////////////////////////////////////////////////////
1609 /// Read array of Short_t from buffer
1610 
1612 {
1613  return XmlReadArray(h);
1614 }
1615 
1616 ////////////////////////////////////////////////////////////////////////////////
1617 /// Read array of UShort_t from buffer
1618 
1620 {
1621  return XmlReadArray(h);
1622 }
1623 
1624 ////////////////////////////////////////////////////////////////////////////////
1625 /// Read array of Int_t from buffer
1626 
1628 {
1629  return XmlReadArray(i);
1630 }
1631 
1632 ////////////////////////////////////////////////////////////////////////////////
1633 /// Read array of UInt_t from buffer
1634 
1636 {
1637  return XmlReadArray(i);
1638 }
1639 
1640 ////////////////////////////////////////////////////////////////////////////////
1641 /// Read array of Long_t from buffer
1642 
1644 {
1645  return XmlReadArray(l);
1646 }
1647 
1648 ////////////////////////////////////////////////////////////////////////////////
1649 /// Read array of ULong_t from buffer
1650 
1652 {
1653  return XmlReadArray(l);
1654 }
1655 
1656 ////////////////////////////////////////////////////////////////////////////////
1657 /// Read array of Long64_t from buffer
1658 
1660 {
1661  return XmlReadArray(l);
1662 }
1663 
1664 ////////////////////////////////////////////////////////////////////////////////
1665 /// Read array of ULong64_t from buffer
1666 
1668 {
1669  return XmlReadArray(l);
1670 }
1671 
1672 ////////////////////////////////////////////////////////////////////////////////
1673 /// Read array of Float_t from buffer
1674 
1676 {
1677  return XmlReadArray(f);
1678 }
1679 
1680 ////////////////////////////////////////////////////////////////////////////////
1681 /// Read array of Double_t from buffer
1682 
1684 {
1685  return XmlReadArray(d);
1686 }
1687 
1688 ////////////////////////////////////////////////////////////////////////////////
1689 /// Read array of Bool_t from buffer
1690 
1692 {
1693  return XmlReadArray(b, true);
1694 }
1695 
1696 ////////////////////////////////////////////////////////////////////////////////
1697 /// Read array of Char_t from buffer
1698 
1700 {
1701  return XmlReadArray(c, true);
1702 }
1703 
1704 ////////////////////////////////////////////////////////////////////////////////
1705 /// Read array of UChar_t from buffer
1706 
1708 {
1709  return XmlReadArray(c, true);
1710 }
1711 
1712 ////////////////////////////////////////////////////////////////////////////////
1713 /// Read array of Short_t from buffer
1714 
1716 {
1717  return XmlReadArray(h, true);
1718 }
1719 
1720 ////////////////////////////////////////////////////////////////////////////////
1721 /// Read array of UShort_t from buffer
1722 
1724 {
1725  return XmlReadArray(h, true);
1726 }
1727 
1728 ////////////////////////////////////////////////////////////////////////////////
1729 /// Read array of Int_t from buffer
1730 
1732 {
1733  return XmlReadArray(i, true);
1734 }
1735 
1736 ////////////////////////////////////////////////////////////////////////////////
1737 /// Read array of UInt_t from buffer
1738 
1740 {
1741  return XmlReadArray(i, true);
1742 }
1743 
1744 ////////////////////////////////////////////////////////////////////////////////
1745 /// Read array of Long_t from buffer
1746 
1748 {
1749  return XmlReadArray(l, true);
1750 }
1751 
1752 ////////////////////////////////////////////////////////////////////////////////
1753 /// Read array of ULong_t from buffer
1754 
1756 {
1757  return XmlReadArray(l, true);
1758 }
1759 
1760 ////////////////////////////////////////////////////////////////////////////////
1761 /// Read array of Long64_t from buffer
1762 
1764 {
1765  return XmlReadArray(l, true);
1766 }
1767 
1768 ////////////////////////////////////////////////////////////////////////////////
1769 /// Read array of ULong64_t from buffer
1770 
1772 {
1773  return XmlReadArray(l, true);
1774 }
1775 
1776 ////////////////////////////////////////////////////////////////////////////////
1777 /// Read array of Float_t from buffer
1778 
1780 {
1781  return XmlReadArray(f, true);
1782 }
1783 
1784 ////////////////////////////////////////////////////////////////////////////////
1785 /// Read array of Double_t from buffer
1786 
1788 {
1789  return XmlReadArray(d, true);
1790 }
1791 
1792 ////////////////////////////////////////////////////////////////////////////////
1793 /// Template method to read content of array, which not include size of array
1794 /// Also treated situation, when instead of one single array chain
1795 /// of several elements should be produced
1796 
1797 template <typename T>
1799 {
1801  if (n <= 0)
1802  return;
1803  if (!VerifyItemNode(xmlio::Array, "ReadFastArray"))
1804  return;
1805  PushStack(StackNode());
1806  XmlReadArrayContent(arr, n);
1807  PopStack();
1808  ShiftStack("readfastarr");
1809 }
1810 
1811 ////////////////////////////////////////////////////////////////////////////////
1812 /// Read array of Bool_t from buffer
1813 
1815 {
1816  XmlReadFastArray(b, n);
1817 }
1818 
1819 ////////////////////////////////////////////////////////////////////////////////
1820 /// Read array of Char_t from buffer
1821 /// if nodename==CharStar, read all array as string
1822 
1824 {
1825  if ((n > 0) && VerifyItemNode(xmlio::CharStar)) {
1826  const char *buf;
1827  if ((buf = XmlReadValue(xmlio::CharStar))) {
1828  Int_t size = strlen(buf);
1829  if (size < n)
1830  size = n;
1831  memcpy(c, buf, size);
1832  }
1833  } else {
1834  XmlReadFastArray(c, n);
1835  }
1836 }
1837 
1838 ////////////////////////////////////////////////////////////////////////////////
1839 /// Read array of n characters from the I/O buffer.
1840 /// Used only from TLeafC, dummy implementation here
1841 
1843 {
1844  ReadFastArray(c, n);
1845 }
1846 
1847 ////////////////////////////////////////////////////////////////////////////////
1848 /// Read array of UChar_t from buffer
1849 
1851 {
1852  XmlReadFastArray(c, n);
1853 }
1854 
1855 ////////////////////////////////////////////////////////////////////////////////
1856 /// Read array of Short_t from buffer
1857 
1859 {
1860  XmlReadFastArray(h, n);
1861 }
1862 
1863 ////////////////////////////////////////////////////////////////////////////////
1864 /// Read array of UShort_t from buffer
1865 
1867 {
1868  XmlReadFastArray(h, n);
1869 }
1870 
1871 ////////////////////////////////////////////////////////////////////////////////
1872 /// Read array of Int_t from buffer
1873 
1875 {
1876  XmlReadFastArray(i, n);
1877 }
1878 
1879 ////////////////////////////////////////////////////////////////////////////////
1880 /// Read array of UInt_t from buffer
1881 
1883 {
1884  XmlReadFastArray(i, n);
1885 }
1886 
1887 ////////////////////////////////////////////////////////////////////////////////
1888 /// Read array of Long_t from buffer
1889 
1891 {
1892  XmlReadFastArray(l, n);
1893 }
1894 
1895 ////////////////////////////////////////////////////////////////////////////////
1896 /// Read array of ULong_t from buffer
1897 
1899 {
1900  XmlReadFastArray(l, n);
1901 }
1902 
1903 ////////////////////////////////////////////////////////////////////////////////
1904 /// Read array of Long64_t from buffer
1905 
1907 {
1908  XmlReadFastArray(l, n);
1909 }
1910 
1911 ////////////////////////////////////////////////////////////////////////////////
1912 /// Read array of ULong64_t from buffer
1913 
1915 {
1916  XmlReadFastArray(l, n);
1917 }
1918 
1919 ////////////////////////////////////////////////////////////////////////////////
1920 /// Read array of Float_t from buffer
1921 
1923 {
1924  XmlReadFastArray(f, n);
1925 }
1926 
1927 ////////////////////////////////////////////////////////////////////////////////
1928 /// Read array of Double_t from buffer
1929 
1931 {
1932  XmlReadFastArray(d, n);
1933 }
1934 
1935 ////////////////////////////////////////////////////////////////////////////////
1936 /// Read an array of 'n' objects from the I/O buffer.
1937 /// Stores the objects read starting at the address 'start'.
1938 /// The objects in the array are assume to be of class 'cl'.
1939 
1940 void TBufferXML::ReadFastArray(void *start, const TClass *cl, Int_t n, TMemberStreamer *streamer,
1941  const TClass *onFileClass)
1942 {
1943  if (streamer) {
1944  streamer->SetOnFileClass(onFileClass);
1945  (*streamer)(*this, start, 0);
1946  return;
1947  }
1948 
1949  int objectSize = cl->Size();
1950  char *obj = (char *)start;
1951  char *end = obj + n * objectSize;
1952 
1953  for (; obj < end; obj += objectSize)
1954  ((TClass *)cl)->Streamer(obj, *this, onFileClass);
1955 }
1956 
1957 ////////////////////////////////////////////////////////////////////////////////
1958 /// Read an array of 'n' objects from the I/O buffer.
1959 ///
1960 /// The objects read are stored starting at the address '*start'
1961 /// The objects in the array are assumed to be of class 'cl' or a derived class.
1962 /// 'mode' indicates whether the data member is marked with '->'
1963 
1964 void TBufferXML::ReadFastArray(void **start, const TClass *cl, Int_t n, Bool_t isPreAlloc, TMemberStreamer *streamer,
1965  const TClass *onFileClass)
1966 {
1967 
1968  Bool_t oldStyle = kFALSE; // flag used to reproduce old-style I/= actions for kSTLp
1969 
1970  if ((GetIOVersion() < 4) && !isPreAlloc) {
1971  TStreamerElement *elem = Stack()->fElem;
1972  if (elem && ((elem->GetType() == TStreamerInfo::kSTLp) ||
1974  oldStyle = kTRUE;
1975  }
1976 
1977  if (streamer) {
1978  if (isPreAlloc) {
1979  for (Int_t j = 0; j < n; j++) {
1980  if (!start[j])
1981  start[j] = cl->New();
1982  }
1983  }
1984  streamer->SetOnFileClass(onFileClass);
1985  (*streamer)(*this, (void *)start, oldStyle ? n : 0);
1986  return;
1987  }
1988 
1989  if (!isPreAlloc) {
1990 
1991  for (Int_t j = 0; j < n; j++) {
1992  if (oldStyle) {
1993  if (!start[j])
1994  start[j] = ((TClass *)cl)->New();
1995  ((TClass *)cl)->Streamer(start[j], *this);
1996  continue;
1997  }
1998  // delete the object or collection
1999  void *old = start[j];
2000  start[j] = ReadObjectAny(cl);
2001  if (old && old != start[j] && TStreamerInfo::CanDelete()
2002  // There are some cases where the user may set up a pointer in the (default)
2003  // constructor but not mark this pointer as transient. Sometime the value
2004  // of this pointer is the address of one of the object with just created
2005  // and the following delete would result in the deletion (possibly of the
2006  // top level object we are goint to return!).
2007  // Eventhough this is a user error, we could prevent the crash by simply
2008  // adding:
2009  // && !CheckObject(start[j],cl)
2010  // However this can increase the read time significantly (10% in the case
2011  // of one TLine pointer in the test/Track and run ./Event 200 0 0 20 30000
2012  //
2013  // If ReadObjectAny returned the same value as we previous had, this means
2014  // that when writing this object (start[j] had already been written and
2015  // is indeed pointing to the same object as the object the user set up
2016  // in the default constructor).
2017  ) {
2018  ((TClass *)cl)->Destructor(old, kFALSE); // call delete and desctructor
2019  }
2020  }
2021 
2022  } else {
2023  // case //-> in comment
2024 
2025  for (Int_t j = 0; j < n; j++) {
2026  if (!start[j])
2027  start[j] = ((TClass *)cl)->New();
2028  ((TClass *)cl)->Streamer(start[j], *this, onFileClass);
2029  }
2030  }
2031 }
2032 
2033 template <typename T>
2035 {
2036  if (fCompressLevel > 0) {
2037  Int_t indx = 0;
2038  while (indx < arrsize) {
2039  XMLNodePointer_t elemnode = XmlWriteBasic(arr[indx]);
2040  Int_t curr = indx++;
2041  while ((indx < arrsize) && (arr[indx] == arr[curr]))
2042  indx++;
2043  if (indx - curr > 1)
2044  fXML->NewIntAttr(elemnode, xmlio::cnt, indx - curr);
2045  }
2046  } else {
2047  for (Int_t indx = 0; indx < arrsize; indx++)
2048  XmlWriteBasic(arr[indx]);
2049  }
2050 }
2051 
2052 ////////////////////////////////////////////////////////////////////////////////
2053 /// Write array, including it size
2054 /// Content may be compressed
2055 
2056 template <typename T>
2058 {
2061  fXML->NewIntAttr(arrnode, xmlio::Size, arrsize);
2062  PushStack(arrnode);
2063  XmlWriteArrayContent(arr, arrsize);
2064  PopStack();
2065 }
2066 
2067 ////////////////////////////////////////////////////////////////////////////////
2068 /// Write array of Bool_t to buffer
2069 
2071 {
2072  XmlWriteArray(b, n);
2073 }
2074 
2075 ////////////////////////////////////////////////////////////////////////////////
2076 /// Write array of Char_t to buffer
2077 
2079 {
2080  XmlWriteArray(c, n);
2081 }
2082 
2083 ////////////////////////////////////////////////////////////////////////////////
2084 /// Write array of UChar_t to buffer
2085 
2087 {
2088  XmlWriteArray(c, n);
2089 }
2090 
2091 ////////////////////////////////////////////////////////////////////////////////
2092 /// Write array of Short_t to buffer
2093 
2095 {
2096  XmlWriteArray(h, n);
2097 }
2098 
2099 ////////////////////////////////////////////////////////////////////////////////
2100 /// Write array of UShort_t to buffer
2101 
2103 {
2104  XmlWriteArray(h, n);
2105 }
2106 
2107 ////////////////////////////////////////////////////////////////////////////////
2108 /// Write array of Int_ to buffer
2109 
2111 {
2112  XmlWriteArray(i, n);
2113 }
2114 
2115 ////////////////////////////////////////////////////////////////////////////////
2116 /// Write array of UInt_t to buffer
2117 
2119 {
2120  XmlWriteArray(i, n);
2121 }
2122 
2123 ////////////////////////////////////////////////////////////////////////////////
2124 /// Write array of Long_t to buffer
2125 
2127 {
2128  XmlWriteArray(l, n);
2129 }
2130 
2131 ////////////////////////////////////////////////////////////////////////////////
2132 /// Write array of ULong_t to buffer
2133 
2135 {
2136  XmlWriteArray(l, n);
2137 }
2138 
2139 ////////////////////////////////////////////////////////////////////////////////
2140 /// Write array of Long64_t to buffer
2141 
2143 {
2144  XmlWriteArray(l, n);
2145 }
2146 
2147 ////////////////////////////////////////////////////////////////////////////////
2148 /// Write array of ULong64_t to buffer
2149 
2151 {
2152  XmlWriteArray(l, n);
2153 }
2154 
2155 ////////////////////////////////////////////////////////////////////////////////
2156 /// Write array of Float_t to buffer
2157 
2159 {
2160  XmlWriteArray(f, n);
2161 }
2162 
2163 ////////////////////////////////////////////////////////////////////////////////
2164 /// Write array of Double_t to buffer
2165 
2167 {
2168  XmlWriteArray(d, n);
2169 }
2170 
2171 /////////////////////////////////////////////////////////////////////////////////
2172 /// Write array without size attribute
2173 /// Also treat situation, when instead of one single array
2174 /// chain of several elements should be produced
2175 
2176 template <typename T>
2178 {
2180  if (n <= 0)
2181  return;
2183  PushStack(arrnode);
2184  XmlWriteArrayContent(arr, n);
2185  PopStack();
2186 }
2187 
2188 ////////////////////////////////////////////////////////////////////////////////
2189 /// Write array of Bool_t to buffer
2190 
2192 {
2193  XmlWriteFastArray(b, n);
2194 }
2195 
2196 ////////////////////////////////////////////////////////////////////////////////
2197 /// Write array of Char_t to buffer
2198 /// If array does not include any special characters,
2199 /// it will be reproduced as CharStar node with string as attribute
2200 
2202 {
2203  Bool_t usedefault = (n == 0);
2204  const Char_t *buf = c;
2205  if (!usedefault)
2206  for (int i = 0; i < n; i++) {
2207  if (*buf < 27) {
2208  usedefault = kTRUE;
2209  break;
2210  }
2211  buf++;
2212  }
2213  if (usedefault) {
2214  XmlWriteFastArray(c, n);
2215  } else {
2216  Char_t *buf2 = new Char_t[n + 1];
2217  memcpy(buf2, c, n);
2218  buf2[n] = 0;
2220  delete[] buf2;
2221  }
2222 }
2223 
2224 ////////////////////////////////////////////////////////////////////////////////
2225 /// Write array of UChar_t to buffer
2226 
2228 {
2229  XmlWriteFastArray(c, n);
2230 }
2231 
2232 ////////////////////////////////////////////////////////////////////////////////
2233 /// Write array of Short_t to buffer
2234 
2236 {
2237  XmlWriteFastArray(h, n);
2238 }
2239 
2240 ////////////////////////////////////////////////////////////////////////////////
2241 /// Write array of UShort_t to buffer
2242 
2244 {
2245  XmlWriteFastArray(h, n);
2246 }
2247 
2248 ////////////////////////////////////////////////////////////////////////////////
2249 /// Write array of Int_t to buffer
2250 
2252 {
2253  XmlWriteFastArray(i, n);
2254 }
2255 
2256 ////////////////////////////////////////////////////////////////////////////////
2257 /// Write array of UInt_t to buffer
2258 
2260 {
2261  XmlWriteFastArray(i, n);
2262 }
2263 
2264 ////////////////////////////////////////////////////////////////////////////////
2265 /// Write array of Long_t to buffer
2266 
2268 {
2269  XmlWriteFastArray(l, n);
2270 }
2271 
2272 ////////////////////////////////////////////////////////////////////////////////
2273 /// Write array of ULong_t to buffer
2274 
2276 {
2277  XmlWriteFastArray(l, n);
2278 }
2279 
2280 ////////////////////////////////////////////////////////////////////////////////
2281 /// Write array of Long64_t to buffer
2282 
2284 {
2285  XmlWriteFastArray(l, n);
2286 }
2287 
2288 ////////////////////////////////////////////////////////////////////////////////
2289 /// Write array of ULong64_t to buffer
2290 
2292 {
2293  XmlWriteFastArray(l, n);
2294 }
2295 
2296 ////////////////////////////////////////////////////////////////////////////////
2297 /// Write array of Float_t to buffer
2298 
2300 {
2301  XmlWriteFastArray(f, n);
2302 }
2303 
2304 ////////////////////////////////////////////////////////////////////////////////
2305 /// Write array of Double_t to buffer
2306 
2308 {
2309  XmlWriteFastArray(d, n);
2310 }
2311 
2312 ////////////////////////////////////////////////////////////////////////////////
2313 /// Write array of n characters into the I/O buffer.
2314 /// Used only by TLeafC, just dummy implementation here
2315 
2317 {
2318  WriteFastArray(c, n);
2319 }
2320 
2321 ////////////////////////////////////////////////////////////////////////////////
2322 /// Write an array of object starting at the address 'start' and of length 'n'
2323 /// the objects in the array are assumed to be of class 'cl'
2324 
2325 void TBufferXML::WriteFastArray(void *start, const TClass *cl, Int_t n, TMemberStreamer *streamer)
2326 {
2327  if (streamer) {
2328  (*streamer)(*this, start, 0);
2329  return;
2330  }
2331 
2332  char *obj = (char *)start;
2333  if (!n)
2334  n = 1;
2335  int size = cl->Size();
2336 
2337  for (Int_t j = 0; j < n; j++, obj += size) {
2338  ((TClass *)cl)->Streamer(obj, *this);
2339  }
2340 }
2341 
2342 ////////////////////////////////////////////////////////////////////////////////
2343 /// Write an array of object starting at the address '*start' and of length 'n'
2344 /// the objects in the array are of class 'cl'
2345 /// 'isPreAlloc' indicates whether the data member is marked with '->'
2346 /// Return:
2347 /// - 0: success
2348 /// - 2: truncated success (i.e actual class is missing. Only ptrClass saved.)
2349 
2350 Int_t TBufferXML::WriteFastArray(void **start, const TClass *cl, Int_t n, Bool_t isPreAlloc, TMemberStreamer *streamer)
2351 {
2352  // if isPreAlloc is true (data member has a ->) we can assume that the pointer
2353  // is never 0.
2354 
2355  Bool_t oldStyle = kFALSE; // flag used to reproduce old-style I/O actions for kSTLp
2356 
2357  if ((GetIOVersion() < 4) && !isPreAlloc) {
2358  TStreamerElement *elem = Stack()->fElem;
2359  if (elem && ((elem->GetType() == TStreamerInfo::kSTLp) ||
2361  oldStyle = kTRUE;
2362  }
2363 
2364  if (streamer) {
2365  (*streamer)(*this, (void *)start, oldStyle ? n : 0);
2366  return 0;
2367  }
2368 
2369  int strInfo = 0;
2370 
2371  Int_t res = 0;
2372 
2373  if (!isPreAlloc) {
2374 
2375  for (Int_t j = 0; j < n; j++) {
2376  // must write StreamerInfo if pointer is null
2377  if (!strInfo && !start[j] && !oldStyle) {
2378  if (cl->Property() & kIsAbstract) {
2379  // Do not try to generate the StreamerInfo for an abstract class
2380  } else {
2381  TStreamerInfo *info = (TStreamerInfo *)((TClass *)cl)->GetStreamerInfo();
2382  ForceWriteInfo(info, kFALSE);
2383  }
2384  }
2385  strInfo = 2003;
2386  if (oldStyle)
2387  ((TClass *)cl)->Streamer(start[j], *this);
2388  else
2389  res |= WriteObjectAny(start[j], cl);
2390  }
2391 
2392  } else {
2393  // case //-> in comment
2394 
2395  for (Int_t j = 0; j < n; j++) {
2396  if (!start[j])
2397  start[j] = ((TClass *)cl)->New();
2398  ((TClass *)cl)->Streamer(start[j], *this);
2399  }
2400  }
2401  return res;
2402 }
2403 
2404 ////////////////////////////////////////////////////////////////////////////////
2405 /// Stream object to/from buffer
2406 
2407 void TBufferXML::StreamObject(void *obj, const TClass *cl, const TClass * /* onfileClass */)
2408 {
2409  if (GetIOVersion() < 4) {
2410  TStreamerElement *elem = Stack()->fElem;
2411  if (elem && (elem->GetType() == TStreamerInfo::kTObject)) {
2412  ((TObject *)obj)->TObject::Streamer(*this);
2413  return;
2414  } else if (elem && (elem->GetType() == TStreamerInfo::kTNamed)) {
2415  ((TNamed *)obj)->TNamed::Streamer(*this);
2416  return;
2417  }
2418  }
2419 
2421  if (gDebug > 1)
2422  Info("StreamObject", "Class: %s", (cl ? cl->GetName() : "none"));
2423  if (IsReading())
2424  XmlReadObject(obj);
2425  else
2426  XmlWriteObject(obj, cl, kTRUE);
2427 }
2428 
2429 ////////////////////////////////////////////////////////////////////////////////
2430 /// Reads Bool_t value from buffer
2431 
2433 {
2435  XmlReadBasic(b);
2436 }
2437 
2438 ////////////////////////////////////////////////////////////////////////////////
2439 /// Reads Char_t value from buffer
2440 
2442 {
2444  XmlReadBasic(c);
2445 }
2446 
2447 ////////////////////////////////////////////////////////////////////////////////
2448 /// Reads UChar_t value from buffer
2449 
2451 {
2453  XmlReadBasic(c);
2454 }
2455 
2456 ////////////////////////////////////////////////////////////////////////////////
2457 /// Reads Short_t value from buffer
2458 
2460 {
2462  XmlReadBasic(h);
2463 }
2464 
2465 ////////////////////////////////////////////////////////////////////////////////
2466 /// Reads UShort_t value from buffer
2467 
2469 {
2471  XmlReadBasic(h);
2472 }
2473 
2474 ////////////////////////////////////////////////////////////////////////////////
2475 /// Reads Int_t value from buffer
2476 
2478 {
2480  XmlReadBasic(i);
2481 }
2482 
2483 ////////////////////////////////////////////////////////////////////////////////
2484 /// Reads UInt_t value from buffer
2485 
2487 {
2489  XmlReadBasic(i);
2490 }
2491 
2492 ////////////////////////////////////////////////////////////////////////////////
2493 /// Reads Long_t value from buffer
2494 
2496 {
2498  XmlReadBasic(l);
2499 }
2500 
2501 ////////////////////////////////////////////////////////////////////////////////
2502 /// Reads ULong_t value from buffer
2503 
2505 {
2507  XmlReadBasic(l);
2508 }
2509 
2510 ////////////////////////////////////////////////////////////////////////////////
2511 /// Reads Long64_t value from buffer
2512 
2514 {
2516  XmlReadBasic(l);
2517 }
2518 
2519 ////////////////////////////////////////////////////////////////////////////////
2520 /// Reads ULong64_t value from buffer
2521 
2523 {
2525  XmlReadBasic(l);
2526 }
2527 
2528 ////////////////////////////////////////////////////////////////////////////////
2529 /// Reads Float_t value from buffer
2530 
2532 {
2534  XmlReadBasic(f);
2535 }
2536 
2537 ////////////////////////////////////////////////////////////////////////////////
2538 /// Reads Double_t value from buffer
2539 
2541 {
2543  XmlReadBasic(d);
2544 }
2545 
2546 ////////////////////////////////////////////////////////////////////////////////
2547 /// Reads array of characters from buffer
2548 
2550 {
2552  const char *buf;
2553  if ((buf = XmlReadValue(xmlio::CharStar)))
2554  strcpy(c, buf);
2555 }
2556 
2557 ////////////////////////////////////////////////////////////////////////////////
2558 /// Reads a TString
2559 
2561 {
2562  if (GetIOVersion() < 3) {
2563  // original TBufferFile method can not be used, while used TString methods are private
2564  // try to reimplement close to the original
2565  Int_t nbig;
2566  UChar_t nwh;
2567  *this >> nwh;
2568  if (nwh == 0) {
2569  s.Resize(0);
2570  } else {
2571  if (nwh == 255)
2572  *this >> nbig;
2573  else
2574  nbig = nwh;
2575 
2576  char *data = new char[nbig];
2577  data[nbig] = 0;
2578  ReadFastArray(data, nbig);
2579  s = data;
2580  delete[] data;
2581  }
2582  } else {
2584  const char *buf = XmlReadValue(xmlio::String);
2585  if (buf)
2586  s = buf;
2587  }
2588 }
2589 
2590 ////////////////////////////////////////////////////////////////////////////////
2591 /// Reads a std::string
2592 
2593 void TBufferXML::ReadStdString(std::string *obj)
2594 {
2595  if (GetIOVersion() < 3) {
2596  if (!obj) {
2597  Error("ReadStdString", "The std::string address is nullptr but should not");
2598  return;
2599  }
2600  Int_t nbig;
2601  UChar_t nwh;
2602  *this >> nwh;
2603  if (nwh == 0) {
2604  obj->clear();
2605  } else {
2606  if (obj->size()) {
2607  // Insure that the underlying data storage is not shared
2608  (*obj)[0] = '\0';
2609  }
2610  if (nwh == 255) {
2611  *this >> nbig;
2612  obj->resize(nbig, '\0');
2613  ReadFastArray((char *)obj->data(), nbig);
2614  } else {
2615  obj->resize(nwh, '\0');
2616  ReadFastArray((char *)obj->data(), nwh);
2617  }
2618  }
2619  } else {
2621  const char *buf = XmlReadValue(xmlio::String);
2622  if (buf && obj)
2623  *obj = buf;
2624  }
2625 }
2626 
2627 ////////////////////////////////////////////////////////////////////////////////
2628 /// Read a char* string
2629 
2631 {
2632  delete[] s;
2633  s = nullptr;
2634 
2635  Int_t nch;
2636  *this >> nch;
2637  if (nch > 0) {
2638  s = new char[nch + 1];
2639  ReadFastArray(s, nch);
2640  s[nch] = 0;
2641  }
2642 }
2643 
2644 ////////////////////////////////////////////////////////////////////////////////
2645 /// Writes Bool_t value to buffer
2646 
2648 {
2650  XmlWriteBasic(b);
2651 }
2652 
2653 ////////////////////////////////////////////////////////////////////////////////
2654 /// Writes Char_t value to buffer
2655 
2657 {
2659  XmlWriteBasic(c);
2660 }
2661 
2662 ////////////////////////////////////////////////////////////////////////////////
2663 /// Writes UChar_t value to buffer
2664 
2666 {
2668  XmlWriteBasic(c);
2669 }
2670 
2671 ////////////////////////////////////////////////////////////////////////////////
2672 /// Writes Short_t value to buffer
2673 
2675 {
2677  XmlWriteBasic(h);
2678 }
2679 
2680 ////////////////////////////////////////////////////////////////////////////////
2681 /// Writes UShort_t value to buffer
2682 
2684 {
2686  XmlWriteBasic(h);
2687 }
2688 
2689 ////////////////////////////////////////////////////////////////////////////////
2690 /// Writes Int_t value to buffer
2691 
2693 {
2695  XmlWriteBasic(i);
2696 }
2697 
2698 ////////////////////////////////////////////////////////////////////////////////
2699 /// Writes UInt_t value to buffer
2700 
2702 {
2704  XmlWriteBasic(i);
2705 }
2706 
2707 ////////////////////////////////////////////////////////////////////////////////
2708 /// Writes Long_t value to buffer
2709 
2711 {
2713  XmlWriteBasic(l);
2714 }
2715 
2716 ////////////////////////////////////////////////////////////////////////////////
2717 /// Writes ULong_t value to buffer
2718 
2720 {
2722  XmlWriteBasic(l);
2723 }
2724 
2725 ////////////////////////////////////////////////////////////////////////////////
2726 /// Writes Long64_t value to buffer
2727 
2729 {
2731  XmlWriteBasic(l);
2732 }
2733 
2734 ////////////////////////////////////////////////////////////////////////////////
2735 /// Writes ULong64_t value to buffer
2736 
2738 {
2740  XmlWriteBasic(l);
2741 }
2742 
2743 ////////////////////////////////////////////////////////////////////////////////
2744 /// Writes Float_t value to buffer
2745 
2747 {
2749  XmlWriteBasic(f);
2750 }
2751 
2752 ////////////////////////////////////////////////////////////////////////////////
2753 /// Writes Double_t value to buffer
2754 
2756 {
2758  XmlWriteBasic(d);
2759 }
2760 
2761 ////////////////////////////////////////////////////////////////////////////////
2762 /// Writes array of characters to buffer
2763 
2765 {
2768 }
2769 
2770 ////////////////////////////////////////////////////////////////////////////////
2771 /// Writes a TString
2772 
2774 {
2775  if (GetIOVersion() < 3) {
2776  // original TBufferFile method, keep for compatibility
2777  Int_t nbig = s.Length();
2778  UChar_t nwh;
2779  if (nbig > 254) {
2780  nwh = 255;
2781  *this << nwh;
2782  *this << nbig;
2783  } else {
2784  nwh = UChar_t(nbig);
2785  *this << nwh;
2786  }
2787  const char *data = s.Data();
2788  WriteFastArray(data, nbig);
2789  } else {
2792  }
2793 }
2794 
2795 ////////////////////////////////////////////////////////////////////////////////
2796 /// Writes a std::string
2797 
2798 void TBufferXML::WriteStdString(const std::string *obj)
2799 {
2800  if (GetIOVersion() < 3) {
2801  if (!obj) {
2802  *this << (UChar_t)0;
2803  WriteFastArray("", 0);
2804  return;
2805  }
2806 
2807  UChar_t nwh;
2808  Int_t nbig = obj->length();
2809  if (nbig > 254) {
2810  nwh = 255;
2811  *this << nwh;
2812  *this << nbig;
2813  } else {
2814  nwh = UChar_t(nbig);
2815  *this << nwh;
2816  }
2817  WriteFastArray(obj->data(), nbig);
2818  } else {
2820  XmlWriteValue(obj ? obj->c_str() : "", xmlio::String);
2821  }
2822 }
2823 
2824 ////////////////////////////////////////////////////////////////////////////////
2825 /// Write a char* string
2826 
2828 {
2829  Int_t nch = 0;
2830  if (s) {
2831  nch = strlen(s);
2832  *this << nch;
2833  WriteFastArray(s, nch);
2834  } else {
2835  *this << nch;
2836  }
2837 }
2838 
2839 ////////////////////////////////////////////////////////////////////////////////
2840 /// Converts Char_t to string and add xml node to buffer
2841 
2843 {
2844  char buf[50];
2845  snprintf(buf, sizeof(buf), "%d", value);
2846  return XmlWriteValue(buf, xmlio::Char);
2847 }
2848 
2849 ////////////////////////////////////////////////////////////////////////////////
2850 /// Converts Short_t to string and add xml node to buffer
2851 
2853 {
2854  char buf[50];
2855  snprintf(buf, sizeof(buf), "%hd", value);
2856  return XmlWriteValue(buf, xmlio::Short);
2857 }
2858 
2859 ////////////////////////////////////////////////////////////////////////////////
2860 /// Converts Int_t to string and add xml node to buffer
2861 
2863 {
2864  char buf[50];
2865  snprintf(buf, sizeof(buf), "%d", value);
2866  return XmlWriteValue(buf, xmlio::Int);
2867 }
2868 
2869 ////////////////////////////////////////////////////////////////////////////////
2870 /// Converts Long_t to string and add xml node to buffer
2871 
2873 {
2874  char buf[50];
2875  snprintf(buf, sizeof(buf), "%ld", value);
2876  return XmlWriteValue(buf, xmlio::Long);
2877 }
2878 
2879 ////////////////////////////////////////////////////////////////////////////////
2880 /// Converts Long64_t to string and add xml node to buffer
2881 
2883 {
2884  std::string buf = std::to_string(value);
2885  return XmlWriteValue(buf.c_str(), xmlio::Long64);
2886 }
2887 
2888 ////////////////////////////////////////////////////////////////////////////////
2889 /// Converts Float_t to string and add xml node to buffer
2890 
2892 {
2893  char buf[200];
2894  ConvertFloat(value, buf, sizeof(buf), kTRUE);
2895  return XmlWriteValue(buf, xmlio::Float);
2896 }
2897 
2898 ////////////////////////////////////////////////////////////////////////////////
2899 /// Converts Double_t to string and add xml node to buffer
2900 
2902 {
2903  char buf[1000];
2904  ConvertDouble(value, buf, sizeof(buf), kTRUE);
2905  return XmlWriteValue(buf, xmlio::Double);
2906 }
2907 
2908 ////////////////////////////////////////////////////////////////////////////////
2909 /// Converts Bool_t to string and add xml node to buffer
2910 
2912 {
2914 }
2915 
2916 ////////////////////////////////////////////////////////////////////////////////
2917 /// Converts UChar_t to string and add xml node to buffer
2918 
2920 {
2921  char buf[50];
2922  snprintf(buf, sizeof(buf), "%u", value);
2923  return XmlWriteValue(buf, xmlio::UChar);
2924 }
2925 
2926 ////////////////////////////////////////////////////////////////////////////////
2927 /// Converts UShort_t to string and add xml node to buffer
2928 
2930 {
2931  char buf[50];
2932  snprintf(buf, sizeof(buf), "%hu", value);
2933  return XmlWriteValue(buf, xmlio::UShort);
2934 }
2935 
2936 ////////////////////////////////////////////////////////////////////////////////
2937 /// Converts UInt_t to string and add xml node to buffer
2938 
2940 {
2941  char buf[50];
2942  snprintf(buf, sizeof(buf), "%u", value);
2943  return XmlWriteValue(buf, xmlio::UInt);
2944 }
2945 
2946 ////////////////////////////////////////////////////////////////////////////////
2947 /// Converts ULong_t to string and add xml node to buffer
2948 
2950 {
2951  char buf[50];
2952  snprintf(buf, sizeof(buf), "%lu", value);
2953  return XmlWriteValue(buf, xmlio::ULong);
2954 }
2955 
2956 ////////////////////////////////////////////////////////////////////////////////
2957 /// Converts ULong64_t to string and add xml node to buffer
2958 
2960 {
2961  std::string buf = std::to_string(value);
2962  return XmlWriteValue(buf.c_str(), xmlio::ULong64);
2963 }
2964 
2965 ////////////////////////////////////////////////////////////////////////////////
2966 /// Create xml node with specified name and adds it to stack node
2967 
2968 XMLNodePointer_t TBufferXML::XmlWriteValue(const char *value, const char *name)
2969 {
2970  XMLNodePointer_t node = nullptr;
2971 
2972  if (fCanUseCompact)
2973  node = StackNode();
2974  else
2975  node = CreateItemNode(name);
2976 
2977  fXML->NewAttr(node, nullptr, xmlio::v, value);
2978 
2980 
2981  return node;
2982 }
2983 
2984 ////////////////////////////////////////////////////////////////////////////////
2985 /// Reads string from current xml node and convert it to Char_t value
2986 
2988 {
2989  const char *res = XmlReadValue(xmlio::Char);
2990  if (res) {
2991  int n;
2992  sscanf(res, "%d", &n);
2993  value = n;
2994  } else
2995  value = 0;
2996 }
2997 
2998 ////////////////////////////////////////////////////////////////////////////////
2999 /// Reads string from current xml node and convert it to Short_t value
3000 
3002 {
3003  const char *res = XmlReadValue(xmlio::Short);
3004  if (res)
3005  sscanf(res, "%hd", &value);
3006  else
3007  value = 0;
3008 }
3009 
3010 ////////////////////////////////////////////////////////////////////////////////
3011 /// Reads string from current xml node and convert it to Int_t value
3012 
3014 {
3015  const char *res = XmlReadValue(xmlio::Int);
3016  if (res)
3017  sscanf(res, "%d", &value);
3018  else
3019  value = 0;
3020 }
3021 
3022 ////////////////////////////////////////////////////////////////////////////////
3023 /// Reads string from current xml node and convert it to Long_t value
3024 
3026 {
3027  const char *res = XmlReadValue(xmlio::Long);
3028  if (res)
3029  sscanf(res, "%ld", &value);
3030  else
3031  value = 0;
3032 }
3033 
3034 ////////////////////////////////////////////////////////////////////////////////
3035 /// Reads string from current xml node and convert it to Long64_t value
3036 
3038 {
3039  const char *res = XmlReadValue(xmlio::Long64);
3040  if (res)
3041  value = (Long64_t)std::stoll(res);
3042  else
3043  value = 0;
3044 }
3045 
3046 ////////////////////////////////////////////////////////////////////////////////
3047 /// Reads string from current xml node and convert it to Float_t value
3048 
3050 {
3051  const char *res = XmlReadValue(xmlio::Float);
3052  if (res)
3053  sscanf(res, "%f", &value);
3054  else
3055  value = 0.;
3056 }
3057 
3058 ////////////////////////////////////////////////////////////////////////////////
3059 /// Reads string from current xml node and convert it to Double_t value
3060 
3062 {
3063  const char *res = XmlReadValue(xmlio::Double);
3064  if (res)
3065  sscanf(res, "%lf", &value);
3066  else
3067  value = 0.;
3068 }
3069 
3070 ////////////////////////////////////////////////////////////////////////////////
3071 /// Reads string from current xml node and convert it to Bool_t value
3072 
3074 {
3075  const char *res = XmlReadValue(xmlio::Bool);
3076  if (res)
3077  value = (strcmp(res, xmlio::True) == 0);
3078  else
3079  value = kFALSE;
3080 }
3081 
3082 ////////////////////////////////////////////////////////////////////////////////
3083 /// Reads string from current xml node and convert it to UChar_t value
3084 
3086 {
3087  const char *res = XmlReadValue(xmlio::UChar);
3088  if (res) {
3089  unsigned int n;
3090  sscanf(res, "%ud", &n);
3091  value = n;
3092  } else
3093  value = 0;
3094 }
3095 
3096 ////////////////////////////////////////////////////////////////////////////////
3097 /// Reads string from current xml node and convert it to UShort_t value
3098 
3100 {
3101  const char *res = XmlReadValue(xmlio::UShort);
3102  if (res)
3103  sscanf(res, "%hud", &value);
3104  else
3105  value = 0;
3106 }
3107 
3108 ////////////////////////////////////////////////////////////////////////////////
3109 /// Reads string from current xml node and convert it to UInt_t value
3110 
3112 {
3113  const char *res = XmlReadValue(xmlio::UInt);
3114  if (res)
3115  sscanf(res, "%u", &value);
3116  else
3117  value = 0;
3118 }
3119 
3120 ////////////////////////////////////////////////////////////////////////////////
3121 /// Reads string from current xml node and convert it to ULong_t value
3122 
3124 {
3125  const char *res = XmlReadValue(xmlio::ULong);
3126  if (res)
3127  sscanf(res, "%lu", &value);
3128  else
3129  value = 0;
3130 }
3131 
3132 ////////////////////////////////////////////////////////////////////////////////
3133 /// Reads string from current xml node and convert it to ULong64_t value
3134 
3136 {
3137  const char *res = XmlReadValue(xmlio::ULong64);
3138  if (res)
3139  value = (ULong64_t)std::stoull(res);
3140  else
3141  value = 0;
3142 }
3143 
3144 ////////////////////////////////////////////////////////////////////////////////
3145 /// read string value from current stack node
3146 
3147 const char *TBufferXML::XmlReadValue(const char *name)
3148 {
3149  if (fErrorFlag > 0)
3150  return 0;
3151 
3152  Bool_t trysimple = fCanUseCompact;
3154 
3155  if (trysimple) {
3156  if (fXML->HasAttr(Stack(1)->fNode, xmlio::v))
3157  fValueBuf = fXML->GetAttr(Stack(1)->fNode, xmlio::v);
3158  else
3159  trysimple = kFALSE;
3160  }
3161 
3162  if (!trysimple) {
3163  if (!VerifyItemNode(name, "XmlReadValue"))
3164  return 0;
3166  }
3167 
3168  if (gDebug > 4)
3169  Info("XmlReadValue", " Name = %s value = %s", name, fValueBuf.Data());
3170 
3171  if (!trysimple)
3172  ShiftStack("readvalue");
3173 
3174  return fValueBuf.Data();
3175 }
3176 
3177 ////////////////////////////////////////////////////////////////////////////////
3178 /// Return current streamer info element
3179 
3181 {
3182  return Stack()->fInfo;
3183 }
Int_t fCompressLevel
! Compression level and algorithm
Definition: TBufferXML.h:333
const char * ULong
Definition: TXMLSetup.cxx:91
Describe Streamer information for one class version.
Definition: TStreamerInfo.h:43
XMLNodePointer_t CreateItemNode(const char *name)
Create item node of specified name.
Definition: TBufferXML.cxx:694
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
const char * Object
Definition: TXMLSetup.cxx:61
virtual ~TBufferXML()
Destroy xml buffer.
Definition: TBufferXML.cxx:98
Bool_t VerifyStackNode(const char *name, const char *errinfo=nullptr)
Check, if stack node has specified name.
Definition: TBufferXML.cxx:659
void XmlReadBlock(XMLNodePointer_t node)
Read binary block of data from xml.
Definition: TBufferXML.cxx:471
Bool_t IsReading() const
Definition: TBuffer.h:83
const char * Long64
Definition: TXMLSetup.cxx:85
static Bool_t CanDelete()
static function returning true if ReadBuffer can delete object
const char * XmlBlock
Definition: TXMLSetup.cxx:59
TXMLStackObj * PushStack(XMLNodePointer_t current, Bool_t simple=kFALSE)
Add new level to xml stack.
Definition: TBufferXML.cxx:314
const char * UInt
Definition: TXMLSetup.cxx:90
virtual Int_t ReadStaticArray(Bool_t *b)
Read array of Bool_t from buffer.
void Add(ULong64_t hash, Long64_t key, Long64_t value)
Add an (key,value) pair to the table. The key should be unique.
Definition: TExMap.cxx:87
Bool_t IsWriting() const
Definition: TBuffer.h:84
static const char * ConvertFloat(Float_t v, char *buf, unsigned len, Bool_t not_optimize=kFALSE)
convert float to string with configured format
Int_t GetCompressionSettings() const
Definition: TBufferXML.h:352
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition: TObject.cxx:854
const char * Ref
Definition: TXMLSetup.cxx:52
virtual void WriteLong64(Long64_t l)
Writes Long64_t value to buffer.
const char * ObjClass
Definition: TXMLSetup.cxx:62
void SetCompressionAlgorithm(Int_t algorithm=0)
See comments for function SetCompressionSettings.
Definition: TBufferXML.cxx:363
long long Long64_t
Definition: RtypesCore.h:69
void WorkWithElement(TStreamerElement *elem, Int_t comp_type)
This function is a part of SetStreamerElementNumber method.
Definition: TBufferXML.cxx:991
Bool_t ProcessPointer(const void *ptr, XMLNodePointer_t node)
Add "ptr" attribute to node, if ptr is null or if ptr is pointer on object, which is already saved in...
Definition: TBufferXML.cxx:542
void XmlWriteBlock(XMLNodePointer_t node)
Write binary data block from buffer to xml.
Definition: TBufferXML.cxx:410
void FreeAttr(XMLNodePointer_t xmlnode, const char *name)
remove attribute from xmlnode
Definition: TXMLEngine.cxx:614
const char * Double
Definition: TXMLSetup.cxx:87
virtual void ReadLong(Long_t &l)
Reads Long_t value from buffer.
#define R__ALWAYS_INLINE
Definition: RConfig.h:556
short Version_t
Definition: RtypesCore.h:61
virtual void WriteFastArray(const Bool_t *b, Int_t n)
Write array of Bool_t to buffer.
virtual Int_t ReadArray(Bool_t *&b)
Read array of Bool_t from buffer.
TString fValueBuf
! Current value buffer
Definition: TBufferXML.h:329
virtual TClass * GetClass() const =0
float Float_t
Definition: RtypesCore.h:53
virtual void WriteLong(Long_t l)
Writes Long_t value to buffer.
R__ALWAYS_INLINE void XmlWriteArray(const T *arr, Int_t arrsize)
Write array, including it size Content may be compressed.
void SetCompressionSettings(Int_t settings=1)
Used to specify the compression level and algorithm.
Definition: TBufferXML.cxx:401
void SetCompressionLevel(Int_t level=1)
See comments for function SetCompressionSettings.
Definition: TBufferXML.cxx:379
const char * Size
Definition: TXMLSetup.cxx:55
TObject * GetParent() const
Return pointer to parent of this buffer.
Definition: TBuffer.cxx:241
EXMLLayout GetXmlLayout() const
Definition: TXMLSetup.h:95
double T(double x)
Definition: ChebyshevPol.h:34
const char * v
Definition: TXMLSetup.cxx:73
TXMLStackObj * Stack(UInt_t depth=0)
Definition: TBufferXML.h:246
unsigned short UShort_t
Definition: RtypesCore.h:36
virtual TClass * GetClassPointer() const
Returns a pointer to the TClass of this element.
virtual void WriteULong64(ULong64_t l)
Writes ULong64_t value to buffer.
const char * ULong64
Definition: TXMLSetup.cxx:92
virtual void ReadFastArray(Bool_t *b, Int_t n)
Read array of Bool_t from buffer.
static void * ConvertFromXMLChecked(const char *xml, const TClass *expectedClass, Bool_t GenericLayout=kFALSE, Bool_t UseNamespaces=kFALSE)
Convert from XML and check if object derived from specified class When possible, cast to given class...
Definition: TBufferXML.cxx:215
Version_t fVersionBuf
! Current version buffer
Definition: TBufferXML.h:328
#define gROOT
Definition: TROOT.h:410
virtual void WriteCharStar(char *s)
Write a char* string.
Basic string class.
Definition: TString.h:131
virtual void WriteChar(Char_t c)
Writes Char_t value to buffer.
#define f(i)
Definition: RSha256.hxx:104
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual void InitMap()
Create the fMap container and initialize them with the null object.
Definition: TBufferIO.cxx:129
XMLNodePointer_t XmlWriteAny(const void *obj, const TClass *cl)
Convert object of any class to xml structures Return pointer on top xml element.
Definition: TBufferXML.cxx:242
const char * Item
Definition: TXMLSetup.cxx:65
virtual void SetArrayDim(Int_t dim)
Set number of array dimensions.
virtual void WriteFastArrayString(const Char_t *c, Int_t n)
Write array of n characters into the I/O buffer.
void CreateElemNode(const TStreamerElement *elem)
Create xml node correspondent to TStreamerElement object.
Definition: TBufferXML.cxx:721
virtual void WriteTString(const TString &s)
Writes a TString.
virtual Version_t ReadVersion(UInt_t *start=nullptr, UInt_t *bcnt=nullptr, const TClass *cl=nullptr)
Read version value from buffer.
Bool_t VerifyNode(XMLNodePointer_t node, const char *name, const char *errinfo=nullptr)
Check if node has specified name.
Definition: TBufferXML.cxx:641
const char * Class
Definition: TXMLSetup.cxx:63
R__ALWAYS_INLINE void XmlReadArrayContent(T *arr, Int_t arrsize)
Template method to read array content.
virtual void SetMaxIndex(Int_t dim, Int_t max)
set maximum index for array with dimension dim
const char * False
Definition: TXMLSetup.cxx:76
void UnlinkFreeNode(XMLNodePointer_t xmlnode)
combined operation. Unlink node and free used memory
XMLNodePointer_t XmlWriteValue(const char *value, const char *name)
Create xml node with specified name and adds it to stack node.
XMLAttrPointer_t NewIntAttr(XMLNodePointer_t xmlnode, const char *name, Int_t value)
create node attribute with integer value
Definition: TXMLEngine.cxx:604
const char * Name
Definition: TXMLSetup.cxx:66
virtual void WriteULong(ULong_t l)
Writes ULong_t value to buffer.
XMLNodePointer_t XmlWriteObject(const void *obj, const TClass *objClass, Bool_t cacheReuse)
Write object to buffer If object was written before, only pointer will be stored Return pointer to to...
Definition: TBufferXML.cxx:775
const char * GetNodeContent(XMLNodePointer_t xmlnode)
get contents (if any) of xmlnode
Int_t Length() const
Definition: TBuffer.h:96
virtual void WriteStdString(const std::string *s)
Writes a std::string.
Bool_t VerifyItemNode(const char *name, const char *errinfo=nullptr)
Checks, if stack node is item and has specified name.
Definition: TBufferXML.cxx:708
TXMLEngine * fXML
! instance of TXMLEngine for working with XML structures
Definition: TBufferXML.h:326
const char * Float
Definition: TXMLSetup.cxx:86
const char * String
Definition: TXMLSetup.cxx:93
virtual void ReadCharP(Char_t *c)
Reads array of characters from buffer.
TXMLFile * XmlFile()
Returns pointer to TXMLFile object.
Definition: TBufferXML.cxx:108
Int_t GetBaseClassOffset(const TClass *toBase, void *address=0, bool isDerivedObject=true)
Definition: TClass.cxx:2710
virtual void WriteInt(Int_t i)
Writes Int_t value to buffer.
Bool_t VerifyAttr(XMLNodePointer_t node, const char *name, const char *value, const char *errinfo=nullptr)
Checks, that attribute of specified name exists and has specified value.
Definition: TBufferXML.cxx:667
virtual void WriteShort(Short_t s)
Writes Short_t value to buffer.
virtual void DecrementLevel(TVirtualStreamerInfo *)
Function is called from TStreamerInfo WriteBuffer and ReadBuffer functions and decrease level in xml ...
Definition: TBufferXML.cxx:948
virtual void WriteUChar(UChar_t c)
Writes UChar_t value to buffer.
void Class()
Definition: Class.C:29
virtual void ReadCharStar(char *&s)
Read a char* string.
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
void BeforeIOoperation()
Function is called before any IO operation of TBuffer Now is used to store version value if no proper...
virtual void ReadShort(Short_t &s)
Reads Short_t value from buffer.
char * Buffer() const
Definition: TBuffer.h:93
Int_t AtoI(const char *sbuf, Int_t def=0, const char *errinfo=0)
converts string to integer.
Definition: TXMLSetup.cxx:287
virtual void WriteUShort(UShort_t s)
Writes UShort_t value to buffer.
virtual void ClassMember(const char *name, const char *typeName=nullptr, Int_t arrsize1=-1, Int_t arrsize2=-1)
Method indicates name and typename of class member, which should be now streamed in custom streamer...
virtual void WriteUInt(UInt_t i)
Writes UInt_t value to buffer.
XMLNsPointer_t NewNS(XMLNodePointer_t xmlnode, const char *reference, const char *name=0)
create namespace attribute for xmlnode.
Definition: TXMLEngine.cxx:733
int R__unzip_header(Int_t *nin, UChar_t *bufin, Int_t *lout)
void SetIOVersion(Int_t v)
Definition: TBufferXML.h:68
virtual void ReadStdString(std::string *s)
Reads a std::string.
virtual void StreamObject(void *obj, const TClass *cl, const TClass *onFileClass=nullptr)
Stream object to/from buffer.
R__ALWAYS_INLINE void XmlWriteArrayContent(const T *arr, Int_t arrsize)
virtual void WriteCharP(const Char_t *c)
Writes array of characters to buffer.
const char * UChar
Definition: TXMLSetup.cxx:88
const char * Char
Definition: TXMLSetup.cxx:81
TObject()
TObject constructor.
Definition: TObject.h:226
virtual void ReadULong64(ULong64_t &l)
Reads ULong64_t value from buffer.
virtual TClass * ReadClass(const TClass *cl=nullptr, UInt_t *objTag=nullptr)
Function to read class from buffer, used in old-style streamers.
virtual void ReadBool(Bool_t &b)
Reads Bool_t value from buffer.
const char * GetNodeName(XMLNodePointer_t xmlnode)
returns name of xmlnode
XMLNodePointer_t StackNode()
Return pointer on current xml node.
Definition: TBufferXML.cxx:341
void Expand(Int_t newsize, Bool_t copy=kTRUE)
Expand (or shrink) the I/O buffer to newsize bytes.
Definition: TBuffer.cxx:211
ECompressionAlgorithm
The global settings depend on a global variable named R__ZipMode which can be modified by a global fu...
Definition: Compression.h:43
virtual void ReadUChar(UChar_t &c)
Reads UChar_t value from buffer.
Int_t GetType() const
Definition: TDataType.h:68
Bool_t VerifyStackAttr(const char *name, const char *value, const char *errinfo=nullptr)
Checks stack attribute.
Definition: TBufferXML.cxx:686
Int_t fIOVersion
! Indicates format of ROOT xml file
Definition: TBufferXML.h:334
virtual void ReadUInt(UInt_t &i)
Reads UInt_t value from buffer.
const char * XmlGetElementName(const TStreamerElement *el)
return converted name for TStreamerElement
Definition: TXMLSetup.cxx:241
TClass * fExpectedBaseClass
! Pointer to class, which should be stored as parent of current
Definition: TBufferXML.h:332
virtual void * ReadObjectAny(const TClass *clCast)
Read object from buffer. Only used from TBuffer.
void ShiftToNext(XMLNodePointer_t &xmlnode, Bool_t realnode=kTRUE)
shifts specified node to next if realnode==kTRUE, any special nodes in between will be skipped ...
TClass * GetClass() const
void SetXML(TXMLEngine *xml)
Definition: TBufferXML.h:233
virtual void IncrementLevel(TVirtualStreamerInfo *)
Function is called from TStreamerInfo WriteBuffer and ReadBuffer functions and indent new level in xm...
Definition: TBufferXML.cxx:874
virtual void MapObject(const TObject *obj, UInt_t offset=1)
Add object to the fMap container.
Definition: TBufferIO.cxx:163
Basic data type descriptor (datatype information is obtained from CINT).
Definition: TDataType.h:44
virtual Int_t WriteObjectAny(const void *obj, const TClass *ptrClass, Bool_t cacheReuse=kTRUE)
Write object to I/O buffer.
Definition: TBufferIO.cxx:492
void * XmlReadObject(void *obj, TClass **cl=nullptr)
Read object from the buffer.
Definition: TBufferXML.cxx:807
void WorkWithClass(TStreamerInfo *info, const TClass *cl=nullptr)
Prepares buffer to stream data of specified class.
Definition: TBufferXML.cxx:882
TBufferXML()
Default constructor.
Definition: TBufferXML.cxx:58
void Destructor(void *obj, Bool_t dtorOnly=kFALSE)
Explicitly call destructor for object.
Definition: TClass.cxx:5149
virtual TVirtualStreamerInfo * GetInfo()
Return current streamer info element.
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:880
Ssiz_t Length() const
Definition: TString.h:405
Int_t Size() const
Return size of object of this class.
Definition: TClass.cxx:5434
virtual void ClassEnd(const TClass *)
Should be called at the end of custom streamer See TBufferXML::ClassBegin for more details...
const char * Array
Definition: TXMLSetup.cxx:79
short Short_t
Definition: RtypesCore.h:35
virtual void GetMappedObject(UInt_t tag, void *&ptr, TClass *&ClassPtr) const
Retrieve the object stored in the buffer&#39;s object map at &#39;tag&#39; Set ptr and ClassPtr respectively to t...
Definition: TBufferIO.cxx:260
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:75
static TString ConvertToXML(const TObject *obj, Bool_t GenericLayout=kFALSE, Bool_t UseNamespaces=kFALSE)
Converts object, inherited from TObject class, to XML string GenericLayout defines layout choice for ...
Definition: TBufferXML.cxx:119
Int_t GetNextRefCounter()
Definition: TXMLSetup.h:109
Bool_t fCanUseCompact
! Flag indicate that basic type (like Int_t) can be placed in the same tag
Definition: TBufferXML.h:331
void * XMLNodePointer_t
Definition: TXMLEngine.h:17
Bool_t VerifyElemNode(const TStreamerElement *elem)
Checks if stack node correspond to TStreamerElement object.
Definition: TBufferXML.cxx:749
Long_t Property() const
Set TObject::fBits and fStreamerType to cache information about the class.
Definition: TClass.cxx:5768
void ExtractReference(XMLNodePointer_t node, const void *ptr, const TClass *cl)
Analyze if node has "ref" attribute and register it to object map.
Definition: TBufferXML.cxx:615
void PerformPreProcessing(const TStreamerElement *elem, XMLNodePointer_t elemnode)
Function is unpack TObject and TString structures to be able read them from custom streamers of this ...
void Streamer(void *obj, TBuffer &b, const TClass *onfile_class=0) const
Definition: TClass.h:561
Bool_t IsUseNamespaces() const
Definition: TXMLSetup.h:98
void SkipEmpty(XMLNodePointer_t &xmlnode)
Skip all current empty nodes and locate on first "true" node.
#define h(i)
Definition: RSha256.hxx:106
static const char * ConvertDouble(Double_t v, char *buf, unsigned len, Bool_t not_optimize=kFALSE)
convert float to string with configured format
const char * XmlConvertClassName(const char *name)
convert class name to exclude any special symbols like &#39;:&#39;, &#39;<&#39; &#39;>&#39; &#39;,&#39; and spaces ...
Definition: TXMLSetup.cxx:214
virtual void WriteFloat(Float_t f)
Writes Float_t value to buffer.
void CheckVersionBuf()
Checks buffer, filled by WriteVersion if next data is arriving, version should be stored in buffer...
const char * Ptr
Definition: TXMLSetup.cxx:51
const Bool_t kFALSE
Definition: RtypesCore.h:88
Bool_t HasAttr(XMLNodePointer_t xmlnode, const char *name)
checks if node has attribute of specified name
Definition: TXMLEngine.cxx:531
long Long_t
Definition: RtypesCore.h:50
#define d(i)
Definition: RSha256.hxx:102
static TObject * ConvertFromXML(const char *str, Bool_t GenericLayout=kFALSE, Bool_t UseNamespaces=kFALSE)
Read object from XML, produced by ConvertToXML() method.
Definition: TBufferXML.cxx:168
virtual UInt_t WriteVersion(const TClass *cl, Bool_t useBcnt=kFALSE)
Copies class version to buffer, but not writes it to xml Version will be written with next I/O operat...
Version_t GetClassVersion() const
Definition: TClass.h:391
XMLAttrPointer_t NewAttr(XMLNodePointer_t xmlnode, XMLNsPointer_t, const char *name, const char *value)
creates new attribute for xmlnode, namespaces are not supported for attributes
Definition: TXMLEngine.cxx:578
Base class for text-based streamers like TBufferJSON or TBufferXML Special actions list will use meth...
Definition: TBufferText.h:21
virtual void ReadDouble(Double_t &d)
Reads Double_t value from buffer.
#define ClassImp(name)
Definition: Rtypes.h:359
double Double_t
Definition: RtypesCore.h:55
virtual void WriteArray(const Bool_t *b, Int_t n)
Write array of Bool_t to buffer.
Bool_t ExtractPointer(XMLNodePointer_t node, void *&ptr, TClass *&cl)
Searches for "ptr" attribute and returns pointer to object and class, if "ptr" attribute reference to...
Definition: TBufferXML.cxx:579
const char * GetAttr(XMLNodePointer_t xmlnode, const char *name)
returns value of attribute for xmlnode
Definition: TXMLEngine.cxx:547
void SaveSingleNode(XMLNodePointer_t xmlnode, TString *res, Int_t layout=1)
convert single xmlnode (and its child node) to string if layout<=0, no any spaces or newlines will be...
virtual void ReadInt(Int_t &i)
Reads Int_t value from buffer.
virtual void ReadUShort(UShort_t &s)
Reads UShort_t value from buffer.
unsigned long long ULong64_t
Definition: RtypesCore.h:70
Int_t IndexOf(const TObject *obj) const
Definition: TObjArray.cxx:589
unsigned long ULong_t
Definition: RtypesCore.h:51
virtual void ReadULong(ULong_t &l)
Reads ULong_t value from buffer.
TExMap * fMap
Map containing object,offset pairs for reading/writing.
Definition: TBufferIO.h:39
static constexpr double s
Int_t GetCompressionLevel() const
Definition: TBufferXML.h:346
const char * XmlClassNameSpaceRef(const TClass *cl)
produce string which used as reference in class namespace definition
Definition: TXMLSetup.cxx:228
virtual void ReadTString(TString &s)
Reads a TString.
Int_t BufferSize() const
Definition: TBuffer.h:94
virtual void WriteDouble(Double_t d)
Writes Double_t value to buffer.
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:2887
void FreeNode(XMLNodePointer_t xmlnode)
release all memory, allocated from this node and destroys node itself
void R__unzip(Int_t *nin, UChar_t *bufin, Int_t *lout, char *bufout, Int_t *nout)
virtual void WriteBool(Bool_t b)
Writes Bool_t value to buffer.
Mother of all ROOT objects.
Definition: TObject.h:37
TObjArray * GetElements() const
void * XMLNsPointer_t
Definition: TXMLEngine.h:18
XMLNodePointer_t XmlWriteBasic(Char_t value)
Converts Char_t to string and add xml node to buffer.
char Char_t
Definition: RtypesCore.h:29
const char * Null
Definition: TXMLSetup.cxx:53
R__ALWAYS_INLINE void XmlReadFastArray(T *arr, Int_t n)
Template method to read content of array, which not include size of array Also treated situation...
Bool_t IsTObject() const
Return kTRUE is the class inherits from TObject.
Definition: TClass.cxx:5668
const char * CharStar
Definition: TXMLSetup.cxx:94
Class for serializing/deserializing object to/from xml.
Definition: TBufferXML.h:35
virtual void ReadLong64(Long64_t &l)
Reads Long64_t value from buffer.
const char * Member
Definition: TXMLSetup.cxx:64
auto * l
Definition: textangle.C:4
XMLNodePointer_t GetChild(XMLNodePointer_t xmlnode, Bool_t realnode=kTRUE)
returns first child of xmlnode
virtual void SetUseNamespaces(Bool_t iUseNamespaces=kTRUE)
Definition: TXMLSetup.h:103
Definition: file.py:1
Int_t fErrorFlag
! Error flag
Definition: TBufferXML.h:330
const char * Int
Definition: TXMLSetup.cxx:83
Int_t GetIOVersion() const
Definition: TBufferXML.h:67
Int_t GetCompressionAlgorithm() const
Definition: TBufferXML.h:340
XMLNodePointer_t NewChild(XMLNodePointer_t parent, XMLNsPointer_t ns, const char *name, const char *content=0)
create new child element for parent node
Definition: TXMLEngine.cxx:707
static R__ALWAYS_INLINE ULong_t Void_Hash(const void *ptr)
Return hash value for provided object.
Definition: TBufferIO.h:53
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
#define snprintf
Definition: civetweb.c:1351
virtual void SkipObjectAny()
Skip any kind of object from buffer Actually skip only one node on current level of xml structure...
Int_t GetIntAttr(XMLNodePointer_t node, const char *name)
returns value of attribute as integer
Definition: TXMLEngine.cxx:563
virtual void WriteClass(const TClass *cl)
Function to write class into buffer, used in old-style streamers.
R__EXTERN Int_t gDebug
Definition: Rtypes.h:86
#define c(i)
Definition: RSha256.hxx:101
Int_t Atoi() const
Return integer value of string.
Definition: TString.cxx:1896
virtual void SetStreamerElementNumber(TStreamerElement *elem, Int_t comp_type)
Function is called from TStreamerInfo WriteBuffer and ReadBuffer functions and add/verify next elemen...
Definition: TBufferXML.cxx:980
void SetBaseVersion(Int_t v)
TClass * XmlDefineClass(const char *xmlClassName)
define class for the converted class name, where special symbols were replaced by &#39;_&#39; ...
Definition: TXMLSetup.cxx:268
Undefined compression algorithm (must be kept the last of the list in case a new algorithm is added)...
Definition: Compression.h:55
const char * Short
Definition: TXMLSetup.cxx:82
const char * OnlyVersion
Definition: TXMLSetup.cxx:50
unsigned char UChar_t
Definition: RtypesCore.h:34
void PerformPostProcessing()
Function is converts TObject and TString structures to more compact representation.
virtual void ReadChar(Char_t &c)
Reads Char_t value from buffer.
virtual void ClassBegin(const TClass *, Version_t=-1)
Should be called at the beginning of custom class streamer.
XMLNodePointer_t ReadSingleNode(const char *src)
read single xmlnode from provided string
virtual void ForceWriteInfo(TVirtualStreamerInfo *info, Bool_t force)
force writing the TStreamerInfo to the file
Definition: TBufferIO.cxx:329
Abstract Interface class describing Streamer information for one class.
const char * ClassVersion
Definition: TXMLSetup.cxx:48
const char * True
Definition: TXMLSetup.cxx:75
virtual void ReadFastArrayString(Char_t *c, Int_t n)
Read array of n characters from the I/O buffer.
const Bool_t kTRUE
Definition: RtypesCore.h:87
const char * UShort
Definition: TXMLSetup.cxx:89
virtual void SetXmlLayout(EXMLLayout layout)
Definition: TXMLSetup.h:100
void ShiftStack(const char *info=nullptr)
Shift stack node to next.
Definition: TBufferXML.cxx:350
Int_t GetType() const
const char * IdBase
Definition: TXMLSetup.cxx:54
static constexpr double ns
const Int_t n
Definition: legend1.C:16
virtual void ReadFloat(Float_t &f)
Reads Float_t value from buffer.
Long64_t GetObjectTag(const void *obj)
Returns tag for specified object from objects map (if exists) Returns 0 if object not included into o...
Definition: TBufferIO.cxx:277
TXMLStackObj * PopStack()
Remove one level from xml stack.
Definition: TBufferXML.cxx:329
void XmlReadBasic(Char_t &value)
Reads string from current xml node and convert it to Char_t value.
const char * Zip
Definition: TXMLSetup.cxx:60
virtual void SetOnFileClass(const TClass *cl)
std::deque< TXMLStackObj * > fStack
! Stack of processed objects
Definition: TBufferXML.h:327
static void * ConvertFromXMLAny(const char *str, TClass **cl=nullptr, Bool_t GenericLayout=kFALSE, Bool_t UseNamespaces=kFALSE)
Read object of any class from XML, produced by ConvertToXML() method.
Definition: TBufferXML.cxx:191
R__ALWAYS_INLINE Int_t XmlReadArray(T *&arr, bool is_static=false)
Template method to read array with size attribute If necessary, array is created. ...
char name[80]
Definition: TGX11.cxx:109
const char * cnt
Definition: TXMLSetup.cxx:74
R__ALWAYS_INLINE void XmlWriteFastArray(const T *arr, Int_t n)
Write array without size attribute Also treat situation, when instead of one single array chain of se...
const char * Long
Definition: TXMLSetup.cxx:84
void Resize(Ssiz_t n)
Resize the string. Truncate or add blanks as necessary.
Definition: TString.cxx:1070
virtual void WriteObjectClass(const void *actualObjStart, const TClass *actualClass, Bool_t cacheReuse)
Write object to buffer. Only used from TBuffer.
const char * XmlReadValue(const char *name)
read string value from current stack node
const char * Bool
Definition: TXMLSetup.cxx:80
void * XmlReadAny(XMLNodePointer_t node, void *obj, TClass **cl)
Recreate object from xml structure.
Definition: TBufferXML.cxx:259
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Return a pointer to a newly allocated object of this class.
Definition: TClass.cxx:4792
const char * Data() const
Definition: TString.h:364