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