Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TXMLFile.cxx
Go to the documentation of this file.
1// @(#)root/xml:$Id: c6d85738bc844c3af55b6d85902df8fc3a014be2 $
2// Author: Sergey Linev, Rene Brun 10.05.2004
3
4/*************************************************************************
5 * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12//________________________________________________________________________
13//
14// The main motivation for the XML format is to facilitate the
15// communication with other non ROOT applications. Currently
16// writing and reading XML files is limited to ROOT applications.
17// It is our intention to develop a simple reader independent
18// of the ROOT libraries that could be used as an example for
19// real applications. One of possible approach with code generation
20// is implemented in TXMLPlayer class.
21//
22// The XML format should be used only for small data volumes,
23// typically histogram files, pictures, geometries, calibrations.
24// The XML file is built in memory before being dumped to disk.
25//
26// Like for normal ROOT files, XML files use the same I/O mechanism
27// exploiting the ROOT/CINT dictionary. Any class having a dictionary
28// can be saved in XML format.
29//
30// This first implementation does not support subdirectories
31// or Trees.
32//
33// The shared library libRXML.so may be loaded dynamically
34// via gSystem->Load("libRXML"). This library is automatically
35// loaded by the plugin manager as soon as a XML file is created
36// via, eg
37// TFile::Open("file.xml","recreate");
38// TFile::Open returns a TXMLFile object. When a XML file is open in write mode,
39// one can use the normal TObject::Write to write an object in the file.
40// Alternatively one can use the new functions TDirectoryFile::WriteObject and
41// TDirectoryFile::WriteObjectAny to write a TObject* or any class not deriving
42// from TObject.
43//
44// example of a session saving a histogram to a XML file
45// =====================================================
46// TFile *f = TFile::Open("Example.xml","recreate");
47// TH1F *h = new TH1F("h","test",1000,-2,2);
48// h->FillRandom("gaus");
49// h->Write();
50// delete f;
51//
52// example of a session reading the histogram from the file
53// ========================================================
54// TFile *f = TFile::Open("Example.xml");
55// TH1F *h = (TH1F*)f->Get("h");
56// h->Draw();
57//
58// A new option in the canvas "File" menu is available to save
59// a TCanvas as a XML file. One can also do
60// canvas->Print("Example.xml");
61//
62// Configuring ROOT with the option "xml"
63// ======================================
64// The XML package is enabled by default
65//
66// documentation
67// =============
68// See also classes TBufferXML, TKeyXML, TXMLEngine, TXMLSetup and TXMLPlayer.
69// An example of XML file corresponding to the small example below
70// can be found at http://root.cern.ch/root/Example.xml
71//
72//______________________________________________________________________________
73
74#include "TXMLFile.h"
75
76#include "TROOT.h"
77#include "TSystem.h"
78#include "TList.h"
79#include "TKeyXML.h"
80#include "TObjArray.h"
81#include "TArrayC.h"
82#include "TStreamerInfo.h"
83#include "TStreamerElement.h"
84#include "TProcessID.h"
85#include "TError.h"
86#include "TClass.h"
87#include "TVirtualMutex.h"
88
89#include <memory>
90
92
93
94////////////////////////////////////////////////////////////////////////////////
95/// Open or creates local XML file with name filename.
96/// It is recommended to specify filename as "<file>.xml". The suffix ".xml"
97/// will be used by object browsers to automatically identify the file as
98/// a XML file. If the constructor fails in any way IsZombie() will
99/// return true. Use IsOpen() to check if the file is (still) open.
100///
101/// If option = NEW or CREATE create a new file and open it for writing,
102/// if the file already exists the file is
103/// not opened.
104/// = RECREATE create a new file, if the file already
105/// exists it will be overwritten.
106/// = 2xoo create a new file with specified xml settings
107/// for more details see TXMLSetup class
108/// = UPDATE open an existing file for writing.
109/// if no file exists, it is created.
110/// = READ open an existing file for reading.
111///
112/// For more details see comments for TFile::TFile() constructor
113///
114/// TXMLFile does not support TTree objects
115
116TXMLFile::TXMLFile(const char *filename, Option_t *option, const char *title, Int_t compression)
117{
118 if (!gROOT)
119 ::Fatal("TFile::TFile", "ROOT system not initialized");
120
121 fXML = std::make_unique<TXMLEngine>();
122
123 if (filename && !strncmp(filename, "xml:", 4))
124 filename += 4;
125
126 gDirectory = nullptr;
127 SetName(filename);
128 SetTitle(title);
129 TDirectoryFile::Build(this, 0);
130
131 fD = -1;
132 fFile = this;
133 fFree = nullptr;
134 fVersion = gROOT->GetVersionInt(); // ROOT version in integer format
135 fUnits = 4;
136 fOption = option;
137 SetCompressionSettings(compression);
138 fWritten = 0;
139 fSumBuffer = 0;
140 fSum2Buffer = 0;
141 fBytesRead = 0;
142 fBytesWrite = 0;
143 fClassIndex = 0;
144 fSeekInfo = 0;
145 fNbytesInfo = 0;
146 fProcessIDs = nullptr;
147 fNProcessIDs = 0;
148 fIOVersion = TXMLFile::Class_Version();
150
151 fOption = option;
153
154 if (fOption == "NEW")
155 fOption = "CREATE";
156
157 Bool_t create = (fOption == "CREATE") ? kTRUE : kFALSE;
158 Bool_t recreate = (fOption == "RECREATE") ? kTRUE : kFALSE;
159 Bool_t update = (fOption == "UPDATE") ? kTRUE : kFALSE;
160 Bool_t read = (fOption == "READ") ? kTRUE : kFALSE;
161 Bool_t xmlsetup = IsValidXmlSetup(option);
162 if (xmlsetup)
163 recreate = kTRUE;
164
165 if (!create && !recreate && !update && !read) {
166 read = kTRUE;
167 fOption = "READ";
168 }
169
170 Bool_t devnull = kFALSE;
171 const char *fname = nullptr;
172
173 if (!filename || !filename[0]) {
174 Error("TXMLFile", "file name is not specified");
175 goto zombie;
176 }
177
178 // support dumping to /dev/null on UNIX
179 if (!strcmp(filename, "/dev/null") && !gSystem->AccessPathName(filename, kWritePermission)) {
180 devnull = kTRUE;
181 create = kTRUE;
182 recreate = kFALSE;
183 update = kFALSE;
184 read = kFALSE;
185 fOption = "CREATE";
187 }
188
189 gROOT->cd();
190
191 fname = gSystem->ExpandPathName(filename);
192 if (fname) {
193 SetName(fname);
194 delete[](char *) fname;
195 fname = GetName();
196 } else {
197 Error("TXMLFile", "error expanding path %s", filename);
198 goto zombie;
199 }
200
201 if (recreate) {
202 if (!gSystem->AccessPathName(fname, kFileExists))
203 gSystem->Unlink(fname);
204 create = kTRUE;
205 fOption = "CREATE";
206 }
207
208 if (create && !devnull && !gSystem->AccessPathName(fname, kFileExists)) {
209 Error("TXMLFile", "file %s already exists", fname);
210 goto zombie;
211 }
212
213 if (update) {
214 if (gSystem->AccessPathName(fname, kFileExists)) {
215 update = kFALSE;
216 create = kTRUE;
217 }
219 Error("TXMLFile", "no write permission, could not open file %s", fname);
220 goto zombie;
221 }
222 }
223
224 if (read) {
225 if (gSystem->AccessPathName(fname, kFileExists)) {
226 Error("TXMLFile", "file %s does not exist", fname);
227 goto zombie;
228 }
230 Error("TXMLFile", "no read permission, could not open file %s", fname);
231 goto zombie;
232 }
233 }
234
235 fRealName = fname;
236
237 if (create || update)
239 else
241
242 if (create) {
243 if (xmlsetup)
244 ReadSetupFromStr(option);
245 else
247 }
248
249 InitXmlFile(create);
250
251 return;
252
253zombie:
254 MakeZombie();
256}
257
258////////////////////////////////////////////////////////////////////////////////
259/// initialize xml file and correspondent structures
260/// identical to TFile::Init() function
261
263{
264 Int_t len = gROOT->GetListOfStreamerInfo()->GetSize() + 1;
265 if (len < 5000)
266 len = 5000;
267 fClassIndex = new TArrayC(len);
268 fClassIndex->Reset(0);
269
270 if (create) {
271 fDoc = fXML->NewDoc();
272 XMLNodePointer_t fRootNode = fXML->NewChild(nullptr, nullptr, xmlio::Root);
273 fXML->DocSetRootElement(fDoc, fRootNode);
274 } else {
275 ReadFromFile();
276 }
277
278 {
280 gROOT->GetListOfFiles()->Add(this);
281 }
282 cd();
283
284 fNProcessIDs = 0;
285 TKey *key = nullptr;
286 TIter iter(fKeys);
287 while ((key = (TKey *)iter()) != nullptr) {
288 if (!strcmp(key->GetClassName(), "TProcessID"))
289 fNProcessIDs++;
290 }
291
293}
294
295////////////////////////////////////////////////////////////////////////////////
296/// Close a XML file
297/// For more comments see TFile::Close() function
298
300{
301 if (!IsOpen())
302 return;
303
304 TString opt = option;
305 if (opt.Length() > 0)
306 opt.ToLower();
307
308 if (IsWritable())
309 SaveToFile();
310
312
313 if (fDoc) {
314 fXML->FreeDoc(fDoc);
315 fDoc = nullptr;
316 }
317
318 if (fClassIndex) {
319 delete fClassIndex;
320 fClassIndex = nullptr;
321 }
322
323 if (fStreamerInfoNode) {
324 fXML->FreeNode(fStreamerInfoNode);
325 fStreamerInfoNode = nullptr;
326 }
327
328 {
329 TDirectory::TContext ctxt(this);
330 // Delete all supported directories structures from memory
332 }
333
334 // delete the TProcessIDs
335 TList pidDeleted;
336 TIter next(fProcessIDs);
337 TProcessID *pid;
338 while ((pid = (TProcessID *)next())) {
339 if (!pid->DecrementCount()) {
341 pidDeleted.Add(pid);
342 } else if (opt.Contains("r")) {
343 pid->Clear();
344 }
345 }
346 pidDeleted.Delete();
347
349 gROOT->GetListOfFiles()->Remove(this);
350}
351
352////////////////////////////////////////////////////////////////////////////////
353/// destructor of TXMLFile object
354
356{
357 Close();
358}
359
360////////////////////////////////////////////////////////////////////////////////
361/// return kTRUE if file is opened and can be accessed
362
364{
365 return fDoc != nullptr;
366}
367
368////////////////////////////////////////////////////////////////////////////////
369/// Reopen a file with a different access mode, like from READ to
370/// See TFile::Open() for details
371
373{
374 cd();
375
376 TString opt = mode;
377 opt.ToUpper();
378
379 if (opt != "READ" && opt != "UPDATE") {
380 Error("ReOpen", "mode must be either READ or UPDATE, not %s", opt.Data());
381 return 1;
382 }
383
384 if (opt == fOption || (opt == "UPDATE" && fOption == "CREATE"))
385 return 1;
386
387 if (opt == "READ") {
388 // switch to READ mode
389
390 if (IsOpen() && IsWritable())
391 SaveToFile();
392 fOption = opt;
393
395
396 } else {
397 fOption = opt;
398
400 }
401
402 return 0;
403}
404
405////////////////////////////////////////////////////////////////////////////////
406/// create XML key, which will store object in xml structures
407
408TKey *TXMLFile::CreateKey(TDirectory *mother, const TObject *obj, const char *name, Int_t)
409{
410 return new TKeyXML(mother, ++fKeyCounter, obj, name);
411}
412
413////////////////////////////////////////////////////////////////////////////////
414/// create XML key, which will store object in xml structures
415
416TKey *TXMLFile::CreateKey(TDirectory *mother, const void *obj, const TClass *cl, const char *name, Int_t)
417{
418 return new TKeyXML(mother, ++fKeyCounter, obj, cl, name);
419}
420
421////////////////////////////////////////////////////////////////////////////////
422/// function produces pair of xml and dtd file names
423
424void TXMLFile::ProduceFileNames(const char *filename, TString &fname, TString &dtdname)
425{
426 fname = filename;
427 dtdname = filename;
428
429 Bool_t hasxmlext = kFALSE;
430
431 if (fname.Length() > 4) {
432 TString last = fname(fname.Length() - 4, 4);
433 last.ToLower();
434 hasxmlext = (last == ".xml");
435 }
436
437 if (hasxmlext) {
438 dtdname.Replace(dtdname.Length() - 4, 4, ".dtd");
439 } else {
440 fname += ".xml";
441 dtdname += ".dtd";
442 }
443}
444
445////////////////////////////////////////////////////////////////////////////////
446/// Saves xml structures to the file
447/// xml elements are kept in list of TKeyXML objects
448/// When saving, all this elements are linked to root xml node
449/// At the end StreamerInfo structures are added
450/// After xml document is saved, all nodes will be unlinked from root node
451/// and kept in memory.
452/// Only Close() or destructor release memory, used by xml structures
453
455{
456 if (!fDoc)
457 return;
458
459 if (gDebug > 1)
460 Info("SaveToFile", "File: %s", fRealName.Data());
461
462 XMLNodePointer_t fRootNode = fXML->DocGetRootElement(fDoc);
463
464 fXML->FreeAttr(fRootNode, xmlio::Setup);
465 fXML->NewAttr(fRootNode, nullptr, xmlio::Setup, GetSetupAsString());
466
467 fXML->FreeAttr(fRootNode, xmlio::Ref);
468 fXML->NewAttr(fRootNode, nullptr, xmlio::Ref, xmlio::Null);
469
470 if (GetIOVersion() > 1) {
471
472 fXML->FreeAttr(fRootNode, xmlio::CreateTm);
474 fXML->NewAttr(fRootNode, nullptr, xmlio::CreateTm, TDatime((UInt_t) 1).AsSQLString());
475 else
476 fXML->NewAttr(fRootNode, nullptr, xmlio::CreateTm, fDatimeC.AsSQLString());
477
478 fXML->FreeAttr(fRootNode, xmlio::ModifyTm);
480 fXML->NewAttr(fRootNode, nullptr, xmlio::ModifyTm, TDatime((UInt_t) 1).AsSQLString());
481 else
482 fXML->NewAttr(fRootNode, nullptr, xmlio::ModifyTm, fDatimeM.AsSQLString());
483
484 fXML->FreeAttr(fRootNode, xmlio::ObjectUUID);
486 fXML->NewAttr(fRootNode, nullptr, xmlio::ObjectUUID, TUUID("00000000-0000-0000-0000-000000000000").AsString());
487 else
488 fXML->NewAttr(fRootNode, nullptr, xmlio::ObjectUUID, fUUID.AsString());
489
490 fXML->FreeAttr(fRootNode, xmlio::Title);
491 if (strlen(GetTitle()) > 0)
492 fXML->NewAttr(fRootNode, nullptr, xmlio::Title, GetTitle());
493
494 fXML->FreeAttr(fRootNode, xmlio::IOVersion);
495 fXML->NewIntAttr(fRootNode, xmlio::IOVersion, GetIOVersion());
496
497 fXML->FreeAttr(fRootNode, "file_version");
498 fXML->NewIntAttr(fRootNode, "file_version", fVersion);
499 }
500
501 TString fname, dtdname;
502 ProduceFileNames(fRealName, fname, dtdname);
503
504 /*
505 TIter iter(GetListOfKeys());
506 TKeyXML* key = nullptr;
507 while ((key=(TKeyXML*)iter()) != nullptr)
508 fXML->AddChild(fRootNode, key->KeyNode());
509 */
510
511 CombineNodesTree(this, fRootNode, kTRUE);
512
514
516 fXML->AddChild(fRootNode, fStreamerInfoNode);
517
518 Int_t layout = GetCompressionLevel() > 5 ? 0 : 1;
519
520 fXML->SaveDoc(fDoc, fname, layout);
521
522 /* iter.Reset();
523 while ((key=(TKeyXML*)iter()) != nullptr)
524 fXML->UnlinkNode(key->KeyNode());
525 */
526 CombineNodesTree(this, fRootNode, kFALSE);
527
529 fXML->UnlinkNode(fStreamerInfoNode);
530}
531
532////////////////////////////////////////////////////////////////////////////////
533/// Connect/disconnect all file nodes to single tree before/after saving
534
536{
537 if (!dir)
538 return;
539
540 TIter iter(dir->GetListOfKeys());
541 TKeyXML *key = nullptr;
542
543 while ((key = (TKeyXML *)iter()) != nullptr) {
544 if (dolink)
545 fXML->AddChild(topnode, key->KeyNode());
546 else
547 fXML->UnlinkNode(key->KeyNode());
548 if (key->IsSubdir())
549 CombineNodesTree(FindKeyDir(dir, key->GetKeyId()), key->KeyNode(), dolink);
550 }
551}
552
553////////////////////////////////////////////////////////////////////////////////
554/// read document from file
555/// Now full content of document reads into the memory
556/// Then document decomposed to separate keys and streamer info structures
557/// All irrelevant data will be cleaned
558
560{
561 fDoc = fXML->ParseFile(fRealName);
562 if (!fDoc)
563 return kFALSE;
564
565 XMLNodePointer_t fRootNode = fXML->DocGetRootElement(fDoc);
566
567 if (!fRootNode || !fXML->ValidateVersion(fDoc)) {
568 fXML->FreeDoc(fDoc);
569 fDoc = nullptr;
570 return kFALSE;
571 }
572
573 ReadSetupFromStr(fXML->GetAttr(fRootNode, xmlio::Setup));
574
575 if (fXML->HasAttr(fRootNode, xmlio::CreateTm)) {
576 TDatime tm(fXML->GetAttr(fRootNode, xmlio::CreateTm));
577 fDatimeC = tm;
578 }
579
580 if (fXML->HasAttr(fRootNode, xmlio::ModifyTm)) {
581 TDatime tm(fXML->GetAttr(fRootNode, xmlio::ModifyTm));
582 fDatimeM = tm;
583 }
584
585 if (fXML->HasAttr(fRootNode, xmlio::ObjectUUID)) {
586 TUUID id(fXML->GetAttr(fRootNode, xmlio::ObjectUUID));
587 fUUID = id;
588 }
589
590 if (fXML->HasAttr(fRootNode, xmlio::Title))
591 SetTitle(fXML->GetAttr(fRootNode, xmlio::Title));
592
593 if (fXML->HasAttr(fRootNode, xmlio::IOVersion))
594 fIOVersion = fXML->GetIntAttr(fRootNode, xmlio::IOVersion);
595 else
596 fIOVersion = 1;
597
598 if (fXML->HasAttr(fRootNode, "file_version"))
599 fVersion = fXML->GetIntAttr(fRootNode, "file_version");
600
601 fStreamerInfoNode = fXML->GetChild(fRootNode);
602 fXML->SkipEmpty(fStreamerInfoNode);
603 while (fStreamerInfoNode) {
604 if (strcmp(xmlio::SInfos, fXML->GetNodeName(fStreamerInfoNode)) == 0)
605 break;
606 fXML->ShiftToNext(fStreamerInfoNode);
607 }
608 fXML->UnlinkNode(fStreamerInfoNode);
609
612
613 if (IsUseDtd())
614 if (!fXML->ValidateDocument(fDoc, gDebug > 0)) {
615 fXML->FreeDoc(fDoc);
616 fDoc = nullptr;
617 return kFALSE;
618 }
619
620 ReadKeysList(this, fRootNode);
621
622 fXML->CleanNode(fRootNode);
623
624 return kTRUE;
625}
626
627////////////////////////////////////////////////////////////////////////////////
628/// Read list of keys for directory
629
631{
632 if (!dir || !topnode)
633 return 0;
634
635 Int_t nkeys = 0;
636
637 XMLNodePointer_t keynode = fXML->GetChild(topnode);
638 fXML->SkipEmpty(keynode);
639 while (keynode) {
640 XMLNodePointer_t next = fXML->GetNext(keynode);
641
642 if (strcmp(xmlio::Xmlkey, fXML->GetNodeName(keynode)) == 0) {
643 fXML->UnlinkNode(keynode);
644
645 TKeyXML *key = new TKeyXML(dir, ++fKeyCounter, keynode);
646 dir->AppendKey(key);
647
648 if (gDebug > 2)
649 Info("ReadKeysList", "Add key %s from node %s", key->GetName(), fXML->GetNodeName(keynode));
650
651 nkeys++;
652 }
653
654 keynode = next;
655 fXML->SkipEmpty(keynode);
656 }
657
658 return nkeys;
659}
660
661////////////////////////////////////////////////////////////////////////////////
662/// convert all TStreamerInfo, used in file, to xml format
663
665{
666 if (fStreamerInfoNode) {
667 fXML->FreeNode(fStreamerInfoNode);
668 fStreamerInfoNode = nullptr;
669 }
670
672 return;
673
674 TObjArray list;
675
676 TIter iter(gROOT->GetListOfStreamerInfo());
677
678 TStreamerInfo *info = nullptr;
679
680 while ((info = (TStreamerInfo *)iter()) != nullptr) {
681 Int_t uid = info->GetNumber();
682 if (fClassIndex->fArray[uid])
683 list.Add(info);
684 }
685
686 if (list.GetSize() == 0)
687 return;
688
689 fStreamerInfoNode = fXML->NewChild(nullptr, nullptr, xmlio::SInfos);
690 for (int n = 0; n <= list.GetLast(); n++) {
691 info = (TStreamerInfo *)list.At(n);
692
693 XMLNodePointer_t infonode = fXML->NewChild(fStreamerInfoNode, nullptr, "TStreamerInfo");
694
695 fXML->NewAttr(infonode, nullptr, "name", info->GetName());
696 fXML->NewAttr(infonode, nullptr, "title", info->GetTitle());
697
698 fXML->NewIntAttr(infonode, "v", info->IsA()->GetClassVersion());
699 fXML->NewIntAttr(infonode, "classversion", info->GetClassVersion());
700 fXML->NewAttr(infonode, nullptr, "canoptimize",
702 fXML->NewIntAttr(infonode, "checksum", info->GetCheckSum());
703
704 TIter iter2(info->GetElements());
705 TStreamerElement *elem = nullptr;
706 while ((elem = (TStreamerElement *)iter2()) != nullptr)
707 StoreStreamerElement(infonode, elem);
708 }
709}
710
711////////////////////////////////////////////////////////////////////////////////
712/// Read streamerinfo structures from xml format and provide them in the list
713/// It is user responsibility to destroy this list
714
716{
718
720 return {nullptr, 1, hash};
721
722 TList *list = new TList();
723
724 XMLNodePointer_t sinfonode = fXML->GetChild(fStreamerInfoNode);
725 fXML->SkipEmpty(sinfonode);
726
727 while (sinfonode) {
728 if (strcmp("TStreamerInfo", fXML->GetNodeName(sinfonode)) == 0) {
729 TString fname = fXML->GetAttr(sinfonode, "name");
730 TString ftitle = fXML->GetAttr(sinfonode, "title");
731
732 TStreamerInfo *info = new TStreamerInfo(TClass::GetClass(fname));
733 info->SetTitle(ftitle);
734
735 list->Add(info);
736
737 Int_t clversion = AtoI(fXML->GetAttr(sinfonode, "classversion"));
738 info->SetClassVersion(clversion);
739 info->SetOnFileClassVersion(clversion);
740 Int_t checksum = AtoI(fXML->GetAttr(sinfonode, "checksum"));
741 info->SetCheckSum(checksum);
742
743 const char *canoptimize = fXML->GetAttr(sinfonode, "canoptimize");
744 if (!canoptimize || (strcmp(canoptimize, xmlio::False) == 0))
746 else
748
749 XMLNodePointer_t node = fXML->GetChild(sinfonode);
750 fXML->SkipEmpty(node);
751 while (node) {
752 ReadStreamerElement(node, info);
753 fXML->ShiftToNext(node);
754 }
755 }
756 fXML->ShiftToNext(sinfonode);
757 }
758
759 list->SetOwner();
760
761 return {list, 0, hash};
762}
763
764////////////////////////////////////////////////////////////////////////////////
765/// store data of single TStreamerElement in streamer node
766
768{
769 TClass *cl = elem->IsA();
770
771 XMLNodePointer_t node = fXML->NewChild(infonode, nullptr, cl->GetName());
772
773 char sbuf[100], namebuf[100];
774
775 fXML->NewAttr(node, nullptr, "name", elem->GetName());
776 if (strlen(elem->GetTitle()) > 0)
777 fXML->NewAttr(node, nullptr, "title", elem->GetTitle());
778
779 fXML->NewIntAttr(node, "v", cl->GetClassVersion());
780
781 fXML->NewIntAttr(node, "type", elem->GetType());
782
783 if (strlen(elem->GetTypeName()) > 0)
784 fXML->NewAttr(node, nullptr, "typename", elem->GetTypeName());
785
786 fXML->NewIntAttr(node, "size", elem->GetSize());
787
788 if (elem->GetArrayDim() > 0) {
789 fXML->NewIntAttr(node, "numdim", elem->GetArrayDim());
790
791 for (int ndim = 0; ndim < elem->GetArrayDim(); ndim++) {
792 sprintf(namebuf, "dim%d", ndim);
793 fXML->NewIntAttr(node, namebuf, elem->GetMaxIndex(ndim));
794 }
795 }
796
797 if (cl == TStreamerBase::Class()) {
798 TStreamerBase *base = (TStreamerBase *)elem;
799 sprintf(sbuf, "%d", base->GetBaseVersion());
800 fXML->NewAttr(node, nullptr, "baseversion", sbuf);
801 sprintf(sbuf, "%d", base->GetBaseCheckSum());
802 fXML->NewAttr(node, nullptr, "basechecksum", sbuf);
803 } else if (cl == TStreamerBasicPointer::Class()) {
805 fXML->NewIntAttr(node, "countversion", bptr->GetCountVersion());
806 fXML->NewAttr(node, nullptr, "countname", bptr->GetCountName());
807 fXML->NewAttr(node, nullptr, "countclass", bptr->GetCountClass());
808 } else if (cl == TStreamerLoop::Class()) {
809 TStreamerLoop *loop = (TStreamerLoop *)elem;
810 fXML->NewIntAttr(node, "countversion", loop->GetCountVersion());
811 fXML->NewAttr(node, nullptr, "countname", loop->GetCountName());
812 fXML->NewAttr(node, nullptr, "countclass", loop->GetCountClass());
813 } else if ((cl == TStreamerSTL::Class()) || (cl == TStreamerSTLstring::Class())) {
814 TStreamerSTL *stl = (TStreamerSTL *)elem;
815 fXML->NewIntAttr(node, "STLtype", stl->GetSTLtype());
816 fXML->NewIntAttr(node, "Ctype", stl->GetCtype());
817 }
818}
819
820////////////////////////////////////////////////////////////////////////////////
821/// read and reconstruct single TStreamerElement from xml node
822
824{
825 TClass *cl = TClass::GetClass(fXML->GetNodeName(node));
826 if (!cl || !cl->InheritsFrom(TStreamerElement::Class()))
827 return;
828
829 TStreamerElement *elem = (TStreamerElement *)cl->New();
830
831 int elem_type = fXML->GetIntAttr(node, "type");
832
833 elem->SetName(fXML->GetAttr(node, "name"));
834 elem->SetTitle(fXML->GetAttr(node, "title"));
835 elem->SetType(elem_type);
836 elem->SetTypeName(fXML->GetAttr(node, "typename"));
837 elem->SetSize(fXML->GetIntAttr(node, "size"));
838
839 if (cl == TStreamerBase::Class()) {
840 int basever = fXML->GetIntAttr(node, "baseversion");
841 ((TStreamerBase *)elem)->SetBaseVersion(basever);
842 Int_t baseCheckSum = fXML->GetIntAttr(node, "basechecksum");
843 ((TStreamerBase *)elem)->SetBaseCheckSum(baseCheckSum);
844 } else if (cl == TStreamerBasicPointer::Class()) {
845 TString countname = fXML->GetAttr(node, "countname");
846 TString countclass = fXML->GetAttr(node, "countclass");
847 Int_t countversion = fXML->GetIntAttr(node, "countversion");
848
849 ((TStreamerBasicPointer *)elem)->SetCountVersion(countversion);
850 ((TStreamerBasicPointer *)elem)->SetCountName(countname);
851 ((TStreamerBasicPointer *)elem)->SetCountClass(countclass);
852 } else if (cl == TStreamerLoop::Class()) {
853 TString countname = fXML->GetAttr(node, "countname");
854 TString countclass = fXML->GetAttr(node, "countclass");
855 Int_t countversion = fXML->GetIntAttr(node, "countversion");
856 ((TStreamerLoop *)elem)->SetCountVersion(countversion);
857 ((TStreamerLoop *)elem)->SetCountName(countname);
858 ((TStreamerLoop *)elem)->SetCountClass(countclass);
859 } else if ((cl == TStreamerSTL::Class()) || (cl == TStreamerSTLstring::Class())) {
860 int fSTLtype = fXML->GetIntAttr(node, "STLtype");
861 int fCtype = fXML->GetIntAttr(node, "Ctype");
862 ((TStreamerSTL *)elem)->SetSTLtype(fSTLtype);
863 ((TStreamerSTL *)elem)->SetCtype(fCtype);
864 }
865
866 char namebuf[100];
867
868 if (fXML->HasAttr(node, "numdim")) {
869 int numdim = fXML->GetIntAttr(node, "numdim");
870 elem->SetArrayDim(numdim);
871 for (int ndim = 0; ndim < numdim; ndim++) {
872 sprintf(namebuf, "dim%d", ndim);
873 int maxi = fXML->GetIntAttr(node, namebuf);
874 elem->SetMaxIndex(ndim, maxi);
875 }
876 }
877
878 elem->SetType(elem_type);
879 elem->SetNewType(elem_type);
880
881 info->GetElements()->Add(elem);
882}
883
884////////////////////////////////////////////////////////////////////////////////
885/// Change layout of objects in xml file
886/// Can be changed only for newly created file.
887///
888/// Currently there are two supported layouts:
889///
890/// TXMLSetup::kSpecialized = 2
891/// This is default layout of the file, when xml nodes names class names and data member
892/// names are used. For instance:
893/// <TAttLine version="1">
894/// <fLineColor v="1"/>
895/// <fLineStyle v="1"/>
896/// <fLineWidth v="1"/>
897/// </TAttLine>
898///
899/// TXMLSetup::kGeneralized = 3
900/// For this layout all nodes name does not depend from class definitions.
901/// The same class looks like
902/// <Class name="TAttLine" version="1">
903/// <Member name="fLineColor" v="1"/>
904/// <Member name="fLineStyle" v="1"/>
905/// <Member name="fLineWidth" v="1"/>
906/// </Member>
907///
908
910{
911 if (IsWritable() && (GetListOfKeys()->GetSize() == 0))
913}
914
915////////////////////////////////////////////////////////////////////////////////
916/// If true, all correspondent to file TStreamerInfo objects will be stored in file
917/// this allows to apply schema evolution later for this file
918/// may be useful, when file used outside ROOT and TStreamerInfo objects does not required
919/// Can be changed only for newly created file.
920
922{
923 if (IsWritable() && (GetListOfKeys()->GetSize() == 0))
925}
926
927////////////////////////////////////////////////////////////////////////////////
928/// Specify usage of DTD for this file.
929/// Currently this option not available (always false).
930/// Can be changed only for newly created file.
931
933{
934 if (IsWritable() && (GetListOfKeys()->GetSize() == 0))
936}
937
938////////////////////////////////////////////////////////////////////////////////
939/// Specify usage of namespaces in xml file
940/// In current implementation every instrumented class in file gets its unique namespace,
941/// which is equal to name of class and refer to root documentation page like
942/// <TAttPad xmlns:TAttPad="http://root.cern.ch/root/htmldoc/TAttPad.html" version="3">
943/// And xml node for class member gets its name as combination of class name and member name
944/// <TAttPad:fLeftMargin v="0.100000"/>
945/// <TAttPad:fRightMargin v="0.100000"/>
946/// <TAttPad:fBottomMargin v="0.100000"/>
947/// and so on
948/// Usage of namespace increase size of xml file, but makes file more readable
949/// and allows to produce DTD in the case, when in several classes data member has same name
950/// Can be changed only for newly created file.
951
953{
954 if (IsWritable() && (GetListOfKeys()->GetSize() == 0))
955 TXMLSetup::SetUseNamespaces(iUseNamespaces);
956}
957
958////////////////////////////////////////////////////////////////////////////////
959/// Add comment line on the top of the xml document
960/// This line can only be seen in xml editor and cannot be accessed later
961/// with TXMLFile methods
962
963Bool_t TXMLFile::AddXmlComment(const char *comment)
964{
965 if (!IsWritable())
966 return kFALSE;
967
968 return fXML->AddDocComment(fDoc, comment);
969}
970
971////////////////////////////////////////////////////////////////////////////////
972/// Adds style sheet definition on the top of xml document
973/// Creates <?xml-stylesheet alternate="yes" title="compact" href="small-base.css" type="text/css"?>
974/// Attributes href and type must be supplied,
975/// other attributes: title, alternate, media, charset are optional
976/// if alternate==0, attribute alternate="no" will be created,
977/// if alternate>0, attribute alternate="yes"
978/// if alternate<0, attribute will not be created
979/// This style sheet definition cannot be later access with TXMLFile methods.
980
981Bool_t TXMLFile::AddXmlStyleSheet(const char *href, const char *type, const char *title, int alternate,
982 const char *media, const char *charset)
983{
984 if (!IsWritable())
985 return kFALSE;
986
987 return fXML->AddDocStyleSheet(fDoc, href, type, title, alternate, media, charset);
988}
989
990////////////////////////////////////////////////////////////////////////////////
991/// Add just one line on the top of xml document
992/// For instance, line can contain special xml processing instructions
993/// Line should has correct xml syntax that later it can be decoded by xml parser
994/// To be parsed later by TXMLFile again, this line should contain either
995/// xml comments or xml processing instruction
996
998{
999 if (!IsWritable())
1000 return kFALSE;
1001
1002 return fXML->AddDocRawLine(fDoc, line);
1003}
1004
1005////////////////////////////////////////////////////////////////////////////////
1006/// Create key for directory entry in the key
1007
1009{
1010 TDirectory *mother = dir->GetMotherDir();
1011 if (!mother)
1012 mother = this;
1013
1014 TKeyXML *key = new TKeyXML(mother, ++fKeyCounter, dir, dir->GetName(), dir->GetTitle());
1015
1016 key->SetSubir();
1017
1018 return key->GetKeyId();
1019}
1020
1021////////////////////////////////////////////////////////////////////////////////
1022/// Search for key which correspond to directory dir
1023
1025{
1026 TDirectory *motherdir = dir->GetMotherDir();
1027 if (!motherdir)
1028 motherdir = this;
1029
1030 TIter next(motherdir->GetListOfKeys());
1031 TObject *obj = nullptr;
1032
1033 while ((obj = next()) != nullptr) {
1034 TKeyXML *key = dynamic_cast<TKeyXML *>(obj);
1035
1036 if (key)
1037 if (key->GetKeyId() == dir->GetSeekDir())
1038 return key;
1039 }
1040
1041 return nullptr;
1042}
1043
1044////////////////////////////////////////////////////////////////////////////////
1045/// Find a directory in motherdir with a seek equal to keyid
1046
1048{
1049 if (!motherdir)
1050 motherdir = this;
1051
1052 TIter next(motherdir->GetList());
1053 TObject *obj = nullptr;
1054
1055 while ((obj = next()) != nullptr) {
1056 TDirectory *dir = dynamic_cast<TDirectory *>(obj);
1057 if (dir)
1058 if (dir->GetSeekDir() == keyid)
1059 return dir;
1060 }
1061
1062 return nullptr;
1063}
1064
1065////////////////////////////////////////////////////////////////////////////////
1066/// Read keys for directory
1067/// Make sense only once, while next time no new subnodes will be created
1068
1070{
1071 TKeyXML *key = FindDirKey(dir);
1072 if (!key)
1073 return 0;
1074
1075 return ReadKeysList(dir, key->KeyNode());
1076}
1077
1078////////////////////////////////////////////////////////////////////////////////
1079/// Update key attributes
1080
1082{
1083 TIter next(GetListOfKeys());
1084 TObject *obj = nullptr;
1085
1086 while ((obj = next()) != nullptr) {
1087 TKeyXML *key = dynamic_cast<TKeyXML *>(obj);
1088 if (key)
1089 key->UpdateAttributes();
1090 }
1091}
1092
1093////////////////////////////////////////////////////////////////////////////////
1094/// Write the directory header
1095
1097{
1098 TKeyXML *key = FindDirKey(dir);
1099 if (key)
1100 key->UpdateObject(dir);
1101}
static void update(gsl_integration_workspace *workspace, double a1, double b1, double area1, double error1, double a2, double b2, double area2, double error2)
const Bool_t kFALSE
Definition RtypesCore.h:101
long long Long64_t
Definition RtypesCore.h:80
const Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:364
#define gDirectory
Definition TDirectory.h:385
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
Definition TError.cxx:220
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:187
void Fatal(const char *location, const char *msgfmt,...)
Use this function in case of a fatal error. It will abort the program.
Definition TError.cxx:245
XFontStruct * id
Definition TGX11.cxx:109
char name[80]
Definition TGX11.cxx:110
int type
Definition TGX11.cxx:121
Int_t gDebug
Definition TROOT.cxx:592
R__EXTERN TVirtualMutex * gROOTMutex
Definition TROOT.h:63
#define gROOT
Definition TROOT.h:404
@ kFileExists
Definition TSystem.h:44
@ kReadPermission
Definition TSystem.h:47
@ kWritePermission
Definition TSystem.h:46
R__EXTERN TSystem * gSystem
Definition TSystem.h:559
#define R__LOCKGUARD(mutex)
void * XMLNodePointer_t
Definition TXMLEngine.h:17
Array of chars or bytes (8 bits per element).
Definition TArrayC.h:27
Char_t * fArray
Definition TArrayC.h:30
void Reset(Char_t val=0)
Definition TArrayC.h:47
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:80
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Return a pointer to a newly allocated object of this class.
Definition TClass.cxx:4964
Version_t GetClassVersion() const
Definition TClass.h:417
Bool_t InheritsFrom(const char *cl) const
Return kTRUE if this class inherits from a class with name "classname".
Definition TClass.cxx:4860
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:2966
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition TDatime.h:37
const char * AsSQLString() const
Return the date & time in SQL compatible string format, like: 1997-01-15 20:16:28.
Definition TDatime.cxx:152
void Close(Option_t *option="") override
Delete all objects from memory and directory structure itself.
Bool_t cd() override
Change current directory to "this" directory.
TFile * fFile
Pointer to current file in memory.
Bool_t IsWritable() const override
TDatime fDatimeM
Date and time of last modification.
TList * GetListOfKeys() const override
TDatime fDatimeC
Date and time when directory is created.
Bool_t fWritable
True if directory is writable.
void SetWritable(Bool_t writable=kTRUE) override
Set the new value of fWritable recursively.
void Build(TFile *motherFile=nullptr, TDirectory *motherDir=nullptr) override
TList * fKeys
Pointer to keys list in memory.
TDirectory::TContext keeps track and restore the current directory.
Definition TDirectory.h:89
Describe directory structure in memory.
Definition TDirectory.h:45
virtual Long64_t GetSeekDir() const
Definition TDirectory.h:228
virtual TList * GetList() const
Definition TDirectory.h:222
virtual Int_t AppendKey(TKey *)
Definition TDirectory.h:184
void SetName(const char *newname) override
Set the name for directory If the directory name is changed after the directory was written once,...
virtual TList * GetListOfKeys() const
Definition TDirectory.h:223
TUUID fUUID
Definition TDirectory.h:143
TDirectory * GetMotherDir() const
Definition TDirectory.h:225
Long64_t fBytesRead
Number of bytes read from this file.
Definition TFile.h:77
Double_t fSum2Buffer
Sum of squares of buffer sizes of objects written so far.
Definition TFile.h:75
virtual void ReadStreamerInfo()
Read the list of StreamerInfo from this file.
Definition TFile.cxx:3543
TArrayC * fClassIndex
!Index of TStreamerInfo classes written to this file
Definition TFile.h:95
Long64_t fSeekInfo
Location on disk of StreamerInfo record.
Definition TFile.h:82
Int_t fVersion
File format version.
Definition TFile.h:84
Int_t fNbytesInfo
Number of bytes for StreamerInfo record.
Definition TFile.h:87
virtual void SetCompressionSettings(Int_t settings=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault)
Used to specify the compression level and algorithm.
Definition TFile.cxx:2276
Int_t GetCompressionLevel() const
Definition TFile.h:395
TString fOption
File options.
Definition TFile.h:92
Int_t fD
File descriptor.
Definition TFile.h:83
Char_t fUnits
Number of bytes for file pointers.
Definition TFile.h:93
TObjArray * fProcessIDs
!Array of pointers to TProcessIDs
Definition TFile.h:96
Long64_t fBytesWrite
Number of bytes written to this file.
Definition TFile.h:76
TList * fFree
Free segments linked list table.
Definition TFile.h:94
TString fRealName
Effective real file name (not original url)
Definition TFile.h:91
Double_t fSumBuffer
Sum of buffer sizes of objects written so far.
Definition TFile.h:74
@ kReproducible
Definition TFile.h:191
@ kDevNull
Definition TFile.h:187
@ kBinaryFile
Definition TFile.h:189
Int_t fNProcessIDs
Number of TProcessID written to this file.
Definition TFile.h:89
Int_t fWritten
Number of objects written so far.
Definition TFile.h:88
void UpdateObject(TObject *obj)
updates object, stored in the node Used for TDirectory data update
Definition TKeyXML.cxx:218
Long64_t GetKeyId() const
Definition TKeyXML.h:62
XMLNodePointer_t KeyNode() const
Definition TKeyXML.h:61
Bool_t IsSubdir() const
Definition TKeyXML.h:63
void UpdateAttributes()
update key attributes in key node
Definition TKeyXML.cxx:203
void SetSubir()
Definition TKeyXML.h:64
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Definition TKey.h:28
virtual const char * GetClassName() const
Definition TKey.h:76
A doubly linked list.
Definition TList.h:38
virtual void Add(TObject *obj)
Definition TList.h:81
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition TList.cxx:470
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:164
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition TNamed.cxx:140
virtual const char * GetTitle() const
Returns title of object.
Definition TNamed.h:48
virtual const char * GetName() const
Returns name of object.
Definition TNamed.h:47
An array of TObjects.
Definition TObjArray.h:31
void Add(TObject *obj)
Definition TObjArray.h:68
Int_t GetLast() const
Return index of last object in array.
TObject * At(Int_t idx) const
Definition TObjArray.h:164
Mother of all ROOT objects.
Definition TObject.h:41
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:201
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:766
void MakeZombie()
Definition TObject.h:53
void ResetBit(UInt_t f)
Definition TObject.h:200
A TProcessID identifies a ROOT job in a unique way in time and space.
Definition TProcessID.h:74
virtual void Clear(Option_t *option="")
delete the TObjArray pointing to referenced objects this function is called by TFile::Close("R")
static TProcessID * GetSessionProcessID()
static function returning the pointer to the session TProcessID
Int_t DecrementCount()
The reference fCount is used to delete the TProcessID in the TFile destructor when fCount = 0.
UInt_t GetBaseCheckSum()
const char * GetCountName() const
Int_t GetCountVersion() const
const char * GetCountClass() const
virtual void SetSize(Int_t dsize)
virtual Int_t GetSize() const
Returns size of this element in bytes.
Int_t GetType() const
virtual void SetArrayDim(Int_t dim)
Set number of array dimensions.
Int_t GetArrayDim() const
Int_t GetMaxIndex(Int_t i) const
const char * GetTypeName() const
virtual void SetType(Int_t dtype)
virtual void SetTypeName(const char *name)
virtual void SetNewType(Int_t dtype)
virtual void SetMaxIndex(Int_t dim, Int_t max)
set maximum index for array with dimension dim
Describes a persistent version of a class.
TObjArray * GetElements() const
void SetClassVersion(Int_t vers)
Int_t GetNumber() const
void SetCheckSum(UInt_t checksum)
void SetOnFileClassVersion(Int_t vers)
Int_t GetClassVersion() const
UInt_t GetCheckSum() const
const char * GetCountName() const
Int_t GetCountVersion() const
const char * GetCountClass() const
Int_t GetCtype() const
Int_t GetSTLtype() const
Basic string class.
Definition TString.h:136
Ssiz_t Length() const
Definition TString.h:410
void ToLower()
Change string to lower-case.
Definition TString.cxx:1150
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
Definition TString.h:682
const char * Data() const
Definition TString.h:369
void ToUpper()
Change string to upper case.
Definition TString.cxx:1163
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:624
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition TSystem.cxx:1274
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
Definition TSystem.cxx:1296
virtual int Unlink(const char *name)
Unlink, i.e.
Definition TSystem.cxx:1381
This class defines a UUID (Universally Unique IDentifier), also known as GUIDs (Globally Unique IDent...
Definition TUUID.h:42
const char * AsString() const
Return UUID as string. Copy string immediately since it will be reused.
Definition TUUID.cxx:570
Bool_t IsOpen() const final
return kTRUE if file is opened and can be accessed
Definition TXMLFile.cxx:363
Int_t fIOVersion
object for interface with xml library
Definition TXMLFile.h:136
TXMLFile()
Definition TXMLFile.h:51
TDirectory * FindKeyDir(TDirectory *mother, Long64_t keyid)
Find a directory in motherdir with a seek equal to keyid.
TKey * CreateKey(TDirectory *mother, const TObject *obj, const char *name, Int_t bufsize) final
create XML key, which will store object in xml structures
Definition TXMLFile.cxx:408
void InitXmlFile(Bool_t create)
initialize xml file and correspondent structures identical to TFile::Init() function
Definition TXMLFile.cxx:262
Bool_t AddXmlStyleSheet(const char *href, const char *type="text/css", const char *title=nullptr, int alternate=-1, const char *media=nullptr, const char *charset=nullptr)
Adds style sheet definition on the top of xml document Creates <?xml-stylesheet alternate="yes" title...
Definition TXMLFile.cxx:981
InfoListRet GetStreamerInfoListImpl(bool lookupSICache) final
Read streamerinfo structures from xml format and provide them in the list It is user responsibility t...
Definition TXMLFile.cxx:715
void SaveToFile()
Saves xml structures to the file xml elements are kept in list of TKeyXML objects When saving,...
Definition TXMLFile.cxx:454
XMLNodePointer_t fStreamerInfoNode
Definition TXMLFile.h:132
Long64_t fKeyCounter
indicates format of ROOT xml file
Definition TXMLFile.h:138
void CombineNodesTree(TDirectory *dir, XMLNodePointer_t topnode, Bool_t dolink)
Connect/disconnect all file nodes to single tree before/after saving.
Definition TXMLFile.cxx:535
void DirWriteHeader(TDirectory *) final
Write the directory header.
Int_t DirReadKeys(TDirectory *) final
Read keys for directory Make sense only once, while next time no new subnodes will be created.
Bool_t AddXmlLine(const char *line)
Add just one line on the top of xml document For instance, line can contain special xml processing in...
Definition TXMLFile.cxx:997
Long64_t GetSize() const final
Returns the current file size.
Definition TXMLFile.h:71
void DirWriteKeys(TDirectory *) final
Update key attributes.
void WriteStreamerInfo() final
convert all TStreamerInfo, used in file, to xml format
Definition TXMLFile.cxx:664
Int_t ReadKeysList(TDirectory *dir, XMLNodePointer_t topnode)
Read list of keys for directory.
Definition TXMLFile.cxx:630
void SetXmlLayout(EXMLLayout layout) final
Change layout of objects in xml file Can be changed only for newly created file.
Definition TXMLFile.cxx:909
void SetStoreStreamerInfos(Bool_t iConvert=kTRUE) final
If true, all correspondent to file TStreamerInfo objects will be stored in file this allows to apply ...
Definition TXMLFile.cxx:921
void SetUseNamespaces(Bool_t iUseNamespaces=kTRUE) final
Specify usage of namespaces in xml file In current implementation every instrumented class in file ge...
Definition TXMLFile.cxx:952
Int_t GetIOVersion() const
Definition TXMLFile.h:73
void SetUsedDtd(Bool_t use=kTRUE) final
Specify usage of DTD for this file.
Definition TXMLFile.cxx:932
virtual ~TXMLFile()
destructor of TXMLFile object
Definition TXMLFile.cxx:355
XMLDocPointer_t fDoc
Definition TXMLFile.h:130
void StoreStreamerElement(XMLNodePointer_t node, TStreamerElement *elem)
store data of single TStreamerElement in streamer node
Definition TXMLFile.cxx:767
void ReadStreamerElement(XMLNodePointer_t node, TStreamerInfo *info)
read and reconstruct single TStreamerElement from xml node
Definition TXMLFile.cxx:823
Int_t ReOpen(Option_t *mode) final
Reopen a file with a different access mode, like from READ to See TFile::Open() for details.
Definition TXMLFile.cxx:372
std::unique_ptr< TXMLEngine > fXML
pointer of node with streamer info data
Definition TXMLFile.h:134
void Close(Option_t *option="") final
Close a XML file For more comments see TFile::Close() function.
Definition TXMLFile.cxx:299
Bool_t ReadFromFile()
read document from file Now full content of document reads into the memory Then document decomposed t...
Definition TXMLFile.cxx:559
Bool_t AddXmlComment(const char *comment)
Add comment line on the top of the xml document This line can only be seen in xml editor and cannot b...
Definition TXMLFile.cxx:963
Long64_t DirCreateEntry(TDirectory *) final
Create key for directory entry in the key.
TKeyXML * FindDirKey(TDirectory *dir)
Search for key which correspond to directory dir.
static void ProduceFileNames(const char *filename, TString &fname, TString &dtdname)
function produces pair of xml and dtd file names
Definition TXMLFile.cxx:424
virtual void SetUsedDtd(Bool_t use=kTRUE)
Definition TXMLSetup.h:104
virtual void SetUseNamespaces(Bool_t iUseNamespaces=kTRUE)
Definition TXMLSetup.h:105
TString GetSetupAsString()
return setup values as string
Bool_t IsValidXmlSetup(const char *setupstr)
checks if string is valid setup
Bool_t ReadSetupFromStr(const char *setupstr)
get values from string
Int_t AtoI(const char *sbuf, Int_t def=0, const char *errinfo=nullptr)
converts string to integer.
Bool_t IsStoreStreamerInfos() const
Definition TXMLSetup.h:98
static TString DefaultXmlSetup()
return default value for XML setup
Bool_t IsUseDtd() const
Definition TXMLSetup.h:99
virtual void SetStoreStreamerInfos(Bool_t iConvert=kTRUE)
Definition TXMLSetup.h:103
virtual void SetXmlLayout(EXMLLayout layout)
Definition TXMLSetup.h:102
TLine * line
const Int_t n
Definition legend1.C:16
const char * Root
Definition TXMLSetup.cxx:47
const char * SInfos
Definition TXMLSetup.cxx:78
const char * IOVersion
Definition TXMLSetup.cxx:50
const char * ModifyTm
Definition TXMLSetup.cxx:70
const char * False
Definition TXMLSetup.cxx:77
const char * True
Definition TXMLSetup.cxx:76
const char * Title
Definition TXMLSetup.cxx:68
const char * Ref
Definition TXMLSetup.cxx:53
const char * Null
Definition TXMLSetup.cxx:54
const char * CreateTm
Definition TXMLSetup.cxx:69
const char * Setup
Definition TXMLSetup.cxx:48
const char * ObjectUUID
Definition TXMLSetup.cxx:71
const char * Xmlkey
Definition TXMLSetup.cxx:58
Simple struct of the return value of GetStreamerInfoListImpl.
Definition TFile.h:146