Logo ROOT   6.12/07
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 It redefines most of TBuffer class function to convert simple types,
19 array of simple types and objects to/from xml.
20 Instead of writing a binary data it creates a set of xml structures as
21 nodes and attributes
22 TBufferXML class uses streaming mechanism, provided by ROOT system,
23 therefore most of ROOT and user classes can be stored to xml. There are
24 limitations for complex objects like TTree, which can not be yet converted to xml.
25 */
26 
27 #include "TBufferXML.h"
28 #include "Compression.h"
29 #include "TXMLFile.h"
30 
31 #include "TObjArray.h"
32 #include "TROOT.h"
33 #include "TClass.h"
34 #include "TClassTable.h"
35 #include "TDataType.h"
36 #include "TExMap.h"
37 #include "TMethodCall.h"
38 #include "TStreamerInfo.h"
39 #include "TStreamerElement.h"
40 #include "TProcessID.h"
41 #include "TFile.h"
42 #include "TMemberStreamer.h"
43 #include "TStreamer.h"
44 #include "TStreamerInfoActions.h"
45 #include "RZip.h"
46 
47 #ifdef R__VISUAL_CPLUSPLUS
48 #define FLong64 "%I64d"
49 #define FULong64 "%I64u"
50 #else
51 #define FLong64 "%lld"
52 #define FULong64 "%llu"
53 #endif
54 
56 
57 std::string TBufferXML::fgFloatFmt = "%e";
58 
59 ////////////////////////////////////////////////////////////////////////////////
60 /// Default constructor
61 
63  : TBufferFile(), TXMLSetup(), fXML(0), fStack(), fVersionBuf(-111), fObjMap(0), fIdArray(0), fErrorFlag(0),
64  fCanUseCompact(kFALSE), fExpectedChain(kFALSE), fExpectedBaseClass(0), fCompressLevel(0), fIOVersion(3)
65 {
66 }
67 
68 ////////////////////////////////////////////////////////////////////////////////
69 /// Creates buffer object to serialize/deserialize data to/from xml.
70 /// Mode should be either TBuffer::kRead or TBuffer::kWrite.
71 
73  : TBufferFile(mode), TXMLSetup(), fXML(0), fStack(), fVersionBuf(-111), fObjMap(0), fIdArray(0), fErrorFlag(0),
75 {
76  fBufSize = 1000000000;
77 
78  SetParent(0);
81 }
82 
83 ////////////////////////////////////////////////////////////////////////////////
84 /// Creates buffer object to serialize/deserialize data to/from xml.
85 /// This constructor should be used, if data from buffer supposed to be stored in file.
86 /// Mode should be either TBuffer::kRead or TBuffer::kWrite.
87 
89  : TBufferFile(mode), TXMLSetup(*file), fXML(0), fStack(), fVersionBuf(-111), fObjMap(0), fIdArray(0), fErrorFlag(0),
91 {
92  // this is for the case when StreamerInfo reads elements from
93  // buffer as ReadFastArray. When it checks if size of buffer is
94  // too small and skip reading. Actually, more improved method should
95  // be used here.
96  fBufSize = 1000000000;
97 
98  SetParent(file);
101  if (XmlFile()) {
102  SetXML(XmlFile()->XML());
105  }
106 }
107 
108 ////////////////////////////////////////////////////////////////////////////////
109 /// Destroy xml buffer.
110 
112 {
113  if (fObjMap)
114  delete fObjMap;
115  if (fIdArray)
116  delete fIdArray;
117  fStack.Delete();
118 }
119 
120 ////////////////////////////////////////////////////////////////////////////////
121 /// Returns pointer to TXMLFile object.
122 /// Access to file is necessary to produce unique identifier for object references.
123 
125 {
126  return dynamic_cast<TXMLFile *>(GetParent());
127 }
128 
129 ////////////////////////////////////////////////////////////////////////////////
130 /// Converts object, inherited from TObject class, to XML string
131 /// GenericLayout defines layout choice for XML file
132 /// UseNamespaces allow XML namespaces.
133 /// See TXMLSetup class for details
134 
135 TString TBufferXML::ConvertToXML(const TObject *obj, Bool_t GenericLayout, Bool_t UseNamespaces)
136 {
137  TClass *clActual = 0;
138  void *ptr = (void *)obj;
139 
140  if (obj != 0) {
141  clActual = TObject::Class()->GetActualClass(obj);
142  if (!clActual)
143  clActual = TObject::Class();
144  else if (clActual != TObject::Class())
145  ptr = (void *)((Long_t)obj - clActual->GetBaseClassOffset(TObject::Class()));
146  }
147 
148  return ConvertToXML(ptr, clActual, GenericLayout, UseNamespaces);
149 }
150 
151 ////////////////////////////////////////////////////////////////////////////////
152 /// Converts any type of object to XML string.
153 /// GenericLayout defines layout choice for XML file
154 /// UseNamespaces allow XML namespaces.
155 /// See TXMLSetup class for details
156 
157 TString TBufferXML::ConvertToXML(const void *obj, const TClass *cl, Bool_t GenericLayout, Bool_t UseNamespaces)
158 {
159  TXMLEngine xml;
160 
162  buf.SetXML(&xml);
163 
165  buf.SetUseNamespaces(UseNamespaces);
166 
167  XMLNodePointer_t xmlnode = buf.XmlWriteAny(obj, cl);
168 
169  TString res;
170 
171  xml.SaveSingleNode(xmlnode, &res);
172 
173  xml.FreeNode(xmlnode);
174 
175  return res;
176 }
177 
178 ////////////////////////////////////////////////////////////////////////////////
179 /// Read object from XML, produced by ConvertToXML() method.
180 /// If object does not inherit from TObject class, return 0.
181 /// GenericLayout and UseNamespaces should be the same as in ConvertToXML()
182 
183 TObject *TBufferXML::ConvertFromXML(const char *str, Bool_t GenericLayout, Bool_t UseNamespaces)
184 {
185  TClass *cl = 0;
186  void *obj = ConvertFromXMLAny(str, &cl, GenericLayout, UseNamespaces);
187 
188  if ((cl == 0) || (obj == 0))
189  return 0;
190 
191  Int_t delta = cl->GetBaseClassOffset(TObject::Class());
192 
193  if (delta < 0) {
194  cl->Destructor(obj);
195  return 0;
196  }
197 
198  return (TObject *)(((char *)obj) + delta);
199 }
200 
201 ////////////////////////////////////////////////////////////////////////////////
202 /// Read object of any class from XML, produced by ConvertToXML() method.
203 /// If cl!=0, return actual class of object.
204 /// GenericLayout and UseNamespaces should be the same as in ConvertToXML()
205 
206 void *TBufferXML::ConvertFromXMLAny(const char *str, TClass **cl, Bool_t GenericLayout, Bool_t UseNamespaces)
207 {
208  TXMLEngine xml;
210 
211  buf.SetXML(&xml);
212 
214  buf.SetUseNamespaces(UseNamespaces);
215 
216  XMLNodePointer_t xmlnode = xml.ReadSingleNode(str);
217 
218  void *obj = buf.XmlReadAny(xmlnode, 0, cl);
219 
220  xml.FreeNode(xmlnode);
221 
222  return obj;
223 }
224 
225 ////////////////////////////////////////////////////////////////////////////////
226 /// Convert object of any class to xml structures
227 /// Return pointer on top xml element
228 
230 {
231  fErrorFlag = 0;
232 
233  if (fXML == 0)
234  return 0;
235 
236  XMLNodePointer_t res = XmlWriteObject(obj, cl, kTRUE);
237 
238  return res;
239 }
240 
241 ////////////////////////////////////////////////////////////////////////////////
242 /// Recreate object from xml structure.
243 /// Return pointer to read object.
244 /// if (cl!=0) returns pointer to class of object
245 
246 void *TBufferXML::XmlReadAny(XMLNodePointer_t node, void *obj, TClass **cl)
247 {
248  if (node == 0)
249  return 0;
250  if (cl)
251  *cl = 0;
252 
253  fErrorFlag = 0;
254 
255  if (fXML == 0)
256  return 0;
257 
258  PushStack(node, kTRUE);
259 
260  void *res = XmlReadObject(obj, cl);
261 
262  PopStack();
263 
264  return res;
265 }
266 
267 // TXMLStackObj is used to keep stack of object hierarchy,
268 // stored in TBuffer. For example, data for parent class(es)
269 // stored in subnodes, but initial object node will be kept.
270 
271 class TXMLStackObj : public TObject {
272 public:
273  TXMLStackObj(XMLNodePointer_t node)
274  : TObject(), fNode(node), fInfo(0), fElem(0), fElemNumber(0), fCompressedClassNode(kFALSE), fClassNs(0),
275  fIsStreamerInfo(kFALSE), fIsElemOwner(kFALSE)
276  {
277  }
278 
279  virtual ~TXMLStackObj()
280  {
281  if (fIsElemOwner)
282  delete fElem;
283  }
284 
285  Bool_t IsStreamerInfo() const { return fIsStreamerInfo; }
286 
287  XMLNodePointer_t fNode;
289  TStreamerElement *fElem;
290  Int_t fElemNumber;
291  Bool_t fCompressedClassNode;
292  XMLNsPointer_t fClassNs;
293  Bool_t fIsStreamerInfo;
294  Bool_t fIsElemOwner;
295 };
296 
297 ////////////////////////////////////////////////////////////////////////////////
298 /// Add new level to xml stack.
299 
300 TXMLStackObj *TBufferXML::PushStack(XMLNodePointer_t current, Bool_t simple)
301 {
302  if (IsReading() && !simple) {
303  current = fXML->GetChild(current);
304  fXML->SkipEmpty(current);
305  }
306 
307  TXMLStackObj *stack = new TXMLStackObj(current);
308  fStack.Add(stack);
309  return stack;
310 }
311 
312 ////////////////////////////////////////////////////////////////////////////////
313 /// Remove one level from xml stack.
314 
315 TXMLStackObj *TBufferXML::PopStack()
316 {
317  TObject *last = fStack.Last();
318  if (last != 0) {
319  fStack.Remove(last);
320  delete last;
321  fStack.Compress();
322  }
323  return dynamic_cast<TXMLStackObj *>(fStack.Last());
324 }
325 
326 ////////////////////////////////////////////////////////////////////////////////
327 /// Return xml stack object of specified depth.
328 
329 TXMLStackObj *TBufferXML::Stack(Int_t depth)
330 {
331  TXMLStackObj *stack = 0;
332  if (depth <= fStack.GetLast())
333  stack = dynamic_cast<TXMLStackObj *>(fStack.At(fStack.GetLast() - depth));
334  return stack;
335 }
336 
337 ////////////////////////////////////////////////////////////////////////////////
338 /// Return pointer on current xml node.
339 
341 {
342  TXMLStackObj *stack = dynamic_cast<TXMLStackObj *>(fStack.Last());
343  return (stack == 0) ? 0 : stack->fNode;
344 }
345 
346 ////////////////////////////////////////////////////////////////////////////////
347 /// Shift stack node to next.
348 
349 void TBufferXML::ShiftStack(const char *errinfo)
350 {
351  TXMLStackObj *stack = dynamic_cast<TXMLStackObj *>(fStack.Last());
352  if (stack) {
353  fXML->ShiftToNext(stack->fNode);
354  if (gDebug > 4)
355  Info("ShiftStack", "%s to node %s", errinfo, fXML->GetNodeName(stack->fNode));
356  }
357 }
358 
359 ////////////////////////////////////////////////////////////////////////////////
360 /// See comments for function SetCompressionSettings.
361 
363 {
364  if (algorithm < 0 || algorithm >= ROOT::kUndefinedCompressionAlgorithm)
365  algorithm = 0;
366  if (fCompressLevel < 0) {
367  // if the level is not defined yet use 1 as a default
368  fCompressLevel = 100 * algorithm + 1;
369  } else {
370  int level = fCompressLevel % 100;
371  fCompressLevel = 100 * algorithm + level;
372  }
373 }
374 
375 ////////////////////////////////////////////////////////////////////////////////
376 /// See comments for function SetCompressionSettings.
377 
379 {
380  if (level < 0)
381  level = 0;
382  if (level > 99)
383  level = 99;
384  if (fCompressLevel < 0) {
385  // if the algorithm is not defined yet use 0 as a default
386  fCompressLevel = level;
387  } else {
388  int algorithm = fCompressLevel / 100;
389  if (algorithm >= ROOT::kUndefinedCompressionAlgorithm)
390  algorithm = 0;
391  fCompressLevel = 100 * algorithm + level;
392  }
393 }
394 
395 ////////////////////////////////////////////////////////////////////////////////
396 /// Used to specify the compression level and algorithm.
397 ///
398 /// See TFile constructor for the details.
399 
401 {
402  fCompressLevel = settings;
403 }
404 
405 ////////////////////////////////////////////////////////////////////////////////
406 /// Write binary data block from buffer to xml.
407 /// This data can be produced only by direct call of TBuffer::WriteBuf() functions.
408 
410 {
411  if ((node == 0) || (Length() == 0))
412  return;
413 
414  const char *src = Buffer();
415  int srcSize = Length();
416 
417  char *fZipBuffer = 0;
418 
419  Int_t compressionLevel = GetCompressionLevel();
420  ROOT::ECompressionAlgorithm compressionAlgorithm =
422 
423  if ((Length() > 512) && (compressionLevel > 0)) {
424  int zipBufferSize = Length();
425  fZipBuffer = new char[zipBufferSize + 9];
426  int dataSize = Length();
427  int compressedSize = 0;
428  R__zipMultipleAlgorithm(compressionLevel, &dataSize, Buffer(), &zipBufferSize, fZipBuffer, &compressedSize,
429  compressionAlgorithm);
430  if (compressedSize > 0) {
431  src = fZipBuffer;
432  srcSize = compressedSize;
433  } else {
434  delete[] fZipBuffer;
435  fZipBuffer = 0;
436  }
437  }
438 
439  TString res;
440  char sbuf[500];
441  int block = 0;
442  char *tgt = sbuf;
443  int srcCnt = 0;
444 
445  while (srcCnt++ < srcSize) {
446  tgt += sprintf(tgt, " %02x", (unsigned char)*src);
447  src++;
448  if (block++ == 100) {
449  res += sbuf;
450  block = 0;
451  tgt = sbuf;
452  }
453  }
454 
455  if (block > 0)
456  res += sbuf;
457 
458  XMLNodePointer_t blocknode = fXML->NewChild(node, 0, xmlio::XmlBlock, res);
459  fXML->NewIntAttr(blocknode, xmlio::Size, Length());
460 
461  if (fZipBuffer) {
462  fXML->NewIntAttr(blocknode, xmlio::Zip, srcSize);
463  delete[] fZipBuffer;
464  }
465 }
466 
467 ////////////////////////////////////////////////////////////////////////////////
468 /// Read binary block of data from xml.
469 
471 {
472  if (blocknode == 0)
473  return;
474 
475  Int_t blockSize = fXML->GetIntAttr(blocknode, xmlio::Size);
476  Bool_t blockCompressed = fXML->HasAttr(blocknode, xmlio::Zip);
477  char *fUnzipBuffer = 0;
478 
479  if (gDebug > 2)
480  Info("XmlReadBlock", "Block size = %d, Length = %d, Compressed = %d", blockSize, Length(), blockCompressed);
481 
482  if (blockSize > BufferSize())
483  Expand(blockSize);
484 
485  char *tgt = Buffer();
486  Int_t readSize = blockSize;
487 
488  TString content = fXML->GetNodeContent(blocknode);
489 
490  if (blockCompressed) {
491  Int_t zipSize = fXML->GetIntAttr(blocknode, xmlio::Zip);
492  fUnzipBuffer = new char[zipSize];
493 
494  tgt = fUnzipBuffer;
495  readSize = zipSize;
496  }
497 
498  char *ptr = (char *)content.Data();
499 
500  if (gDebug > 3)
501  Info("XmlReadBlock", "Content %s", ptr);
502 
503  for (int i = 0; i < readSize; i++) {
504  while ((*ptr < 48) || ((*ptr > 57) && (*ptr < 97)) || (*ptr > 102))
505  ptr++;
506 
507  int b_hi = (*ptr > 57) ? *ptr - 87 : *ptr - 48;
508  ptr++;
509  int b_lo = (*ptr > 57) ? *ptr - 87 : *ptr - 48;
510  ptr++;
511 
512  *tgt = b_hi * 16 + b_lo;
513  tgt++;
514 
515  if (gDebug > 4)
516  Info("XmlReadBlock", " Buf[%d] = %d", i, b_hi * 16 + b_lo);
517  }
518 
519  if (fUnzipBuffer) {
520 
521  int srcsize;
522  int tgtsize;
523  int status = R__unzip_header(&srcsize, (UChar_t *)fUnzipBuffer, &tgtsize);
524 
525  int unzipRes = 0;
526  if (status == 0) {
527  R__unzip(&readSize, (unsigned char *)fUnzipBuffer, &blockSize, (unsigned char *)Buffer(), &unzipRes);
528  }
529  if (status != 0 || unzipRes != blockSize)
530  Error("XmlReadBlock", "Decompression error %d", unzipRes);
531  else if (gDebug > 2)
532  Info("XmlReadBlock", "Unzip ok");
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 == 0)
545  return kFALSE;
546 
547  TString refvalue;
548 
549  if (ptr == 0)
550  refvalue = xmlio::Null; // null
551  else {
552  if (fObjMap == 0)
553  return kFALSE;
554 
555  ULong_t hash = TString::Hash(&ptr, sizeof(void *));
556 
558  if (refnode == 0)
559  return kFALSE;
560 
561  if (fXML->HasAttr(refnode, xmlio::Ref))
562  refvalue = fXML->GetAttr(refnode, xmlio::Ref);
563  else {
564  refvalue = xmlio::IdBase;
565  if (XmlFile())
566  refvalue += XmlFile()->GetNextRefCounter();
567  else
568  refvalue += GetNextRefCounter();
569  fXML->NewAttr(refnode, 0, xmlio::Ref, refvalue.Data());
570  }
571  }
572  if (refvalue.Length() > 0) {
573  fXML->NewAttr(node, 0, xmlio::Ptr, refvalue.Data());
574  return kTRUE;
575  }
576 
577  return kFALSE;
578 }
579 
580 ////////////////////////////////////////////////////////////////////////////////
581 /// Register pair of object pointer and node, where this object is saved,
582 /// in object map
583 
585 {
586  if ((node == 0) || (ptr == 0))
587  return;
588 
589  ULong_t hash = TString::Hash(&ptr, sizeof(void *));
590 
591  if (fObjMap == 0)
592  fObjMap = new TExMap();
593 
594  if (fObjMap->GetValue(hash, (Long_t)ptr) == 0)
595  fObjMap->Add(hash, (Long_t)ptr, (Long_t)node);
596 }
597 
598 ////////////////////////////////////////////////////////////////////////////////
599 /// Searches for "ptr" attribute and returns pointer to object and class,
600 /// if "ptr" attribute reference to read object
601 
603 {
604  cl = 0;
605 
606  if (!fXML->HasAttr(node, xmlio::Ptr))
607  return kFALSE;
608 
609  const char *ptrid = fXML->GetAttr(node, xmlio::Ptr);
610 
611  if (ptrid == 0)
612  return kFALSE;
613 
614  // null
615  if (strcmp(ptrid, xmlio::Null) == 0) {
616  ptr = 0;
617  return kTRUE;
618  }
619 
620  if ((fIdArray == 0) || (fObjMap == 0))
621  return kFALSE;
622 
623  TNamed *obj = (TNamed *)fIdArray->FindObject(ptrid);
624  if (obj) {
625  ptr = (void *)(Long_t)fObjMap->GetValue((Long_t)fIdArray->IndexOf(obj));
626  cl = TClass::GetClass(obj->GetTitle());
627  return kTRUE;
628  }
629  return kFALSE;
630 }
631 
632 ////////////////////////////////////////////////////////////////////////////////
633 /// Analyze if node has "ref" attribute and register it to object map
634 
635 void TBufferXML::ExtractReference(XMLNodePointer_t node, const void *ptr, const TClass *cl)
636 {
637  if ((node == 0) || (ptr == 0))
638  return;
639 
640  const char *refid = fXML->GetAttr(node, xmlio::Ref);
641 
642  if (refid == 0)
643  return;
644 
645  if (fIdArray == 0) {
646  fIdArray = new TObjArray;
648  }
649  TNamed *nid = new TNamed(refid, cl->GetName());
650  fIdArray->Add(nid);
651 
652  if (fObjMap == 0)
653  fObjMap = new TExMap();
654 
655  fObjMap->Add((Long_t)fIdArray->IndexOf(nid), (Long_t)ptr);
656 
657  if (gDebug > 2)
658  Info("ExtractReference", "Find reference %s for object %p", refid, ptr);
659 }
660 
661 ////////////////////////////////////////////////////////////////////////////////
662 /// Check if node has specified name
663 
664 Bool_t TBufferXML::VerifyNode(XMLNodePointer_t node, const char *name, const char *errinfo)
665 {
666  if ((name == 0) || (node == 0))
667  return kFALSE;
668 
669  if (strcmp(fXML->GetNodeName(node), name) != 0) {
670  if (errinfo) {
671  Error("VerifyNode", "Reading XML file (%s). Get: %s, expects: %s", errinfo, fXML->GetNodeName(node), name);
672  fErrorFlag = 1;
673  }
674  return kFALSE;
675  }
676  return kTRUE;
677 }
678 
679 ////////////////////////////////////////////////////////////////////////////////
680 /// Check, if stack node has specified name
681 
682 Bool_t TBufferXML::VerifyStackNode(const char *name, const char *errinfo)
683 {
684  return VerifyNode(StackNode(), name, errinfo);
685 }
686 
687 ////////////////////////////////////////////////////////////////////////////////
688 /// Checks, that attribute of specified name exists and has specified value
689 
690 Bool_t TBufferXML::VerifyAttr(XMLNodePointer_t node, const char *name, const char *value, const char *errinfo)
691 {
692  if ((node == 0) || (name == 0) || (value == 0))
693  return kFALSE;
694  const char *cont = fXML->GetAttr(node, name);
695  if (((cont == 0) || (strcmp(cont, value) != 0))) {
696  if (errinfo) {
697  Error("VerifyAttr", "%s : attr %s = %s, expected: %s", errinfo, name, cont, value);
698  fErrorFlag = 1;
699  }
700  return kFALSE;
701  }
702  return kTRUE;
703 }
704 
705 ////////////////////////////////////////////////////////////////////////////////
706 /// Checks stack attribute
707 
708 Bool_t TBufferXML::VerifyStackAttr(const char *name, const char *value, const char *errinfo)
709 {
710  return VerifyAttr(StackNode(), name, value, errinfo);
711 }
712 
713 ////////////////////////////////////////////////////////////////////////////////
714 /// Create item node of specified name
715 
717 {
718  XMLNodePointer_t node = 0;
719  if (GetXmlLayout() == kGeneralized) {
720  node = fXML->NewChild(StackNode(), 0, xmlio::Item, 0);
721  fXML->NewAttr(node, 0, xmlio::Name, name);
722  } else
723  node = fXML->NewChild(StackNode(), 0, name, 0);
724  return node;
725 }
726 
727 ////////////////////////////////////////////////////////////////////////////////
728 /// Checks, if stack node is item and has specified name
729 
730 Bool_t TBufferXML::VerifyItemNode(const char *name, const char *errinfo)
731 {
732  Bool_t res = kTRUE;
733  if (GetXmlLayout() == kGeneralized)
734  res = VerifyStackNode(xmlio::Item, errinfo) && VerifyStackAttr(xmlio::Name, name, errinfo);
735  else
736  res = VerifyStackNode(name, errinfo);
737  return res;
738 }
739 
740 ////////////////////////////////////////////////////////////////////////////////
741 /// Create xml node correspondent to TStreamerElement object
742 
744 {
745  XMLNodePointer_t elemnode = 0;
746 
747  const char *elemxmlname = XmlGetElementName(elem);
748 
749  if (GetXmlLayout() == kGeneralized) {
750  elemnode = fXML->NewChild(StackNode(), 0, xmlio::Member, 0);
751  fXML->NewAttr(elemnode, 0, xmlio::Name, elemxmlname);
752  } else {
753  // take namesapce for element only if it is not a base class or class name
754  XMLNsPointer_t ns = Stack()->fClassNs;
755  if ((elem->GetType() == TStreamerInfo::kBase) ||
756  ((elem->GetType() == TStreamerInfo::kTNamed) && !strcmp(elem->GetName(), TNamed::Class()->GetName())) ||
757  ((elem->GetType() == TStreamerInfo::kTObject) && !strcmp(elem->GetName(), TObject::Class()->GetName())) ||
758  ((elem->GetType() == TStreamerInfo::kTString) && !strcmp(elem->GetName(), TString::Class()->GetName())))
759  ns = 0;
760 
761  elemnode = fXML->NewChild(StackNode(), ns, elemxmlname, 0);
762  }
763 
764  TXMLStackObj *curr = PushStack(elemnode);
765  curr->fElem = (TStreamerElement *)elem;
766 }
767 
768 ////////////////////////////////////////////////////////////////////////////////
769 /// Checks if stack node correspond to TStreamerElement object
770 
772 {
773  const char *elemxmlname = XmlGetElementName(elem);
774 
775  if (GetXmlLayout() == kGeneralized) {
777  return kFALSE;
778  if (!VerifyStackAttr(xmlio::Name, elemxmlname))
779  return kFALSE;
780  } else {
781  if (!VerifyStackNode(elemxmlname))
782  return kFALSE;
783  }
784 
786 
787  TXMLStackObj *curr = PushStack(StackNode()); // set pointer to first data inside element
788  curr->fElem = (TStreamerElement *)elem;
789  return kTRUE;
790 }
791 
792 ////////////////////////////////////////////////////////////////////////////////
793 /// Write object to buffer
794 /// If object was written before, only pointer will be stored
795 /// Return pointer to top xml node, representing object
796 
797 XMLNodePointer_t TBufferXML::XmlWriteObject(const void *obj, const TClass *cl, Bool_t cacheReuse)
798 {
800 
801  if (!cl)
802  obj = 0;
803  if (ProcessPointer(obj, objnode))
804  return objnode;
805 
806  TString clname = XmlConvertClassName(cl->GetName());
807 
808  fXML->NewAttr(objnode, 0, xmlio::ObjClass, clname);
809 
810  if (cacheReuse) RegisterPointer(obj, objnode);
811 
812  PushStack(objnode);
813 
814  ((TClass *)cl)->Streamer((void *)obj, *this);
815 
816  PopStack();
817 
818  if (gDebug > 1)
819  Info("XmlWriteObject", "Done write for class: %s", cl ? cl->GetName() : "null");
820 
821  return objnode;
822 }
823 
824 ////////////////////////////////////////////////////////////////////////////////
825 /// Read object from the buffer
826 
827 void *TBufferXML::XmlReadObject(void *obj, TClass **cl)
828 {
829  if (cl)
830  *cl = 0;
831 
832  XMLNodePointer_t objnode = StackNode();
833 
834  if (fErrorFlag > 0)
835  return obj;
836 
837  if (objnode == 0)
838  return obj;
839 
840  if (!VerifyNode(objnode, xmlio::Object, "XmlReadObjectNew"))
841  return obj;
842 
843  TClass *objClass = 0;
844 
845  if (ExtractPointer(objnode, obj, objClass)) {
846  ShiftStack("readobjptr");
847  if (cl)
848  *cl = objClass;
849  return obj;
850  }
851 
852  TString clname = fXML->GetAttr(objnode, xmlio::ObjClass);
853  objClass = XmlDefineClass(clname);
854  if (objClass == TDirectory::Class())
855  objClass = TDirectoryFile::Class();
856 
857  if (objClass == 0) {
858  Error("XmlReadObject", "Cannot find class %s", clname.Data());
859  ShiftStack("readobjerr");
860  return obj;
861  }
862 
863  if (gDebug > 1)
864  Info("XmlReadObject", "Reading object of class %s", clname.Data());
865 
866  if (obj == 0)
867  obj = objClass->New();
868 
869  ExtractReference(objnode, obj, objClass);
870 
871  PushStack(objnode);
872 
873  objClass->Streamer((void *)obj, *this);
874 
875  PopStack();
876 
877  ShiftStack("readobj");
878 
879  if (gDebug > 1)
880  Info("XmlReadObject", "Reading object of class %s done", clname.Data());
881 
882  if (cl)
883  *cl = objClass;
884 
885  return obj;
886 }
887 
888 ////////////////////////////////////////////////////////////////////////////////
889 /// Function is called from TStreamerInfo WriteBuffer and ReadBuffer functions
890 /// and indent new level in xml structure.
891 /// This call indicates, that TStreamerInfo functions starts streaming
892 /// object data of correspondent class
893 
895 {
896  WorkWithClass((TStreamerInfo *)info);
897 }
898 
899 ////////////////////////////////////////////////////////////////////////////////
900 /// Prepares buffer to stream data of specified class.
901 
903 {
906 
907  if (sinfo != 0)
908  cl = sinfo->GetClass();
909 
910  if (cl == 0)
911  return;
912 
913  TString clname = XmlConvertClassName(cl->GetName());
914 
915  if (gDebug > 2)
916  Info("IncrementLevel", "Class: %s", clname.Data());
917 
918  Bool_t compressClassNode = fExpectedBaseClass == cl;
919  fExpectedBaseClass = 0;
920 
921  TXMLStackObj *stack = Stack();
922 
923  if (IsWriting()) {
924 
925  XMLNodePointer_t classnode = 0;
926  if (compressClassNode) {
927  classnode = StackNode();
928  } else {
929  if (GetXmlLayout() == kGeneralized) {
930  classnode = fXML->NewChild(StackNode(), 0, xmlio::Class, 0);
931  fXML->NewAttr(classnode, 0, "name", clname);
932  } else
933  classnode = fXML->NewChild(StackNode(), 0, clname, 0);
934  stack = PushStack(classnode);
935  }
936 
937  if (fVersionBuf >= -1) {
938  if (fVersionBuf == -1)
939  fVersionBuf = 1;
941  fVersionBuf = -111;
942  }
943 
944  if (IsUseNamespaces() && (GetXmlLayout() != kGeneralized))
945  stack->fClassNs = fXML->NewNS(classnode, XmlClassNameSpaceRef(cl), clname);
946 
947  } else {
948  if (!compressClassNode) {
949  if (GetXmlLayout() == kGeneralized) {
950  if (!VerifyStackNode(xmlio::Class, "StartInfo"))
951  return;
952  if (!VerifyStackAttr("name", clname, "StartInfo"))
953  return;
954  } else if (!VerifyStackNode(clname, "StartInfo"))
955  return;
956  stack = PushStack(StackNode());
957  }
958  }
959 
960  stack->fCompressedClassNode = compressClassNode;
961  stack->fInfo = sinfo;
962  stack->fIsStreamerInfo = kTRUE;
963 }
964 
965 ////////////////////////////////////////////////////////////////////////////////
966 /// Function is called from TStreamerInfo WriteBuffer and ReadBuffer functions
967 /// and decrease level in xml structure.
968 
970 {
971  CheckVersionBuf();
972 
975 
976  if (gDebug > 2)
977  Info("DecrementLevel", "Class: %s", (info ? info->GetClass()->GetName() : "custom"));
978 
979  TXMLStackObj *stack = Stack();
980 
981  if (!stack->IsStreamerInfo()) {
983  stack = PopStack(); // remove stack of last element
984  }
985 
986  if (stack->fCompressedClassNode) {
987  stack->fInfo = 0;
988  stack->fIsStreamerInfo = kFALSE;
989  stack->fCompressedClassNode = kFALSE;
990  } else {
991  PopStack(); // back from data of stack info
992  if (IsReading())
993  ShiftStack("declevel"); // shift to next element after streamer info
994  }
995 }
996 
997 ////////////////////////////////////////////////////////////////////////////////
998 /// Function is called from TStreamerInfo WriteBuffer and ReadBuffer functions
999 /// and add/verify next element of xml structure
1000 /// This calls allows separate data, correspondent to one class member, from another
1001 
1003 {
1004  WorkWithElement(elem, comptype);
1005 }
1006 
1007 ////////////////////////////////////////////////////////////////////////////////
1008 /// This function is a part of SetStreamerElementNumber method.
1009 /// It is introduced for reading of data for specified data member of class.
1010 /// Used also in ReadFastArray methods to resolve problem of compressed data,
1011 /// when several data members of the same basic type streamed with single ...FastArray call
1012 
1014 {
1015  CheckVersionBuf();
1016 
1019  fExpectedBaseClass = 0;
1020 
1021  TXMLStackObj *stack = Stack();
1022  if (stack == 0) {
1023  Error("SetStreamerElementNumber", "stack is empty");
1024  return;
1025  }
1026 
1027  if (!stack->IsStreamerInfo()) { // this is not a first element
1029  PopStack(); // go level back
1030  if (IsReading())
1031  ShiftStack("startelem"); // shift to next element, only for reading
1032  stack = dynamic_cast<TXMLStackObj *>(fStack.Last());
1033  }
1034 
1035  if (stack == 0) {
1036  Error("SetStreamerElementNumber", "Lost of stack");
1037  return;
1038  }
1039 
1040  if (!elem) {
1041  Error("SetStreamerElementNumber", "Problem in Inc/Dec level");
1042  return;
1043  }
1044 
1045  TStreamerInfo *info = stack->fInfo;
1046 
1047  if (!stack->IsStreamerInfo()) {
1048  Error("SetStreamerElementNumber", "Problem in Inc/Dec level");
1049  return;
1050  }
1051  Int_t number = info ? info->GetElements()->IndexOf(elem) : -1;
1052 
1053  if (gDebug > 4)
1054  Info("SetStreamerElementNumber", " Next element %s", elem->GetName());
1055 
1056  Bool_t isBasicType = (elem->GetType() > 0) && (elem->GetType() < 20);
1057 
1058  fExpectedChain = isBasicType && (comp_type - elem->GetType() == TStreamerInfo::kOffsetL);
1059 
1060  if (fExpectedChain && (gDebug > 3)) {
1061  Info("SetStreamerElementNumber", " Expects chain for elem %s number %d", elem->GetName(), number);
1062  }
1063 
1064  fCanUseCompact =
1065  isBasicType && ((elem->GetType() == comp_type) || (elem->GetType() == comp_type - TStreamerInfo::kConv) ||
1066  (elem->GetType() == comp_type - TStreamerInfo::kSkip));
1067 
1068  if ((elem->GetType() == TStreamerInfo::kBase) ||
1069  ((elem->GetType() == TStreamerInfo::kTNamed) && !strcmp(elem->GetName(), TNamed::Class()->GetName())))
1071 
1072  if (fExpectedBaseClass && (gDebug > 3))
1073  Info("SetStreamerElementNumber", " Expects base class %s with standard streamer",
1075 
1076  if (IsWriting()) {
1077  CreateElemNode(elem);
1078  } else {
1079  if (!VerifyElemNode(elem))
1080  return;
1081  }
1082 
1083  stack = Stack();
1084  stack->fElemNumber = number;
1085  stack->fIsElemOwner = (number < 0);
1086 }
1087 
1088 ////////////////////////////////////////////////////////////////////////////////
1089 /// Should be called at the beginning of custom class streamer.
1090 ///
1091 /// Informs buffer data about class which will be streamed now.
1092 /// ClassBegin(), ClassEnd() and ClassMemeber() should be used in
1093 /// custom class streamers to specify which kind of data are
1094 /// now streamed. Such information is used to correctly
1095 /// convert class data to XML. Without that functions calls
1096 /// classes with custom streamers cannot be used with TBufferXML
1097 
1099 {
1100  WorkWithClass(0, cl);
1101 }
1102 
1103 ////////////////////////////////////////////////////////////////////////////////
1104 /// Should be called at the end of custom streamer
1105 /// See TBufferXML::ClassBegin for more details
1106 
1108 {
1109  DecrementLevel(0);
1110 }
1111 
1112 ////////////////////////////////////////////////////////////////////////////////
1113 /// Method indicates name and typename of class member,
1114 /// which should be now streamed in custom streamer
1115 ///
1116 /// Following combinations are supported:
1117 /// -# name = "ClassName", typeName = 0 or typename==ClassName.
1118 /// This is a case, when data of parent class "ClassName" should be streamed.
1119 /// For instance, if class directly inherited from TObject, custom streamer
1120 /// should include following code:
1121 /// ~~~{.cpp}
1122 /// b.ClassMember("TObject");
1123 /// TObject::Streamer(b);
1124 /// ~~~
1125 /// -# Basic data type
1126 /// ~~~{.cpp}
1127 /// b.ClassMember("fInt","Int_t");
1128 /// b >> fInt;
1129 /// ~~~
1130 /// -# Array of basic data types
1131 /// ~~~{.cpp}
1132 /// b.ClassMember("fArr","Int_t", 5);
1133 /// b.ReadFastArray(fArr, 5);
1134 /// ~~~
1135 /// -# Object as data member
1136 /// ~~~{.cpp}
1137 /// b.ClassMemeber("fName","TString");
1138 /// fName.Streamer(b);
1139 /// ~~~
1140 /// -# Pointer on object as data member
1141 /// ~~~{.cpp}
1142 /// b.ClassMemeber("fObj","TObject*");
1143 /// b.StreamObject(fObj);
1144 /// ~~~
1145 ///
1146 /// Arrsize1 and arrsize2 arguments (when specified) indicate first and
1147 /// second dimension of array. Can be used for array of basic types.
1148 /// See ClassBegin() method for more details.
1149 
1150 void TBufferXML::ClassMember(const char *name, const char *typeName, Int_t arrsize1, Int_t arrsize2)
1151 {
1152  if (typeName == 0)
1153  typeName = name;
1154 
1155  if ((name == 0) || (strlen(name) == 0)) {
1156  Error("ClassMember", "Invalid member name");
1157  fErrorFlag = 1;
1158  return;
1159  }
1160 
1161  TString tname = typeName;
1162 
1163  Int_t typ_id(-1), comp_type(-1);
1164 
1165  if (strcmp(typeName, "raw:data") == 0)
1166  typ_id = TStreamerInfo::kMissing;
1167 
1168  if (typ_id < 0) {
1169  TDataType *dt = gROOT->GetType(typeName);
1170  if (dt != 0)
1171  if ((dt->GetType() > 0) && (dt->GetType() < 20))
1172  typ_id = dt->GetType();
1173  }
1174 
1175  if (typ_id < 0)
1176  if (strcmp(name, typeName) == 0) {
1177  TClass *cl = TClass::GetClass(tname.Data());
1178  if (cl != 0)
1179  typ_id = TStreamerInfo::kBase;
1180  }
1181 
1182  if (typ_id < 0) {
1183  Bool_t isptr = kFALSE;
1184  if (tname[tname.Length() - 1] == '*') {
1185  tname.Resize(tname.Length() - 1);
1186  isptr = kTRUE;
1187  }
1188  TClass *cl = TClass::GetClass(tname.Data());
1189  if (cl == 0) {
1190  Error("ClassMember", "Invalid class specifier %s", typeName);
1191  fErrorFlag = 1;
1192  return;
1193  }
1194 
1195  if (cl->IsTObject())
1197  else
1198  typ_id = isptr ? TStreamerInfo::kAnyp : TStreamerInfo::kAny;
1199 
1200  if ((cl == TString::Class()) && !isptr)
1201  typ_id = TStreamerInfo::kTString;
1202  }
1203 
1204  TStreamerElement *elem = 0;
1205 
1206  if (typ_id == TStreamerInfo::kMissing) {
1207  elem = new TStreamerElement(name, "title", 0, typ_id, "raw:data");
1208  } else
1209 
1210  if (typ_id == TStreamerInfo::kBase) {
1211  TClass *cl = TClass::GetClass(tname.Data());
1212  if (cl != 0) {
1213  TStreamerBase *b = new TStreamerBase(tname.Data(), "title", 0);
1214  b->SetBaseVersion(cl->GetClassVersion());
1215  elem = b;
1216  }
1217  } else
1218 
1219  if ((typ_id > 0) && (typ_id < 20)) {
1220  elem = new TStreamerBasicType(name, "title", 0, typ_id, typeName);
1221  comp_type = typ_id;
1222  } else
1223 
1224  if ((typ_id == TStreamerInfo::kObject) || (typ_id == TStreamerInfo::kTObject) ||
1225  (typ_id == TStreamerInfo::kTNamed)) {
1226  elem = new TStreamerObject(name, "title", 0, tname.Data());
1227  } else
1228 
1229  if (typ_id == TStreamerInfo::kObjectp) {
1230  elem = new TStreamerObjectPointer(name, "title", 0, tname.Data());
1231  } else
1232 
1233  if (typ_id == TStreamerInfo::kAny) {
1234  elem = new TStreamerObjectAny(name, "title", 0, tname.Data());
1235  } else
1236 
1237  if (typ_id == TStreamerInfo::kAnyp) {
1238  elem = new TStreamerObjectAnyPointer(name, "title", 0, tname.Data());
1239  } else
1240 
1241  if (typ_id == TStreamerInfo::kTString) {
1242  elem = new TStreamerString(name, "title", 0);
1243  }
1244 
1245  if (elem == 0) {
1246  Error("ClassMember", "Invalid combination name = %s type = %s", name, typeName);
1247  fErrorFlag = 1;
1248  return;
1249  }
1250 
1251  if (arrsize1 > 0) {
1252  elem->SetArrayDim(arrsize2 > 0 ? 2 : 1);
1253  elem->SetMaxIndex(0, arrsize1);
1254  if (arrsize2 > 0)
1255  elem->SetMaxIndex(1, arrsize2);
1256  }
1257 
1258  // we indicate that there is no streamerinfo
1259  WorkWithElement(elem, comp_type);
1260 }
1261 
1262 ////////////////////////////////////////////////////////////////////////////////
1263 /// Function is converts TObject and TString structures to more compact representation
1264 
1266 {
1267  if (GetXmlLayout() == kGeneralized)
1268  return;
1269 
1270  const TStreamerElement *elem = Stack()->fElem;
1271  XMLNodePointer_t elemnode = IsWriting() ? Stack()->fNode : Stack(1)->fNode;
1272 
1273  if ((elem == 0) || (elemnode == 0))
1274  return;
1275 
1276  if (elem->GetType() == TStreamerInfo::kTString) {
1277 
1278  XMLNodePointer_t node = fXML->GetChild(elemnode);
1279  fXML->SkipEmpty(node);
1280 
1281  XMLNodePointer_t nodecharstar(0), nodeuchar(0), nodeint(0), nodestring(0);
1282 
1283  while (node != 0) {
1284  const char *name = fXML->GetNodeName(node);
1285  if (strcmp(name, xmlio::String) == 0) {
1286  if (nodestring)
1287  return;
1288  nodestring = node;
1289  } else if (strcmp(name, xmlio::UChar) == 0) {
1290  if (nodeuchar)
1291  return;
1292  nodeuchar = node;
1293  } else if (strcmp(name, xmlio::Int) == 0) {
1294  if (nodeint)
1295  return;
1296  nodeint = node;
1297  } else if (strcmp(name, xmlio::CharStar) == 0) {
1298  if (nodecharstar != 0)
1299  return;
1300  nodecharstar = node;
1301  } else
1302  return; // can not be something else
1303  fXML->ShiftToNext(node);
1304  }
1305 
1306  TString str;
1307 
1308  if (GetIOVersion() < 3) {
1309  if (nodeuchar == 0)
1310  return;
1311  if (nodecharstar != 0)
1312  str = fXML->GetAttr(nodecharstar, xmlio::v);
1313  fXML->UnlinkFreeNode(nodeuchar);
1314  fXML->UnlinkFreeNode(nodeint);
1315  fXML->UnlinkFreeNode(nodecharstar);
1316  } else {
1317  if (nodestring != 0)
1318  str = fXML->GetAttr(nodestring, xmlio::v);
1319  fXML->UnlinkFreeNode(nodestring);
1320  }
1321 
1322  fXML->NewAttr(elemnode, 0, "str", str);
1323  } else if (elem->GetType() == TStreamerInfo::kTObject) {
1324  XMLNodePointer_t node = fXML->GetChild(elemnode);
1325  fXML->SkipEmpty(node);
1326 
1327  XMLNodePointer_t vnode = 0;
1328  XMLNodePointer_t idnode = 0;
1329  XMLNodePointer_t bitsnode = 0;
1330  XMLNodePointer_t prnode = 0;
1331  while (node != 0) {
1332  const char *name = fXML->GetNodeName(node);
1333 
1334  if (strcmp(name, xmlio::OnlyVersion) == 0) {
1335  if (vnode)
1336  return;
1337  vnode = node;
1338  } else if (strcmp(name, xmlio::UInt) == 0) {
1339  if (idnode == 0)
1340  idnode = node;
1341  else if (bitsnode == 0)
1342  bitsnode = node;
1343  else
1344  return;
1345  } else if (strcmp(name, xmlio::UShort) == 0) {
1346  if (prnode)
1347  return;
1348  prnode = node;
1349  } else
1350  return;
1351  fXML->ShiftToNext(node);
1352  }
1353 
1354  if ((vnode == 0) || (idnode == 0) || (bitsnode == 0))
1355  return;
1356 
1357  TString str = fXML->GetAttr(idnode, xmlio::v);
1358  fXML->NewAttr(elemnode, 0, "fUniqueID", str);
1359 
1360  str = fXML->GetAttr(bitsnode, xmlio::v);
1361  UInt_t bits;
1362  sscanf(str.Data(), "%u", &bits);
1363 
1364  char sbuf[20];
1365  snprintf(sbuf, sizeof(sbuf), "%x", bits);
1366  fXML->NewAttr(elemnode, 0, "fBits", sbuf);
1367 
1368  if (prnode != 0) {
1369  str = fXML->GetAttr(prnode, xmlio::v);
1370  fXML->NewAttr(elemnode, 0, "fProcessID", str);
1371  }
1372 
1373  fXML->UnlinkFreeNode(vnode);
1374  fXML->UnlinkFreeNode(idnode);
1375  fXML->UnlinkFreeNode(bitsnode);
1376  fXML->UnlinkFreeNode(prnode);
1377  }
1378 }
1379 
1380 ////////////////////////////////////////////////////////////////////////////////
1381 /// Function is unpack TObject and TString structures to be able read
1382 /// them from custom streamers of this objects
1383 
1385 {
1386  if (GetXmlLayout() == kGeneralized)
1387  return;
1388  if ((elem == 0) || (elemnode == 0))
1389  return;
1390 
1391  if (elem->GetType() == TStreamerInfo::kTString) {
1392 
1393  if (!fXML->HasAttr(elemnode, "str"))
1394  return;
1395  TString str = fXML->GetAttr(elemnode, "str");
1396  fXML->FreeAttr(elemnode, "str");
1397 
1398  if (GetIOVersion() < 3) {
1399  Int_t len = str.Length();
1400  XMLNodePointer_t ucharnode = fXML->NewChild(elemnode, 0, xmlio::UChar, 0);
1401  char sbuf[20];
1402  snprintf(sbuf, sizeof(sbuf), "%d", len);
1403  if (len < 255) {
1404  fXML->NewAttr(ucharnode, 0, xmlio::v, sbuf);
1405  } else {
1406  fXML->NewAttr(ucharnode, 0, xmlio::v, "255");
1407  XMLNodePointer_t intnode = fXML->NewChild(elemnode, 0, xmlio::Int, 0);
1408  fXML->NewAttr(intnode, 0, xmlio::v, sbuf);
1409  }
1410  if (len > 0) {
1411  XMLNodePointer_t node = fXML->NewChild(elemnode, 0, xmlio::CharStar, 0);
1412  fXML->NewAttr(node, 0, xmlio::v, str);
1413  }
1414  } else {
1415  XMLNodePointer_t node = fXML->NewChild(elemnode, 0, xmlio::String, 0);
1416  fXML->NewAttr(node, 0, xmlio::v, str);
1417  }
1418  } else if (elem->GetType() == TStreamerInfo::kTObject) {
1419  if (!fXML->HasAttr(elemnode, "fUniqueID"))
1420  return;
1421  if (!fXML->HasAttr(elemnode, "fBits"))
1422  return;
1423 
1424  TString idstr = fXML->GetAttr(elemnode, "fUniqueID");
1425  TString bitsstr = fXML->GetAttr(elemnode, "fBits");
1426  TString prstr = fXML->GetAttr(elemnode, "fProcessID");
1427 
1428  fXML->FreeAttr(elemnode, "fUniqueID");
1429  fXML->FreeAttr(elemnode, "fBits");
1430  fXML->FreeAttr(elemnode, "fProcessID");
1431 
1432  XMLNodePointer_t node = fXML->NewChild(elemnode, 0, xmlio::OnlyVersion, 0);
1433  fXML->NewAttr(node, 0, xmlio::v, "1");
1434 
1435  node = fXML->NewChild(elemnode, 0, xmlio::UInt, 0);
1436  fXML->NewAttr(node, 0, xmlio::v, idstr);
1437 
1438  UInt_t bits;
1439  sscanf(bitsstr.Data(), "%x", &bits);
1440  char sbuf[20];
1441  snprintf(sbuf, sizeof(sbuf), "%u", bits);
1442 
1443  node = fXML->NewChild(elemnode, 0, xmlio::UInt, 0);
1444  fXML->NewAttr(node, 0, xmlio::v, sbuf);
1445 
1446  if (prstr.Length() > 0) {
1447  node = fXML->NewChild(elemnode, 0, xmlio::UShort, 0);
1448  fXML->NewAttr(node, 0, xmlio::v, prstr.Data());
1449  }
1450  }
1451 }
1452 
1453 ////////////////////////////////////////////////////////////////////////////////
1454 /// Function is called before any IO operation of TBuffer
1455 /// Now is used to store version value if no proper calls are discovered
1456 
1458 {
1459  CheckVersionBuf();
1460 }
1461 
1462 ////////////////////////////////////////////////////////////////////////////////
1463 /// Function to read class from buffer, used in old-style streamers
1464 
1466 {
1467  const char *clname = 0;
1468 
1470  clname = XmlReadValue(xmlio::Class);
1471  }
1472 
1473  if (gDebug > 2)
1474  Info("ReadClass", "Try to read class %s", clname ? clname : "---");
1475 
1476  return clname ? gROOT->GetClass(clname) : 0;
1477 }
1478 
1479 ////////////////////////////////////////////////////////////////////////////////
1480 /// Function to write class into buffer, used in old-style streamers
1481 
1483 {
1484  if (gDebug > 2)
1485  Info("WriteClass", "Try to write class %s", cl->GetName());
1486 
1488 }
1489 
1490 ////////////////////////////////////////////////////////////////////////////////
1491 /// Suppressed function of TBuffer
1492 
1493 Int_t TBufferXML::CheckByteCount(UInt_t /*r_s */, UInt_t /*r_c*/, const TClass * /*cl*/)
1494 {
1495  return 0;
1496 }
1497 
1498 ////////////////////////////////////////////////////////////////////////////////
1499 /// Suppressed function of TBuffer
1500 
1502 {
1503  return 0;
1504 }
1505 
1506 ////////////////////////////////////////////////////////////////////////////////
1507 /// Suppressed function of TBuffer
1508 
1510 {
1511 }
1512 
1513 ////////////////////////////////////////////////////////////////////////////////
1514 /// Skip class version from I/O buffer.
1515 
1517 {
1518  ReadVersion(0, 0, cl);
1519 }
1520 
1521 ////////////////////////////////////////////////////////////////////////////////
1522 /// Read version value from buffer
1523 
1524 Version_t TBufferXML::ReadVersion(UInt_t *start, UInt_t *bcnt, const TClass * /*cl*/)
1525 {
1527 
1528  Version_t res = 0;
1529 
1530  if (start)
1531  *start = 0;
1532  if (bcnt)
1533  *bcnt = 0;
1534 
1537  } else if ((fExpectedBaseClass != 0) && (fXML->HasAttr(Stack(1)->fNode, xmlio::ClassVersion))) {
1538  res = fXML->GetIntAttr(Stack(1)->fNode, xmlio::ClassVersion);
1539  } else if (fXML->HasAttr(StackNode(), xmlio::ClassVersion)) {
1541  } else {
1542  Error("ReadVersion", "No correspondent tags to read version");
1543  ;
1544  fErrorFlag = 1;
1545  }
1546 
1547  if (gDebug > 2)
1548  Info("ReadVersion", "Version = %d", res);
1549 
1550  return res;
1551 }
1552 
1553 ////////////////////////////////////////////////////////////////////////////////
1554 /// Checks buffer, filled by WriteVersion
1555 /// if next data is arriving, version should be stored in buffer
1556 
1558 {
1559  if (IsWriting() && (fVersionBuf >= -100)) {
1560  char sbuf[20];
1561  snprintf(sbuf, sizeof(sbuf), "%d", fVersionBuf);
1563  fVersionBuf = -111;
1564  }
1565 }
1566 
1567 ////////////////////////////////////////////////////////////////////////////////
1568 /// Copies class version to buffer, but not writes it to xml
1569 /// Version will be written with next I/O operation or
1570 /// will be added as attribute of class tag, created by IncrementLevel call
1571 
1573 {
1575 
1576  if (fExpectedBaseClass != cl)
1577  fExpectedBaseClass = 0;
1578 
1579  fVersionBuf = cl->GetClassVersion();
1580 
1581  if (gDebug > 2)
1582  Info("WriteVersion", "Class: %s, version = %d", cl->GetName(), fVersionBuf);
1583 
1584  return 0;
1585 }
1586 
1587 ////////////////////////////////////////////////////////////////////////////////
1588 /// Read object from buffer. Only used from TBuffer
1589 
1591 {
1593  if (gDebug > 2)
1594  Info("ReadObjectAny", "From node %s", fXML->GetNodeName(StackNode()));
1595  void *res = XmlReadObject(0);
1596  return res;
1597 }
1598 
1599 ////////////////////////////////////////////////////////////////////////////////
1600 /// Skip any kind of object from buffer
1601 /// Actually skip only one node on current level of xml structure
1602 
1604 {
1605  ShiftStack("skipobjectany");
1606 }
1607 
1608 ////////////////////////////////////////////////////////////////////////////////
1609 /// Write object to buffer. Only used from TBuffer
1610 
1611 void TBufferXML::WriteObjectClass(const void *actualObjStart, const TClass *actualClass, Bool_t cacheReuse)
1612 {
1614  if (gDebug > 2)
1615  Info("WriteObject", "Class %s", (actualClass ? actualClass->GetName() : " null"));
1616  XmlWriteObject(actualObjStart, actualClass, cacheReuse);
1617 }
1618 
1619 // Macro to read content of uncompressed array
1620 #define TXMLReadArrayNoncompress(vname) \
1621  { \
1622  for (Int_t indx = 0; indx < n; indx++) \
1623  XmlReadBasic(vname[indx]); \
1624  }
1625 
1626 // macro to read content of array with compression
1627 #define TXMLReadArrayContent(vname, arrsize) \
1628  { \
1629  Int_t indx = 0; \
1630  while (indx < arrsize) { \
1631  Int_t cnt = 1; \
1632  if (fXML->HasAttr(StackNode(), xmlio::cnt)) \
1633  cnt = fXML->GetIntAttr(StackNode(), xmlio::cnt); \
1634  XmlReadBasic(vname[indx]); \
1635  Int_t curr = indx; \
1636  indx++; \
1637  while (cnt > 1) { \
1638  vname[indx] = vname[curr]; \
1639  cnt--; \
1640  indx++; \
1641  } \
1642  } \
1643  }
1644 
1645 // macro to read array, which include size attribute
1646 #define TBufferXML_ReadArray(tname, vname) \
1647  { \
1648  BeforeIOoperation(); \
1649  if (!VerifyItemNode(xmlio::Array, "ReadArray")) \
1650  return 0; \
1651  Int_t n = fXML->GetIntAttr(StackNode(), xmlio::Size); \
1652  if (n <= 0) \
1653  return 0; \
1654  if (!vname) \
1655  vname = new tname[n]; \
1656  PushStack(StackNode()); \
1657  TXMLReadArrayContent(vname, n); \
1658  PopStack(); \
1659  ShiftStack("readarr"); \
1660  return n; \
1661  }
1662 
1663 ////////////////////////////////////////////////////////////////////////////////
1664 /// Read a Float16_t from the buffer
1665 
1667 {
1669  XmlReadBasic(*f);
1670 }
1671 
1672 ////////////////////////////////////////////////////////////////////////////////
1673 /// Read a Double32_t from the buffer
1674 
1676 {
1678  XmlReadBasic(*d);
1679 }
1680 
1681 ////////////////////////////////////////////////////////////////////////////////
1682 /// Read a Double32_t from the buffer when the factor and minimun value have been specified
1683 /// see comments about Double32_t encoding at TBufferFile::WriteDouble32().
1684 /// Currently TBufferXML does not optimize space in this case.
1685 
1686 void TBufferXML::ReadWithFactor(Float_t *ptr, Double_t /* factor */, Double_t /* minvalue */)
1687 {
1689  XmlReadBasic(*ptr);
1690 }
1691 
1692 ////////////////////////////////////////////////////////////////////////////////
1693 /// Read a Float16_t from the buffer when the number of bits is specified (explicitly or not)
1694 /// see comments about Float16_t encoding at TBufferFile::WriteFloat16().
1695 /// Currently TBufferXML does not optimize space in this case.
1696 
1697 void TBufferXML::ReadWithNbits(Float_t *ptr, Int_t /* nbits */)
1698 {
1700  XmlReadBasic(*ptr);
1701 }
1702 
1703 ////////////////////////////////////////////////////////////////////////////////
1704 /// Read a Double32_t from the buffer when the factor and minimum value have been specified
1705 /// see comments about Double32_t encoding at TBufferFile::WriteDouble32().
1706 /// Currently TBufferXML does not optimize space in this case.
1707 
1708 void TBufferXML::ReadWithFactor(Double_t *ptr, Double_t /* factor */, Double_t /* minvalue */)
1709 {
1711  XmlReadBasic(*ptr);
1712 }
1713 
1714 ////////////////////////////////////////////////////////////////////////////////
1715 /// Read a Double32_t from the buffer when the number of bits is specified (explicitly or not)
1716 /// see comments about Double32_t encoding at TBufferFile::WriteDouble32().
1717 /// Currently TBufferXML does not optimize space in this case.
1718 
1720 {
1722  XmlReadBasic(*ptr);
1723 }
1724 
1725 ////////////////////////////////////////////////////////////////////////////////
1726 /// Write a Float16_t to the buffer
1727 
1729 {
1731  XmlWriteBasic(*f);
1732 }
1733 
1734 ////////////////////////////////////////////////////////////////////////////////
1735 /// Write a Double32_t to the buffer
1736 
1738 {
1740  XmlWriteBasic(*d);
1741 }
1742 
1743 ////////////////////////////////////////////////////////////////////////////////
1744 /// Read array of Bool_t from buffer
1745 
1747 {
1749 }
1750 
1751 ////////////////////////////////////////////////////////////////////////////////
1752 /// Read array of Char_t from buffer
1753 
1755 {
1757 }
1758 
1759 ////////////////////////////////////////////////////////////////////////////////
1760 /// Read array of UChar_t from buffer
1761 
1763 {
1765 }
1766 
1767 ////////////////////////////////////////////////////////////////////////////////
1768 /// Read array of Short_t from buffer
1769 
1771 {
1773 }
1774 
1775 ////////////////////////////////////////////////////////////////////////////////
1776 /// Read array of UShort_t from buffer
1777 
1779 {
1781 }
1782 
1783 ////////////////////////////////////////////////////////////////////////////////
1784 /// Read array of Int_t from buffer
1785 
1787 {
1789 }
1790 
1791 ////////////////////////////////////////////////////////////////////////////////
1792 /// Read array of UInt_t from buffer
1793 
1795 {
1797 }
1798 
1799 ////////////////////////////////////////////////////////////////////////////////
1800 /// Read array of Long_t from buffer
1801 
1803 {
1805 }
1806 
1807 ////////////////////////////////////////////////////////////////////////////////
1808 /// Read array of ULong_t from buffer
1809 
1811 {
1813 }
1814 
1815 ////////////////////////////////////////////////////////////////////////////////
1816 /// Read array of Long64_t from buffer
1817 
1819 {
1821 }
1822 
1823 ////////////////////////////////////////////////////////////////////////////////
1824 /// Read array of ULong64_t from buffer
1825 
1827 {
1829 }
1830 
1831 ////////////////////////////////////////////////////////////////////////////////
1832 /// Read array of Float_t from buffer
1833 
1835 {
1837 }
1838 
1839 ////////////////////////////////////////////////////////////////////////////////
1840 /// Read array of Double_t from buffer
1841 
1843 {
1845 }
1846 
1847 ////////////////////////////////////////////////////////////////////////////////
1848 /// Read array of Float16_t from buffer
1849 
1851 {
1853 }
1854 
1855 ////////////////////////////////////////////////////////////////////////////////
1856 /// Read array of Double32_t from buffer
1857 
1859 {
1861 }
1862 
1863 // macro to read array from xml buffer
1864 #define TBufferXML_ReadStaticArray(vname) \
1865  { \
1866  BeforeIOoperation(); \
1867  if (!VerifyItemNode(xmlio::Array, "ReadStaticArray")) \
1868  return 0; \
1869  Int_t n = fXML->GetIntAttr(StackNode(), xmlio::Size); \
1870  if (n <= 0) \
1871  return 0; \
1872  if (!vname) \
1873  return 0; \
1874  PushStack(StackNode()); \
1875  TXMLReadArrayContent(vname, n); \
1876  PopStack(); \
1877  ShiftStack("readstatarr"); \
1878  return n; \
1879  }
1880 
1881 ////////////////////////////////////////////////////////////////////////////////
1882 /// Read array of Bool_t from buffer
1883 
1885 {
1887 }
1888 
1889 ////////////////////////////////////////////////////////////////////////////////
1890 /// Read array of Char_t from buffer
1891 
1893 {
1895 }
1896 
1897 ////////////////////////////////////////////////////////////////////////////////
1898 /// Read array of UChar_t from buffer
1899 
1901 {
1903 }
1904 
1905 ////////////////////////////////////////////////////////////////////////////////
1906 /// Read array of Short_t from buffer
1907 
1909 {
1911 }
1912 
1913 ////////////////////////////////////////////////////////////////////////////////
1914 /// Read array of UShort_t from buffer
1915 
1917 {
1919 }
1920 
1921 ////////////////////////////////////////////////////////////////////////////////
1922 /// Read array of Int_t from buffer
1923 
1925 {
1927 }
1928 
1929 ////////////////////////////////////////////////////////////////////////////////
1930 /// Read array of UInt_t from buffer
1931 
1933 {
1935 }
1936 
1937 ////////////////////////////////////////////////////////////////////////////////
1938 /// Read array of Long_t from buffer
1939 
1941 {
1943 }
1944 
1945 ////////////////////////////////////////////////////////////////////////////////
1946 /// Read array of ULong_t from buffer
1947 
1949 {
1951 }
1952 
1953 ////////////////////////////////////////////////////////////////////////////////
1954 /// Read array of Long64_t from buffer
1955 
1957 {
1959 }
1960 
1961 ////////////////////////////////////////////////////////////////////////////////
1962 /// Read array of ULong64_t from buffer
1963 
1965 {
1967 }
1968 
1969 ////////////////////////////////////////////////////////////////////////////////
1970 /// Read array of Float_t from buffer
1971 
1973 {
1975 }
1976 
1977 ////////////////////////////////////////////////////////////////////////////////
1978 /// Read array of Double_t from buffer
1979 
1981 {
1983 }
1984 
1985 ////////////////////////////////////////////////////////////////////////////////
1986 /// Read array of Float16_t from buffer
1987 
1989 {
1991 }
1992 
1993 ////////////////////////////////////////////////////////////////////////////////
1994 /// Read array of Double32_t from buffer
1995 
1997 {
1999 }
2000 
2001 // macro to read content of array, which not include size of array
2002 // macro also treat situation, when instead of one single array chain
2003 // of several elements should be produced
2004 #define TBufferXML_ReadFastArray(vname) \
2005  { \
2006  BeforeIOoperation(); \
2007  if (n <= 0) \
2008  return; \
2009  TStreamerElement *elem = Stack(0)->fElem; \
2010  if ((elem != 0) && (elem->GetType() > TStreamerInfo::kOffsetL) && (elem->GetType() < TStreamerInfo::kOffsetP) && \
2011  (elem->GetArrayLength() != n)) \
2012  fExpectedChain = kTRUE; \
2013  if (fExpectedChain) { \
2014  fExpectedChain = kFALSE; \
2015  Int_t startnumber = Stack(0)->fElemNumber; \
2016  TStreamerInfo *info = Stack(1)->fInfo; \
2017  Int_t index = 0; \
2018  while (index < n) { \
2019  elem = (TStreamerElement *)info->GetElements()->At(startnumber++); \
2020  if (elem->GetType() < TStreamerInfo::kOffsetL) { \
2021  if (index > 0) { \
2022  PopStack(); \
2023  ShiftStack("chainreader"); \
2024  VerifyElemNode(elem); \
2025  } \
2026  fCanUseCompact = kTRUE; \
2027  XmlReadBasic(vname[index]); \
2028  index++; \
2029  } else { \
2030  if (!VerifyItemNode(xmlio::Array, "ReadFastArray")) \
2031  return; \
2032  PushStack(StackNode()); \
2033  Int_t elemlen = elem->GetArrayLength(); \
2034  TXMLReadArrayContent((vname + index), elemlen); \
2035  PopStack(); \
2036  ShiftStack("readfastarr"); \
2037  index += elemlen; \
2038  } \
2039  } \
2040  } else { \
2041  if (!VerifyItemNode(xmlio::Array, "ReadFastArray")) \
2042  return; \
2043  PushStack(StackNode()); \
2044  TXMLReadArrayContent(vname, n); \
2045  PopStack(); \
2046  ShiftStack("readfastarr"); \
2047  } \
2048  }
2049 
2050 ////////////////////////////////////////////////////////////////////////////////
2051 /// Read array of Bool_t from buffer
2052 
2054 {
2056 }
2057 
2058 ////////////////////////////////////////////////////////////////////////////////
2059 /// Read array of Char_t from buffer
2060 /// if nodename==CharStar, read all array as string
2061 
2063 {
2064  if ((n > 0) && VerifyItemNode(xmlio::CharStar)) {
2065  const char *buf;
2066  if ((buf = XmlReadValue(xmlio::CharStar))) {
2067  Int_t size = strlen(buf);
2068  if (size < n)
2069  size = n;
2070  memcpy(c, buf, size);
2071  }
2072  } else
2074 }
2075 
2076 ////////////////////////////////////////////////////////////////////////////////
2077 /// Read array of UChar_t from buffer
2078 
2080 {
2082 }
2083 
2084 ////////////////////////////////////////////////////////////////////////////////
2085 /// Read array of Short_t from buffer
2086 
2088 {
2090 }
2091 
2092 ////////////////////////////////////////////////////////////////////////////////
2093 /// Read array of UShort_t from buffer
2094 
2096 {
2098 }
2099 
2100 ////////////////////////////////////////////////////////////////////////////////
2101 /// Read array of Int_t from buffer
2102 
2104 {
2106 }
2107 
2108 ////////////////////////////////////////////////////////////////////////////////
2109 /// Read array of UInt_t from buffer
2110 
2112 {
2114 }
2115 
2116 ////////////////////////////////////////////////////////////////////////////////
2117 /// Read array of Long_t from buffer
2118 
2120 {
2122 }
2123 
2124 ////////////////////////////////////////////////////////////////////////////////
2125 /// Read array of ULong_t from buffer
2126 
2128 {
2130 }
2131 
2132 ////////////////////////////////////////////////////////////////////////////////
2133 /// Read array of Long64_t from buffer
2134 
2136 {
2138 }
2139 
2140 ////////////////////////////////////////////////////////////////////////////////
2141 /// Read array of ULong64_t from buffer
2142 
2144 {
2146 }
2147 
2148 ////////////////////////////////////////////////////////////////////////////////
2149 /// Read array of Float_t from buffer
2150 
2152 {
2154 }
2155 
2156 ////////////////////////////////////////////////////////////////////////////////
2157 /// Read array of Double_t from buffer
2158 
2160 {
2162 }
2163 
2164 ////////////////////////////////////////////////////////////////////////////////
2165 /// Read array of Float16_t from buffer
2166 
2168 {
2170 }
2171 
2172 ////////////////////////////////////////////////////////////////////////////////
2173 /// Read array of Float16_t from buffer
2174 
2175 void TBufferXML::ReadFastArrayWithFactor(Float_t *f, Int_t n, Double_t /* factor */, Double_t /* minvalue */)
2176 {
2178 }
2179 
2180 ////////////////////////////////////////////////////////////////////////////////
2181 /// Read array of Float16_t from buffer
2182 
2184 {
2186 }
2187 
2188 ////////////////////////////////////////////////////////////////////////////////
2189 /// Read array of Double32_t from buffer
2190 
2192 {
2194 }
2195 
2196 ////////////////////////////////////////////////////////////////////////////////
2197 /// Read array of Double32_t from buffer
2198 
2199 void TBufferXML::ReadFastArrayWithFactor(Double_t *d, Int_t n, Double_t /* factor */, Double_t /* minvalue */)
2200 {
2202 }
2203 
2204 ////////////////////////////////////////////////////////////////////////////////
2205 /// Read array of Double32_t from buffer
2206 
2208 {
2210 }
2211 
2212 ////////////////////////////////////////////////////////////////////////////////
2213 /// redefined here to avoid warning message from gcc
2214 
2215 void TBufferXML::ReadFastArray(void *start, const TClass *cl, Int_t n, TMemberStreamer *s, const TClass *onFileClass)
2216 {
2217  TBufferFile::ReadFastArray(start, cl, n, s, onFileClass);
2218 }
2219 
2220 ////////////////////////////////////////////////////////////////////////////////
2221 /// redefined here to avoid warning message from gcc
2222 
2223 void TBufferXML::ReadFastArray(void **startp, const TClass *cl, Int_t n, Bool_t isPreAlloc, TMemberStreamer *s,
2224  const TClass *onFileClass)
2225 {
2226  TBufferFile::ReadFastArray(startp, cl, n, isPreAlloc, s, onFileClass);
2227 }
2228 
2229 // macro to write content of noncompressed array
2230 #define TXMLWriteArrayNoncompress(vname, arrsize) \
2231  { \
2232  for (Int_t indx = 0; indx < arrsize; indx++) \
2233  XmlWriteBasic(vname[indx]); \
2234  }
2235 
2236 // macro to write content of compressed array
2237 #define TXMLWriteArrayCompress(vname, arrsize) \
2238  { \
2239  Int_t indx = 0; \
2240  while (indx < arrsize) { \
2241  XMLNodePointer_t elemnode = XmlWriteBasic(vname[indx]); \
2242  Int_t curr = indx; \
2243  indx++; \
2244  while ((indx < arrsize) && (vname[indx] == vname[curr])) \
2245  indx++; \
2246  if (indx - curr > 1) \
2247  fXML->NewIntAttr(elemnode, xmlio::cnt, indx - curr); \
2248  } \
2249  }
2250 
2251 #define TXMLWriteArrayContent(vname, arrsize) \
2252  { \
2253  if (fCompressLevel > 0) { \
2254  TXMLWriteArrayCompress(vname, arrsize) \
2255  } else { \
2256  TXMLWriteArrayNoncompress(vname, arrsize) \
2257  } \
2258  }
2259 
2260 // macro to write array, which include size
2261 #define TBufferXML_WriteArray(vname) \
2262  { \
2263  BeforeIOoperation(); \
2264  XMLNodePointer_t arrnode = CreateItemNode(xmlio::Array); \
2265  fXML->NewIntAttr(arrnode, xmlio::Size, n); \
2266  PushStack(arrnode); \
2267  TXMLWriteArrayContent(vname, n); \
2268  PopStack(); \
2269  }
2270 
2271 ////////////////////////////////////////////////////////////////////////////////
2272 /// Write array of Bool_t to buffer
2273 
2275 {
2277 }
2278 
2279 ////////////////////////////////////////////////////////////////////////////////
2280 /// Write array of Char_t to buffer
2281 
2283 {
2285 }
2286 
2287 ////////////////////////////////////////////////////////////////////////////////
2288 /// Write array of UChar_t to buffer
2289 
2291 {
2293 }
2294 
2295 ////////////////////////////////////////////////////////////////////////////////
2296 /// Write array of Short_t to buffer
2297 
2299 {
2301 }
2302 
2303 ////////////////////////////////////////////////////////////////////////////////
2304 /// Write array of UShort_t to buffer
2305 
2307 {
2309 }
2310 
2311 ////////////////////////////////////////////////////////////////////////////////
2312 /// Write array of Int_ to buffer
2313 
2315 {
2317 }
2318 
2319 ////////////////////////////////////////////////////////////////////////////////
2320 /// Write array of UInt_t to buffer
2321 
2323 {
2325 }
2326 
2327 ////////////////////////////////////////////////////////////////////////////////
2328 /// Write array of Long_t to buffer
2329 
2331 {
2333 }
2334 
2335 ////////////////////////////////////////////////////////////////////////////////
2336 /// Write array of ULong_t to buffer
2337 
2339 {
2341 }
2342 
2343 ////////////////////////////////////////////////////////////////////////////////
2344 /// Write array of Long64_t to buffer
2345 
2347 {
2349 }
2350 
2351 ////////////////////////////////////////////////////////////////////////////////
2352 /// Write array of ULong64_t to buffer
2353 
2355 {
2357 }
2358 
2359 ////////////////////////////////////////////////////////////////////////////////
2360 /// Write array of Float_t to buffer
2361 
2363 {
2365 }
2366 
2367 ////////////////////////////////////////////////////////////////////////////////
2368 /// Write array of Double_t to buffer
2369 
2371 {
2373 }
2374 
2375 ////////////////////////////////////////////////////////////////////////////////
2376 /// Write array of Float16_t to buffer
2377 
2379 {
2381 }
2382 
2383 ////////////////////////////////////////////////////////////////////////////////
2384 /// Write array of Double32_t to buffer
2385 
2387 {
2389 }
2390 
2391 // write array without size attribute
2392 // macro also treat situation, when instead of one single array
2393 // chain of several elements should be produced
2394 #define TBufferXML_WriteFastArray(vname) \
2395  { \
2396  BeforeIOoperation(); \
2397  if (n <= 0) \
2398  return; \
2399  TStreamerElement *elem = Stack(0)->fElem; \
2400  if ((elem != 0) && (elem->GetType() > TStreamerInfo::kOffsetL) && (elem->GetType() < TStreamerInfo::kOffsetP) && \
2401  (elem->GetArrayLength() != n)) \
2402  fExpectedChain = kTRUE; \
2403  if (fExpectedChain) { \
2404  TStreamerInfo *info = Stack(1)->fInfo; \
2405  Int_t startnumber = Stack(0)->fElemNumber; \
2406  fExpectedChain = kFALSE; \
2407  Int_t index = 0; \
2408  while (index < n) { \
2409  elem = (TStreamerElement *)info->GetElements()->At(startnumber++); \
2410  if (elem->GetType() < TStreamerInfo::kOffsetL) { \
2411  if (index > 0) { \
2412  PopStack(); \
2413  CreateElemNode(elem); \
2414  } \
2415  fCanUseCompact = kTRUE; \
2416  XmlWriteBasic(vname[index]); \
2417  index++; \
2418  } else { \
2419  XMLNodePointer_t arrnode = CreateItemNode(xmlio::Array); \
2420  Int_t elemlen = elem->GetArrayLength(); \
2421  PushStack(arrnode); \
2422  TXMLWriteArrayContent((vname + index), elemlen); \
2423  index += elemlen; \
2424  PopStack(); \
2425  } \
2426  } \
2427  } else { \
2428  XMLNodePointer_t arrnode = CreateItemNode(xmlio::Array); \
2429  PushStack(arrnode); \
2430  TXMLWriteArrayContent(vname, n); \
2431  PopStack(); \
2432  } \
2433  }
2434 
2435 ////////////////////////////////////////////////////////////////////////////////
2436 /// Write array of Bool_t to buffer
2437 
2439 {
2441 }
2442 
2443 ////////////////////////////////////////////////////////////////////////////////
2444 /// Write array of Char_t to buffer
2445 /// If array does not include any special characters,
2446 /// it will be reproduced as CharStar node with string as attribute
2447 
2449 {
2450  Bool_t usedefault = (n == 0) || fExpectedChain;
2451  const Char_t *buf = c;
2452  if (!usedefault)
2453  for (int i = 0; i < n; i++) {
2454  if (*buf < 27) {
2455  usedefault = kTRUE;
2456  break;
2457  }
2458  buf++;
2459  }
2460  if (usedefault) {
2462  } else {
2463  Char_t *buf2 = new Char_t[n + 1];
2464  memcpy(buf2, c, n);
2465  buf2[n] = 0;
2467  delete[] buf2;
2468  }
2469 }
2470 
2471 ////////////////////////////////////////////////////////////////////////////////
2472 /// Write array of UChar_t to buffer
2473 
2475 {
2477 }
2478 
2479 ////////////////////////////////////////////////////////////////////////////////
2480 /// Write array of Short_t to buffer
2481 
2483 {
2485 }
2486 
2487 ////////////////////////////////////////////////////////////////////////////////
2488 /// Write array of UShort_t to buffer
2489 
2491 {
2493 }
2494 
2495 ////////////////////////////////////////////////////////////////////////////////
2496 /// Write array of Int_t to buffer
2497 
2499 {
2501 }
2502 
2503 ////////////////////////////////////////////////////////////////////////////////
2504 /// Write array of UInt_t to buffer
2505 
2507 {
2509 }
2510 
2511 ////////////////////////////////////////////////////////////////////////////////
2512 /// Write array of Long_t to buffer
2513 
2515 {
2517 }
2518 
2519 ////////////////////////////////////////////////////////////////////////////////
2520 /// Write array of ULong_t to buffer
2521 
2523 {
2525 }
2526 
2527 ////////////////////////////////////////////////////////////////////////////////
2528 /// Write array of Long64_t to buffer
2529 
2531 {
2533 }
2534 
2535 ////////////////////////////////////////////////////////////////////////////////
2536 /// Write array of ULong64_t to buffer
2537 
2539 {
2541 }
2542 
2543 ////////////////////////////////////////////////////////////////////////////////
2544 /// Write array of Float_t to buffer
2545 
2547 {
2549 }
2550 
2551 ////////////////////////////////////////////////////////////////////////////////
2552 /// Write array of Double_t to buffer
2553 
2555 {
2557 }
2558 
2559 ////////////////////////////////////////////////////////////////////////////////
2560 /// Write array of Float16_t to buffer
2561 
2563 {
2565 }
2566 
2567 ////////////////////////////////////////////////////////////////////////////////
2568 /// Write array of Double32_t to buffer
2569 
2571 {
2573 }
2574 
2575 ////////////////////////////////////////////////////////////////////////////////
2576 /// Recall TBuffer function to avoid gcc warning message
2577 
2579 {
2580  TBufferFile::WriteFastArray(start, cl, n, s);
2581 }
2582 
2583 ////////////////////////////////////////////////////////////////////////////////
2584 /// Recall TBuffer function to avoid gcc warning message
2585 
2586 Int_t TBufferXML::WriteFastArray(void **startp, const TClass *cl, Int_t n, Bool_t isPreAlloc, TMemberStreamer *s)
2587 {
2588  return TBufferFile::WriteFastArray(startp, cl, n, isPreAlloc, s);
2589 }
2590 
2591 ////////////////////////////////////////////////////////////////////////////////
2592 /// steram object to/from buffer
2593 
2594 void TBufferXML::StreamObject(void *obj, const std::type_info &typeinfo, const TClass * /* onFileClass */)
2595 {
2596  StreamObject(obj, TClass::GetClass(typeinfo));
2597 }
2598 
2599 ////////////////////////////////////////////////////////////////////////////////
2600 /// steram object to/from buffer
2601 
2602 void TBufferXML::StreamObject(void *obj, const char *className, const TClass * /* onFileClass */)
2603 {
2604  StreamObject(obj, TClass::GetClass(className));
2605 }
2606 
2608 {
2609  // steram object to/from buffer
2610 
2611  StreamObject(obj, obj ? obj->IsA() : TObject::Class());
2612 }
2613 
2614 ////////////////////////////////////////////////////////////////////////////////
2615 /// Steram object to/from buffer
2616 
2617 void TBufferXML::StreamObject(void *obj, const TClass *cl, const TClass * /* onfileClass */)
2618 {
2620  if (gDebug > 1)
2621  Info("StreamObject", "Class: %s", (cl ? cl->GetName() : "none"));
2622  if (IsReading())
2623  XmlReadObject(obj);
2624  else
2625  XmlWriteObject(obj, cl, kTRUE);
2626 }
2627 
2628 // macro for right shift operator for basic type
2629 #define TBufferXML_operatorin(vname) \
2630  { \
2631  BeforeIOoperation(); \
2632  XmlReadBasic(vname); \
2633  }
2634 
2635 ////////////////////////////////////////////////////////////////////////////////
2636 /// Reads Bool_t value from buffer
2637 
2639 {
2641 }
2642 
2643 ////////////////////////////////////////////////////////////////////////////////
2644 /// Reads Char_t value from buffer
2645 
2647 {
2649 }
2650 
2651 ////////////////////////////////////////////////////////////////////////////////
2652 /// Reads UChar_t value from buffer
2653 
2655 {
2657 }
2658 
2659 ////////////////////////////////////////////////////////////////////////////////
2660 /// Reads Short_t value from buffer
2661 
2663 {
2665 }
2666 
2667 ////////////////////////////////////////////////////////////////////////////////
2668 /// Reads UShort_t value from buffer
2669 
2671 {
2673 }
2674 
2675 ////////////////////////////////////////////////////////////////////////////////
2676 /// Reads Int_t value from buffer
2677 
2679 {
2681 }
2682 
2683 ////////////////////////////////////////////////////////////////////////////////
2684 /// Reads UInt_t value from buffer
2685 
2687 {
2689 }
2690 
2691 ////////////////////////////////////////////////////////////////////////////////
2692 /// Reads Long_t value from buffer
2693 
2695 {
2697 }
2698 
2699 ////////////////////////////////////////////////////////////////////////////////
2700 /// Reads ULong_t value from buffer
2701 
2703 {
2705 }
2706 
2707 ////////////////////////////////////////////////////////////////////////////////
2708 /// Reads Long64_t value from buffer
2709 
2711 {
2713 }
2714 
2715 ////////////////////////////////////////////////////////////////////////////////
2716 /// Reads ULong64_t value from buffer
2717 
2719 {
2721 }
2722 
2723 ////////////////////////////////////////////////////////////////////////////////
2724 /// Reads Float_t value from buffer
2725 
2727 {
2729 }
2730 
2731 ////////////////////////////////////////////////////////////////////////////////
2732 /// Reads Double_t value from buffer
2733 
2735 {
2737 }
2738 
2739 ////////////////////////////////////////////////////////////////////////////////
2740 /// Reads array of characters from buffer
2741 
2743 {
2745  const char *buf;
2746  if ((buf = XmlReadValue(xmlio::CharStar)))
2747  strcpy(c, buf);
2748 }
2749 
2750 ////////////////////////////////////////////////////////////////////////////////
2751 /// Reads a TString
2752 
2754 {
2755  if (GetIOVersion() < 3) {
2757  } else {
2759  const char *buf;
2760  if ((buf = XmlReadValue(xmlio::String)))
2761  s = buf;
2762  }
2763 }
2764 
2765 ////////////////////////////////////////////////////////////////////////////////
2766 /// Reads a std::string
2767 
2768 void TBufferXML::ReadStdString(std::string *s)
2769 {
2770  if (GetIOVersion() < 3) {
2772  } else {
2774  const char *buf;
2775  if ((buf = XmlReadValue(xmlio::String)))
2776  if (s)
2777  *s = buf;
2778  }
2779 }
2780 
2781 ////////////////////////////////////////////////////////////////////////////////
2782 /// Read a char* string
2783 
2785 {
2787 }
2788 
2789 // macro for left shift operator for basic types
2790 #define TBufferXML_operatorout(vname) \
2791  { \
2792  BeforeIOoperation(); \
2793  XmlWriteBasic(vname); \
2794  }
2795 
2796 ////////////////////////////////////////////////////////////////////////////////
2797 /// Writes Bool_t value to buffer
2798 
2800 {
2802 }
2803 
2804 ////////////////////////////////////////////////////////////////////////////////
2805 /// Writes Char_t value to buffer
2806 
2808 {
2810 }
2811 
2812 ////////////////////////////////////////////////////////////////////////////////
2813 /// Writes UChar_t value to buffer
2814 
2816 {
2818 }
2819 
2820 ////////////////////////////////////////////////////////////////////////////////
2821 /// Writes Short_t value to buffer
2822 
2824 {
2826 }
2827 
2828 ////////////////////////////////////////////////////////////////////////////////
2829 /// Writes UShort_t value to buffer
2830 
2832 {
2834 }
2835 
2836 ////////////////////////////////////////////////////////////////////////////////
2837 /// Writes Int_t value to buffer
2838 
2840 {
2842 }
2843 
2844 ////////////////////////////////////////////////////////////////////////////////
2845 /// Writes UInt_t value to buffer
2846 
2848 {
2850 }
2851 
2852 ////////////////////////////////////////////////////////////////////////////////
2853 /// Writes Long_t value to buffer
2854 
2856 {
2858 }
2859 
2860 ////////////////////////////////////////////////////////////////////////////////
2861 /// Writes ULong_t value to buffer
2862 
2864 {
2866 }
2867 
2868 ////////////////////////////////////////////////////////////////////////////////
2869 /// Writes Long64_t value to buffer
2870 
2872 {
2874 }
2875 
2876 ////////////////////////////////////////////////////////////////////////////////
2877 /// Writes ULong64_t value to buffer
2878 
2880 {
2882 }
2883 
2884 ////////////////////////////////////////////////////////////////////////////////
2885 /// Writes Float_t value to buffer
2886 
2888 {
2890 }
2891 
2892 ////////////////////////////////////////////////////////////////////////////////
2893 /// Writes Double_t value to buffer
2894 
2896 {
2898 }
2899 
2900 ////////////////////////////////////////////////////////////////////////////////
2901 /// Writes array of characters to buffer
2902 
2904 {
2907 }
2908 
2909 ////////////////////////////////////////////////////////////////////////////////
2910 /// Writes a TString
2911 
2913 {
2914  if (GetIOVersion() < 3) {
2916  } else {
2919  }
2920 }
2921 
2922 ////////////////////////////////////////////////////////////////////////////////
2923 /// Writes a TString
2924 
2925 void TBufferXML::WriteStdString(const std::string *s)
2926 {
2927  if (GetIOVersion() < 3) {
2929  } else {
2931  if (s)
2932  XmlWriteValue(s->c_str(), xmlio::String);
2933  else
2935  }
2936 }
2937 
2938 ////////////////////////////////////////////////////////////////////////////////
2939 /// Write a char* string
2940 
2942 {
2944 }
2945 
2946 ////////////////////////////////////////////////////////////////////////////////
2947 /// Converts Char_t to string and add xml node to buffer
2948 
2950 {
2951  char buf[50];
2952  snprintf(buf, sizeof(buf), "%d", value);
2953  return XmlWriteValue(buf, xmlio::Char);
2954 }
2955 
2956 ////////////////////////////////////////////////////////////////////////////////
2957 /// Converts Short_t to string and add xml node to buffer
2958 
2960 {
2961  char buf[50];
2962  snprintf(buf, sizeof(buf), "%hd", value);
2963  return XmlWriteValue(buf, xmlio::Short);
2964 }
2965 
2966 ////////////////////////////////////////////////////////////////////////////////
2967 /// Converts Int_t to string and add xml node to buffer
2968 
2970 {
2971  char buf[50];
2972  snprintf(buf, sizeof(buf), "%d", value);
2973  return XmlWriteValue(buf, xmlio::Int);
2974 }
2975 
2976 ////////////////////////////////////////////////////////////////////////////////
2977 /// Converts Long_t to string and add xml node to buffer
2978 
2980 {
2981  char buf[50];
2982  snprintf(buf, sizeof(buf), "%ld", value);
2983  return XmlWriteValue(buf, xmlio::Long);
2984 }
2985 
2986 ////////////////////////////////////////////////////////////////////////////////
2987 /// Converts Long64_t to string and add xml node to buffer
2988 
2990 {
2991  char buf[50];
2992  snprintf(buf, sizeof(buf), FLong64, value);
2993  return XmlWriteValue(buf, xmlio::Long64);
2994 }
2995 
2996 ////////////////////////////////////////////////////////////////////////////////
2997 /// Converts Float_t to string and add xml node to buffer
2998 
3000 {
3001  char buf[200];
3002  snprintf(buf, sizeof(buf), fgFloatFmt.c_str(), value);
3003  return XmlWriteValue(buf, xmlio::Float);
3004 }
3005 
3006 ////////////////////////////////////////////////////////////////////////////////
3007 /// Converts Double_t to string and add xml node to buffer
3008 
3010 {
3011  char buf[1000];
3012  snprintf(buf, sizeof(buf), fgFloatFmt.c_str(), value);
3013  return XmlWriteValue(buf, xmlio::Double);
3014 }
3015 
3016 ////////////////////////////////////////////////////////////////////////////////
3017 /// Converts Bool_t to string and add xml node to buffer
3018 
3020 {
3022 }
3023 
3024 ////////////////////////////////////////////////////////////////////////////////
3025 /// Converts UChar_t to string and add xml node to buffer
3026 
3028 {
3029  char buf[50];
3030  snprintf(buf, sizeof(buf), "%u", value);
3031  return XmlWriteValue(buf, xmlio::UChar);
3032 }
3033 
3034 ////////////////////////////////////////////////////////////////////////////////
3035 /// Converts UShort_t to string and add xml node to buffer
3036 
3038 {
3039  char buf[50];
3040  snprintf(buf, sizeof(buf), "%hu", value);
3041  return XmlWriteValue(buf, xmlio::UShort);
3042 }
3043 
3044 ////////////////////////////////////////////////////////////////////////////////
3045 /// Converts UInt_t to string and add xml node to buffer
3046 
3048 {
3049  char buf[50];
3050  snprintf(buf, sizeof(buf), "%u", value);
3051  return XmlWriteValue(buf, xmlio::UInt);
3052 }
3053 
3054 ////////////////////////////////////////////////////////////////////////////////
3055 /// Converts ULong_t to string and add xml node to buffer
3056 
3058 {
3059  char buf[50];
3060  snprintf(buf, sizeof(buf), "%lu", value);
3061  return XmlWriteValue(buf, xmlio::ULong);
3062 }
3063 
3064 ////////////////////////////////////////////////////////////////////////////////
3065 /// Converts ULong64_t to string and add xml node to buffer
3066 
3068 {
3069  char buf[50];
3070  snprintf(buf, sizeof(buf), FULong64, value);
3071  return XmlWriteValue(buf, xmlio::ULong64);
3072 }
3073 
3074 ////////////////////////////////////////////////////////////////////////////////
3075 /// Create xml node with specified name and adds it to stack node
3076 
3077 XMLNodePointer_t TBufferXML::XmlWriteValue(const char *value, const char *name)
3078 {
3079  XMLNodePointer_t node = 0;
3080 
3081  if (fCanUseCompact)
3082  node = StackNode();
3083  else
3084  node = CreateItemNode(name);
3085 
3086  fXML->NewAttr(node, 0, xmlio::v, value);
3087 
3089 
3090  return node;
3091 }
3092 
3093 ////////////////////////////////////////////////////////////////////////////////
3094 /// Reads string from current xml node and convert it to Char_t value
3095 
3097 {
3098  const char *res = XmlReadValue(xmlio::Char);
3099  if (res) {
3100  int n;
3101  sscanf(res, "%d", &n);
3102  value = n;
3103  } else
3104  value = 0;
3105 }
3106 
3107 ////////////////////////////////////////////////////////////////////////////////
3108 /// Reads string from current xml node and convert it to Short_t value
3109 
3111 {
3112  const char *res = XmlReadValue(xmlio::Short);
3113  if (res)
3114  sscanf(res, "%hd", &value);
3115  else
3116  value = 0;
3117 }
3118 
3119 ////////////////////////////////////////////////////////////////////////////////
3120 /// Reads string from current xml node and convert it to Int_t value
3121 
3123 {
3124  const char *res = XmlReadValue(xmlio::Int);
3125  if (res)
3126  sscanf(res, "%d", &value);
3127  else
3128  value = 0;
3129 }
3130 
3131 ////////////////////////////////////////////////////////////////////////////////
3132 /// Reads string from current xml node and convert it to Long_t value
3133 
3135 {
3136  const char *res = XmlReadValue(xmlio::Long);
3137  if (res)
3138  sscanf(res, "%ld", &value);
3139  else
3140  value = 0;
3141 }
3142 
3143 ////////////////////////////////////////////////////////////////////////////////
3144 /// Reads string from current xml node and convert it to Long64_t value
3145 
3147 {
3148  const char *res = XmlReadValue(xmlio::Long64);
3149  if (res)
3150  sscanf(res, FLong64, &value);
3151  else
3152  value = 0;
3153 }
3154 
3155 ////////////////////////////////////////////////////////////////////////////////
3156 /// Reads string from current xml node and convert it to Float_t value
3157 
3159 {
3160  const char *res = XmlReadValue(xmlio::Float);
3161  if (res)
3162  sscanf(res, "%f", &value);
3163  else
3164  value = 0.;
3165 }
3166 
3167 ////////////////////////////////////////////////////////////////////////////////
3168 /// Reads string from current xml node and convert it to Double_t value
3169 
3171 {
3172  const char *res = XmlReadValue(xmlio::Double);
3173  if (res)
3174  sscanf(res, "%lf", &value);
3175  else
3176  value = 0.;
3177 }
3178 
3179 ////////////////////////////////////////////////////////////////////////////////
3180 /// Reads string from current xml node and convert it to Bool_t value
3181 
3183 {
3184  const char *res = XmlReadValue(xmlio::Bool);
3185  if (res)
3186  value = (strcmp(res, xmlio::True) == 0);
3187  else
3188  value = kFALSE;
3189 }
3190 
3191 ////////////////////////////////////////////////////////////////////////////////
3192 /// Reads string from current xml node and convert it to UChar_t value
3193 
3195 {
3196  const char *res = XmlReadValue(xmlio::UChar);
3197  if (res) {
3198  unsigned int n;
3199  sscanf(res, "%ud", &n);
3200  value = n;
3201  } else
3202  value = 0;
3203 }
3204 
3205 ////////////////////////////////////////////////////////////////////////////////
3206 /// Reads string from current xml node and convert it to UShort_t value
3207 
3209 {
3210  const char *res = XmlReadValue(xmlio::UShort);
3211  if (res)
3212  sscanf(res, "%hud", &value);
3213  else
3214  value = 0;
3215 }
3216 
3217 ////////////////////////////////////////////////////////////////////////////////
3218 /// Reads string from current xml node and convert it to UInt_t value
3219 
3221 {
3222  const char *res = XmlReadValue(xmlio::UInt);
3223  if (res)
3224  sscanf(res, "%u", &value);
3225  else
3226  value = 0;
3227 }
3228 
3229 ////////////////////////////////////////////////////////////////////////////////
3230 /// Reads string from current xml node and convert it to ULong_t value
3231 
3233 {
3234  const char *res = XmlReadValue(xmlio::ULong);
3235  if (res)
3236  sscanf(res, "%lu", &value);
3237  else
3238  value = 0;
3239 }
3240 
3241 ////////////////////////////////////////////////////////////////////////////////
3242 /// Reads string from current xml node and convert it to ULong64_t value
3243 
3245 {
3246  const char *res = XmlReadValue(xmlio::ULong64);
3247  if (res)
3248  sscanf(res, FULong64, &value);
3249  else
3250  value = 0;
3251 }
3252 
3253 ////////////////////////////////////////////////////////////////////////////////
3254 /// read string value from current stack node
3255 
3256 const char *TBufferXML::XmlReadValue(const char *name)
3257 {
3258  if (fErrorFlag > 0)
3259  return 0;
3260 
3261  Bool_t trysimple = fCanUseCompact;
3263 
3264  if (trysimple) {
3265  if (fXML->HasAttr(Stack(1)->fNode, xmlio::v))
3266  fValueBuf = fXML->GetAttr(Stack(1)->fNode, xmlio::v);
3267  else
3268  trysimple = kFALSE;
3269  }
3270 
3271  if (!trysimple) {
3272  if (!VerifyItemNode(name, "XmlReadValue"))
3273  return 0;
3275  }
3276 
3277  if (gDebug > 4)
3278  Info("XmlReadValue", " Name = %s value = %s", name, fValueBuf.Data());
3279 
3280  if (!trysimple)
3281  ShiftStack("readvalue");
3282 
3283  return fValueBuf.Data();
3284 }
3285 
3286 void TBufferXML::SetFloatFormat(const char *fmt)
3287 {
3288  // Set printf format for float/double members, default "%e"
3289  // This method is not thread-safe as it changes a global state.
3290 
3291  if (!fmt)
3292  fgFloatFmt = "%e";
3293  fgFloatFmt = fmt;
3294 }
3295 
3297 {
3298  // return current printf format for float/double members, default "%e"
3299 
3300  return fgFloatFmt.c_str();
3301 }
3302 
3303 ////////////////////////////////////////////////////////////////////////////////
3304 /// Read one collection of objects from the buffer using the StreamerInfoLoopAction.
3305 /// The collection needs to be a split TClonesArray or a split vector of pointers.
3306 
3308 {
3309  TVirtualStreamerInfo *info = sequence.fStreamerInfo;
3310  IncrementLevel(info);
3311 
3312  if (gDebug) {
3313  // loop on all active members
3314  TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.fActions.end();
3315  for (TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.fActions.begin(); iter != end;
3316  ++iter) {
3317  // Idea: Try to remove this function call as it is really needed only for XML streaming.
3318  SetStreamerElementNumber((*iter).fConfiguration->fCompInfo->fElem, (*iter).fConfiguration->fCompInfo->fType);
3319  (*iter).PrintDebug(*this, obj);
3320  (*iter)(*this, obj);
3321  }
3322 
3323  } else {
3324  // loop on all active members
3325  TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.fActions.end();
3326  for (TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.fActions.begin(); iter != end;
3327  ++iter) {
3328  // Idea: Try to remove this function call as it is really needed only for XML streaming.
3329  SetStreamerElementNumber((*iter).fConfiguration->fCompInfo->fElem, (*iter).fConfiguration->fCompInfo->fType);
3330  (*iter)(*this, obj);
3331  }
3332  }
3333 
3334  DecrementLevel(info);
3335  return 0;
3336 }
3337 
3338 ////////////////////////////////////////////////////////////////////////////////
3339 /// Read one collection of objects from the buffer using the StreamerInfoLoopAction.
3340 /// The collection needs to be a split TClonesArray or a split vector of pointers.
3341 
3343  void *end_collection)
3344 {
3345  TVirtualStreamerInfo *info = sequence.fStreamerInfo;
3346  IncrementLevel(info);
3347 
3348  if (gDebug) {
3349  // loop on all active members
3350  TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.fActions.end();
3351  for (TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.fActions.begin(); iter != end;
3352  ++iter) {
3353  // Idea: Try to remove this function call as it is really needed only for XML streaming.
3354  SetStreamerElementNumber((*iter).fConfiguration->fCompInfo->fElem, (*iter).fConfiguration->fCompInfo->fType);
3355  (*iter).PrintDebug(
3356  *this, *(char **)start_collection); // Warning: This limits us to TClonesArray and vector of pointers.
3357  (*iter)(*this, start_collection, end_collection);
3358  }
3359 
3360  } else {
3361  // loop on all active members
3362  TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.fActions.end();
3363  for (TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.fActions.begin(); iter != end;
3364  ++iter) {
3365  // Idea: Try to remove this function call as it is really needed only for XML streaming.
3366  SetStreamerElementNumber((*iter).fConfiguration->fCompInfo->fElem, (*iter).fConfiguration->fCompInfo->fType);
3367  (*iter)(*this, start_collection, end_collection);
3368  }
3369  }
3370 
3371  DecrementLevel(info);
3372  return 0;
3373 }
3374 
3375 ////////////////////////////////////////////////////////////////////////////////
3376 /// Read one collection of objects from the buffer using the StreamerInfoLoopAction.
3377 
3379  void *end_collection)
3380 {
3381  TVirtualStreamerInfo *info = sequence.fStreamerInfo;
3382  IncrementLevel(info);
3383 
3385  if (gDebug) {
3386 
3387  // Get the address of the first item for the PrintDebug.
3388  // (Performance is not essential here since we are going to print to
3389  // the screen anyway).
3390  void *arr0 = loopconfig->GetFirstAddress(start_collection, end_collection);
3391  // loop on all active members
3392  TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.fActions.end();
3393  for (TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.fActions.begin(); iter != end;
3394  ++iter) {
3395  // Idea: Try to remove this function call as it is really needed only for XML streaming.
3396  SetStreamerElementNumber((*iter).fConfiguration->fCompInfo->fElem, (*iter).fConfiguration->fCompInfo->fType);
3397  (*iter).PrintDebug(*this, arr0);
3398  (*iter)(*this, start_collection, end_collection, loopconfig);
3399  }
3400 
3401  } else {
3402  // loop on all active members
3403  TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.fActions.end();
3404  for (TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.fActions.begin(); iter != end;
3405  ++iter) {
3406  // Idea: Try to remove this function call as it is really needed only for XML streaming.
3407  SetStreamerElementNumber((*iter).fConfiguration->fCompInfo->fElem, (*iter).fConfiguration->fCompInfo->fType);
3408  (*iter)(*this, start_collection, end_collection, loopconfig);
3409  }
3410  }
3411 
3412  DecrementLevel(info);
3413  return 0;
3414 }
Int_t fCompressLevel
! Compression level and algorithm
Definition: TBufferXML.h:338
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:716
virtual Int_t ApplySequenceVecPtr(const TStreamerInfoActions::TActionSequence &sequence, void *start_collection, void *end_collection)
Read one collection of objects from the buffer using the StreamerInfoLoopAction.
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
const char * Object
Definition: TXMLSetup.cxx:61
#define TBufferXML_operatorin(vname)
virtual ~TBufferXML()
Destroy xml buffer.
Definition: TBufferXML.cxx:111
#define TBufferXML_operatorout(vname)
void XmlReadBlock(XMLNodePointer_t node)
Read binary block of data from xml.
Definition: TBufferXML.cxx:470
Bool_t IsReading() const
Definition: TBuffer.h:83
const char * Long64
Definition: TXMLSetup.cxx:85
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:300
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
virtual Int_t ReadStaticArrayFloat16(Float_t *f, TStreamerElement *ele=0)
Read array of Float16_t from buffer.
Bool_t IsWriting() const
Definition: TBuffer.h:84
An array of TObjects.
Definition: TObjArray.h:37
Int_t GetCompressionSettings() const
Definition: TBufferXML.h:360
#define FULong64
Definition: TBufferXML.cxx:52
virtual void ReadFloat16(Float_t *f, TStreamerElement *ele=0)
Read a Float16_t from the buffer.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition: TObject.cxx:854
const char * Ref
Definition: TXMLSetup.cxx:52
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket...
Definition: TBufferFile.h:47
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:362
virtual void ReadFastArrayDouble32(Double_t *d, Int_t n, TStreamerElement *ele=0)
Read array of Double32_t from buffer.
long long Long64_t
Definition: RtypesCore.h:69
void WorkWithElement(TStreamerElement *elem, Int_t comp_type)
This function is a part of SetStreamerElementNumber method.
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:409
void FreeAttr(XMLNodePointer_t xmlnode, const char *name)
remove attribute from xmlnode
Definition: TXMLEngine.cxx:614
virtual void ReadWithFactor(Float_t *ptr, Double_t factor, Double_t minvalue)
Read a Double32_t from the buffer when the factor and minimun value have been specified see comments ...
const char * Double
Definition: TXMLSetup.cxx:87
virtual void ReadLong(Long_t &l)
Reads Long_t value from buffer.
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
Definition: TBufferXML.h:331
virtual TClass * GetClass() const =0
TLoopConfiguration * fLoopConfig
If this is a bundle of memberwise streaming action, this configures the looping.
static void * ConvertFromXMLAny(const char *str, TClass **cl=0, Bool_t GenericLayout=kFALSE, Bool_t UseNamespaces=kFALSE)
Read object of any class from XML, produced by ConvertToXML() method.
Definition: TBufferXML.cxx:206
float Float_t
Definition: RtypesCore.h:53
virtual void WriteLong(Long_t l)
Writes Long_t value to buffer.
virtual void Delete(Option_t *option="")
Remove all objects from the array AND delete all heap based objects.
Definition: TObjArray.cxx:355
void SetCompressionSettings(Int_t settings=1)
Used to specify the compression level and algorithm.
Definition: TBufferXML.cxx:400
void SetCompressionLevel(Int_t level=1)
See comments for function SetCompressionSettings.
Definition: TBufferXML.cxx:378
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
const char * v
Definition: TXMLSetup.cxx:73
#define TBufferXML_WriteArray(vname)
virtual void ReadTString(TString &s)
Read TString from TBuffer.
unsigned short UShort_t
Definition: RtypesCore.h:36
virtual void ClassMember(const char *name, const char *typeName=0, 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 TClass * GetClassPointer() const
Returns a pointer to the TClass of this element.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
TH1 * h
Definition: legend2.C:5
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.
virtual void SkipVersion(const TClass *cl=0)
Skip class version from I/O buffer.
Version_t fVersionBuf
Definition: TBufferXML.h:326
#define gROOT
Definition: TROOT.h:402
virtual TObject * Remove(TObject *obj)
Remove object from array.
Definition: TObjArray.cxx:703
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)
Suppressed function of TBuffer.
virtual void WriteCharStar(char *s)
Write a char* string.
void RegisterPointer(const void *ptr, XMLNodePointer_t node)
Register pair of object pointer and node, where this object is saved, in object map.
Definition: TBufferXML.cxx:584
Basic string class.
Definition: TString.h:125
virtual Int_t ReadStaticArrayDouble32(Double_t *d, TStreamerElement *ele=0)
Read array of Double32_t from buffer.
virtual void WriteChar(Char_t c)
Writes Char_t value to buffer.
virtual void WriteCharStar(char *s)
Write char* into TBuffer.
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual TClass * ReadClass(const TClass *cl=0, UInt_t *objTag=0)
Function to read class from buffer, used in old-style streamers.
void SetParent(TObject *parent)
Set parent owning this buffer.
Definition: TBuffer.cxx:249
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:229
virtual void ReadFastArrayWithNbits(Float_t *ptr, Int_t n, Int_t nbits)
Read array of Float16_t from buffer.
const char * Item
Definition: TXMLSetup.cxx:65
virtual void SetArrayDim(Int_t dim)
Set number of array dimensions.
void CreateElemNode(const TStreamerElement *elem)
Create xml node correspondent to TStreamerElement object.
Definition: TBufferXML.cxx:743
TObject * At(Int_t idx) const
Definition: TObjArray.h:165
virtual void WriteTString(const TString &s)
Writes a TString.
const char * Class
Definition: TXMLSetup.cxx:63
virtual void WriteDouble32(Double_t *d, TStreamerElement *ele=0)
Write a Double32_t to the buffer.
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.
UInt_t Hash(ECaseCompare cmp=kExact) const
Return hash value.
Definition: TString.cxx:616
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:694
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
#define TBufferXML_WriteFastArray(vname)
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:797
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 TString.
TXMLEngine * fXML
Definition: TBufferXML.h:322
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:124
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=0)
Checks, that attribute of specified name exists and has specified value.
Definition: TBufferXML.cxx:690
TObject * Last() const
Return the object in the last filled slot. Returns 0 if no entries.
Definition: TObjArray.cxx:505
virtual void WriteShort(Short_t s)
Writes Short_t value to buffer.
TExMap * fObjMap
Definition: TBufferXML.h:328
virtual void ReadFastArrayFloat16(Float_t *f, Int_t n, TStreamerElement *ele=0)
Read array of Float16_t from buffer.
virtual void * GetFirstAddress(void *start, const void *end) const =0
virtual void DecrementLevel(TVirtualStreamerInfo *)
Function is called from TStreamerInfo WriteBuffer and ReadBuffer functions and decrease level in xml ...
Definition: TBufferXML.cxx:969
Bool_t VerifyNode(XMLNodePointer_t node, const char *name, const char *errinfo=0)
Check if node has specified name.
Definition: TBufferXML.cxx:664
virtual Int_t ApplySequence(const TStreamerInfoActions::TActionSequence &sequence, void *object)
Read one collection of objects from the buffer using the StreamerInfoLoopAction.
virtual void WriteUChar(UChar_t c)
Writes UChar_t value to buffer.
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)
Read version value from buffer.
void Class()
Definition: Class.C:29
virtual void ReadCharStar(char *&s)
Read char* from TBuffer.
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
virtual TObject * FindObject(const char *name) const
Find an object in this collection using its name.
Definition: TObjArray.cxx:414
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.
virtual void WriteStdString(const std::string *s)
Write std::string to TBuffer.
virtual void StreamObject(void *obj, const std::type_info &typeinfo, const TClass *onFileClass=0)
steram object to/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 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:50
virtual void ReadStdString(std::string *s)
Reads a std::string.
virtual void WriteFastArrayDouble32(const Double_t *d, Int_t n, TStreamerElement *ele=0)
Write array of Double32_t to buffer.
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
virtual void ReadStdString(std::string *s)
Read std::string from TBuffer.
Base class of the Configurations for the member wise looping routines.
TObject()
TObject constructor.
Definition: TObject.h:226
virtual void ReadULong64(ULong64_t &l)
Reads ULong64_t value from buffer.
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:340
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:34
virtual void ReadUChar(UChar_t &c)
Reads UChar_t value from buffer.
virtual void WriteTString(const TString &s)
Write TString to TBuffer.
Int_t GetType() const
Definition: TDataType.h:68
virtual void ReadDouble32(Double_t *d, TStreamerElement *ele=0)
Read a Double32_t from the buffer.
TStreamerInfo * fInfo
Pointer to TStreamerInfo object writing/reading the buffer.
Definition: TBufferFile.h:58
Int_t GetLast() const
Return index of last object in array.
Definition: TObjArray.cxx:561
TObjArray fStack
Definition: TBufferXML.h:324
Int_t fIOVersion
! Indicates format of ROOT xml file
Definition: TBufferXML.h:339
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:337
Long64_t GetValue(ULong64_t hash, Long64_t key)
Return the value belonging to specified key and hash value.
Definition: TExMap.cxx:173
void ShiftStack(const char *info=0)
Shift stack node to next.
Definition: TBufferXML.cxx:349
Bool_t VerifyStackAttr(const char *name, const char *value, const char *errinfo=0)
Checks stack attribute.
Definition: TBufferXML.cxx:708
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:249
#define TBufferXML_ReadArray(tname, vname)
virtual void IncrementLevel(TVirtualStreamerInfo *)
Function is called from TStreamerInfo WriteBuffer and ReadBuffer functions and indent new level in xm...
Definition: TBufferXML.cxx:894
Basic data type descriptor (datatype information is obtained from CINT).
Definition: TDataType.h:44
virtual Int_t ReadArrayFloat16(Float_t *&f, TStreamerElement *ele=0)
Read array of Float16_t from buffer.
TBufferXML()
Default constructor.
Definition: TBufferXML.cxx:62
virtual void WriteFloat16(Float_t *f, TStreamerElement *ele=0)
Write a Float16_t to the buffer.
void Destructor(void *obj, Bool_t dtorOnly=kFALSE)
Explicitly call destructor for object.
Definition: TClass.cxx:5149
static std::string fgFloatFmt
! Printf argument for floats and doubles, either "%f" or "%e" or "%10f" and so on ...
Definition: TBufferXML.h:342
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:386
#define TBufferXML_ReadStaticArray(vname)
virtual void ClassEnd(const TClass *)
Should be called at the end of custom streamer See TBufferXML::ClassBegin for more details...
short Short_t
Definition: RtypesCore.h:35
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:135
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:335
virtual void WriteArrayFloat16(const Float_t *f, Int_t n, TStreamerElement *ele=0)
Write array of Float16_t to buffer.
Bool_t VerifyStackNode(const char *name, const char *errinfo=0)
Check, if stack node has specified name.
Definition: TBufferXML.cxx:682
void * XMLNodePointer_t
Definition: TXMLEngine.h:17
Bool_t VerifyElemNode(const TStreamerElement *elem)
Checks if stack node correspond to TStreamerElement object.
Definition: TBufferXML.cxx:771
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:635
static void SetFloatFormat(const char *fmt="%e")
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.
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
static const char * GetFloatFormat()
#define FLong64
Definition: TBufferXML.cxx:51
long Long_t
Definition: RtypesCore.h:50
virtual void WriteArrayDouble32(const Double_t *d, Int_t n, TStreamerElement *ele=0)
Write array of Double32_t to buffer.
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:183
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...
TObjArray * fIdArray
Definition: TBufferXML.h:329
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
virtual void ReadWithNbits(Float_t *ptr, Int_t nbits)
Read a Float16_t from the buffer when the number of bits is specified (explicitly or not) see comment...
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:602
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.
static constexpr double s
Bool_t fExpectedChain
! Flag to resolve situation when several elements of same basic type stored as FastArray ...
Definition: TBufferXML.h:336
void WorkWithClass(TStreamerInfo *info, const TClass *cl=0)
Prepares buffer to stream data of specified class.
Definition: TBufferXML.cxx:902
Int_t GetCompressionLevel() const
Definition: TBufferXML.h:354
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
Definition: TXMLEngine.cxx:986
void R__unzip(Int_t *nin, UChar_t *bufin, Int_t *lout, char *bufout, Int_t *nout)
Bool_t VerifyItemNode(const char *name, const char *errinfo=0)
Checks, if stack node is item and has specified name.
Definition: TBufferXML.cxx:730
TXMLStackObj * Stack(Int_t depth=0)
Return xml stack object of specified depth.
Definition: TBufferXML.cxx:329
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
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:32
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
void * XmlReadObject(void *obj, TClass **cl=0)
Read object from the buffer.
Definition: TBufferXML.cxx:827
virtual void SetUseNamespaces(Bool_t iUseNamespaces=kTRUE)
Definition: TXMLSetup.h:103
Definition: file.py:1
Int_t fErrorFlag
Definition: TBufferXML.h:333
const char * Int
Definition: TXMLSetup.cxx:83
Int_t GetIOVersion() const
Definition: TBufferXML.h:49
Int_t GetCompressionAlgorithm() const
Definition: TBufferXML.h:348
virtual void SetByteCount(UInt_t cntpos, Bool_t packInVersion=kFALSE)
Suppressed function of TBuffer.
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
virtual void WriteFastArray(const Bool_t *b, Int_t n)
Write array of n bools into the I/O buffer.
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
virtual void ReadFastArrayWithFactor(Float_t *ptr, Int_t n, Double_t factor, Double_t minvalue)
Read array of Float16_t from buffer.
#define snprintf
Definition: civetweb.c:822
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
Int_t fBufSize
Definition: TBuffer.h:47
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
virtual void SetStreamerElementNumber(TStreamerElement *elem, Int_t comp_type)
Function is called from TStreamerInfo WriteBuffer and ReadBuffer functions and add/verify next elemen...
void Add(TObject *obj)
Definition: TObjArray.h:73
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:46
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 WriteFastArrayFloat16(const Float_t *d, Int_t n, TStreamerElement *ele=0)
Write array of Float16_t to buffer.
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
#define TBufferXML_ReadFastArray(vname)
virtual void Compress()
Remove empty slots from array.
Definition: TObjArray.cxx:333
Abstract Interface class describing Streamer information for one class.
const char * ClassVersion
Definition: TXMLSetup.cxx:48
const char * True
Definition: TXMLSetup.cxx:75
virtual Int_t ReadArrayDouble32(Double_t *&d, TStreamerElement *ele=0)
Read array of Double32_t from 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
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.
TXMLStackObj * PopStack()
Remove one level from xml stack.
Definition: TBufferXML.cxx:315
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
char name[80]
Definition: TGX11.cxx:109
This class stores a (key,value) pair using an external hash.
Definition: TExMap.h:33
const char * Long
Definition: TXMLSetup.cxx:84
virtual void ReadFastArray(Bool_t *b, Int_t n)
Read array of n bools from the I/O buffer.
void Resize(Ssiz_t n)
Resize the string. Truncate or add blanks as necessary.
Definition: TString.cxx:1069
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
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:246
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:345
TVirtualStreamerInfo * fStreamerInfo
StreamerInfo used to derive these actions.