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