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/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;
128 SetTitle(title);
129 TDirectoryFile::Build(this, nullptr);
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 = nullptr;
144 fSeekInfo = 0;
145 fNbytesInfo = 0;
146 fProcessIDs = nullptr;
147 fNProcessIDs = 0;
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
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)
245 else
247 }
248
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 constexpr std::size_t bufferSize = 100;
774 char sbuf[bufferSize];
775 char namebuf[bufferSize];
776
777 fXML->NewAttr(node, nullptr, "name", elem->GetName());
778 if (strlen(elem->GetTitle()) > 0)
779 fXML->NewAttr(node, nullptr, "title", elem->GetTitle());
780
781 fXML->NewIntAttr(node, "v", cl->GetClassVersion());
782
783 fXML->NewIntAttr(node, "type", elem->GetType());
784
785 if (strlen(elem->GetTypeName()) > 0)
786 fXML->NewAttr(node, nullptr, "typename", elem->GetTypeName());
787
788 fXML->NewIntAttr(node, "size", elem->GetSize());
789
790 if (elem->GetArrayDim() > 0) {
791 fXML->NewIntAttr(node, "numdim", elem->GetArrayDim());
792
793 for (int ndim = 0; ndim < elem->GetArrayDim(); ndim++) {
794 snprintf(namebuf, bufferSize, "dim%d", ndim);
795 fXML->NewIntAttr(node, namebuf, elem->GetMaxIndex(ndim));
796 }
797 }
798
799 if (cl == TStreamerBase::Class()) {
800 TStreamerBase *base = (TStreamerBase *)elem;
801 snprintf(sbuf, bufferSize, "%d", base->GetBaseVersion());
802 fXML->NewAttr(node, nullptr, "baseversion", sbuf);
803 snprintf(sbuf, bufferSize, "%d", base->GetBaseCheckSum());
804 fXML->NewAttr(node, nullptr, "basechecksum", sbuf);
805 } else if (cl == TStreamerBasicPointer::Class()) {
807 fXML->NewIntAttr(node, "countversion", bptr->GetCountVersion());
808 fXML->NewAttr(node, nullptr, "countname", bptr->GetCountName());
809 fXML->NewAttr(node, nullptr, "countclass", bptr->GetCountClass());
810 } else if (cl == TStreamerLoop::Class()) {
811 TStreamerLoop *loop = (TStreamerLoop *)elem;
812 fXML->NewIntAttr(node, "countversion", loop->GetCountVersion());
813 fXML->NewAttr(node, nullptr, "countname", loop->GetCountName());
814 fXML->NewAttr(node, nullptr, "countclass", loop->GetCountClass());
815 } else if ((cl == TStreamerSTL::Class()) || (cl == TStreamerSTLstring::Class())) {
816 TStreamerSTL *stl = (TStreamerSTL *)elem;
817 fXML->NewIntAttr(node, "STLtype", stl->GetSTLtype());
818 fXML->NewIntAttr(node, "Ctype", stl->GetCtype());
819 }
820}
821
822////////////////////////////////////////////////////////////////////////////////
823/// read and reconstruct single TStreamerElement from xml node
824
826{
827 TClass *cl = TClass::GetClass(fXML->GetNodeName(node));
828 if (!cl || !cl->InheritsFrom(TStreamerElement::Class()))
829 return;
830
831 TStreamerElement *elem = (TStreamerElement *)cl->New();
832
833 int elem_type = fXML->GetIntAttr(node, "type");
834
835 elem->SetName(fXML->GetAttr(node, "name"));
836 elem->SetTitle(fXML->GetAttr(node, "title"));
837 elem->SetType(elem_type);
838 elem->SetTypeName(fXML->GetAttr(node, "typename"));
839 elem->SetSize(fXML->GetIntAttr(node, "size"));
840
841 if (cl == TStreamerBase::Class()) {
842 int basever = fXML->GetIntAttr(node, "baseversion");
843 ((TStreamerBase *)elem)->SetBaseVersion(basever);
844 Int_t baseCheckSum = fXML->GetIntAttr(node, "basechecksum");
845 ((TStreamerBase *)elem)->SetBaseCheckSum(baseCheckSum);
846 } else if (cl == TStreamerBasicPointer::Class()) {
847 TString countname = fXML->GetAttr(node, "countname");
848 TString countclass = fXML->GetAttr(node, "countclass");
849 Int_t countversion = fXML->GetIntAttr(node, "countversion");
850
851 ((TStreamerBasicPointer *)elem)->SetCountVersion(countversion);
852 ((TStreamerBasicPointer *)elem)->SetCountName(countname);
853 ((TStreamerBasicPointer *)elem)->SetCountClass(countclass);
854 } else if (cl == TStreamerLoop::Class()) {
855 TString countname = fXML->GetAttr(node, "countname");
856 TString countclass = fXML->GetAttr(node, "countclass");
857 Int_t countversion = fXML->GetIntAttr(node, "countversion");
858 ((TStreamerLoop *)elem)->SetCountVersion(countversion);
859 ((TStreamerLoop *)elem)->SetCountName(countname);
860 ((TStreamerLoop *)elem)->SetCountClass(countclass);
861 } else if ((cl == TStreamerSTL::Class()) || (cl == TStreamerSTLstring::Class())) {
862 int fSTLtype = fXML->GetIntAttr(node, "STLtype");
863 int fCtype = fXML->GetIntAttr(node, "Ctype");
864 ((TStreamerSTL *)elem)->SetSTLtype(fSTLtype);
865 ((TStreamerSTL *)elem)->SetCtype(fCtype);
866 }
867
868 char namebuf[100];
869
870 if (fXML->HasAttr(node, "numdim")) {
871 int numdim = fXML->GetIntAttr(node, "numdim");
872 elem->SetArrayDim(numdim);
873 for (int ndim = 0; ndim < numdim; ndim++) {
874 snprintf(namebuf, 100, "dim%d", ndim);
875 int maxi = fXML->GetIntAttr(node, namebuf);
876 elem->SetMaxIndex(ndim, maxi);
877 }
878 }
879
880 elem->SetType(elem_type);
881 elem->SetNewType(elem_type);
882
883 info->GetElements()->Add(elem);
884}
885
886////////////////////////////////////////////////////////////////////////////////
887/// Change layout of objects in xml file
888/// Can be changed only for newly created file.
889///
890/// Currently there are two supported layouts:
891///
892/// TXMLSetup::kSpecialized = 2
893/// This is default layout of the file, when xml nodes names class names and data member
894/// names are used. For instance:
895/// `<TAttLine version="1">`
896/// `<fLineColor v="1"/>`
897/// `<fLineStyle v="1"/>`
898/// `<fLineWidth v="1"/>`
899/// `</TAttLine>`
900///
901/// TXMLSetup::kGeneralized = 3
902/// For this layout all nodes name does not depend from class definitions.
903/// The same class looks like
904/// `<Class name="TAttLine" version="1">`
905/// `<Member name="fLineColor" v="1"/>`
906/// `<Member name="fLineStyle" v="1"/>`
907/// `<Member name="fLineWidth" v="1"/>`
908/// `</Member>`
909///
910
912{
913 if (IsWritable() && (GetListOfKeys()->GetSize() == 0))
915}
916
917////////////////////////////////////////////////////////////////////////////////
918/// If true, all correspondent to file TStreamerInfo objects will be stored in file
919/// this allows to apply schema evolution later for this file
920/// may be useful, when file used outside ROOT and TStreamerInfo objects does not required
921/// Can be changed only for newly created file.
922
924{
925 if (IsWritable() && (GetListOfKeys()->GetSize() == 0))
927}
928
929////////////////////////////////////////////////////////////////////////////////
930/// Specify usage of DTD for this file.
931/// Currently this option not available (always false).
932/// Can be changed only for newly created file.
933
935{
936 if (IsWritable() && (GetListOfKeys()->GetSize() == 0))
938}
939
940////////////////////////////////////////////////////////////////////////////////
941/// Specify usage of namespaces in xml file
942/// In current implementation every instrumented class in file gets its unique namespace,
943/// which is equal to name of class and refer to root documentation page like
944/// `<TAttPad xmlns:TAttPad="http://root.cern/root/htmldoc/TAttPad.html" version="3">`
945/// And xml node for class member gets its name as combination of class name and member name
946/// `<TAttPad:fLeftMargin v="0.100000"/>`
947/// `<TAttPad:fRightMargin v="0.100000"/>`
948/// `<TAttPad:fBottomMargin v="0.100000"/>`
949/// and so on
950/// Usage of namespace increase size of xml file, but makes file more readable
951/// and allows to produce DTD in the case, when in several classes data member has same name
952/// Can be changed only for newly created file.
953
955{
956 if (IsWritable() && (GetListOfKeys()->GetSize() == 0))
957 TXMLSetup::SetUseNamespaces(iUseNamespaces);
958}
959
960////////////////////////////////////////////////////////////////////////////////
961/// Add comment line on the top of the xml document
962/// This line can only be seen in xml editor and cannot be accessed later
963/// with TXMLFile methods
964
965Bool_t TXMLFile::AddXmlComment(const char *comment)
966{
967 if (!IsWritable())
968 return kFALSE;
969
970 return fXML->AddDocComment(fDoc, comment);
971}
972
973////////////////////////////////////////////////////////////////////////////////
974/// Adds style sheet definition on the top of xml document
975/// Creates <?xml-stylesheet alternate="yes" title="compact" href="small-base.css" type="text/css"?>
976/// Attributes href and type must be supplied,
977/// other attributes: title, alternate, media, charset are optional
978/// if alternate==0, attribute alternate="no" will be created,
979/// if alternate>0, attribute alternate="yes"
980/// if alternate<0, attribute will not be created
981/// This style sheet definition cannot be later access with TXMLFile methods.
982
983Bool_t TXMLFile::AddXmlStyleSheet(const char *href, const char *type, const char *title, int alternate,
984 const char *media, const char *charset)
985{
986 if (!IsWritable())
987 return kFALSE;
988
989 return fXML->AddDocStyleSheet(fDoc, href, type, title, alternate, media, charset);
990}
991
992////////////////////////////////////////////////////////////////////////////////
993/// Add just one line on the top of xml document
994/// For instance, line can contain special xml processing instructions
995/// Line should has correct xml syntax that later it can be decoded by xml parser
996/// To be parsed later by TXMLFile again, this line should contain either
997/// xml comments or xml processing instruction
998
1000{
1001 if (!IsWritable())
1002 return kFALSE;
1003
1004 return fXML->AddDocRawLine(fDoc, line);
1005}
1006
1007////////////////////////////////////////////////////////////////////////////////
1008/// Create key for directory entry in the key
1009
1011{
1012 TDirectory *mother = dir->GetMotherDir();
1013 if (!mother)
1014 mother = this;
1015
1016 TKeyXML *key = new TKeyXML(mother, ++fKeyCounter, dir, dir->GetName(), dir->GetTitle());
1017
1018 key->SetSubir();
1019
1020 return key->GetKeyId();
1021}
1022
1023////////////////////////////////////////////////////////////////////////////////
1024/// Search for key which correspond to directory dir
1025
1027{
1028 TDirectory *motherdir = dir->GetMotherDir();
1029 if (!motherdir)
1030 motherdir = this;
1031
1032 TIter next(motherdir->GetListOfKeys());
1033 TObject *obj = nullptr;
1034
1035 while ((obj = next()) != nullptr) {
1036 TKeyXML *key = dynamic_cast<TKeyXML *>(obj);
1037
1038 if (key)
1039 if (key->GetKeyId() == dir->GetSeekDir())
1040 return key;
1041 }
1042
1043 return nullptr;
1044}
1045
1046////////////////////////////////////////////////////////////////////////////////
1047/// Find a directory in motherdir with a seek equal to keyid
1048
1050{
1051 if (!motherdir)
1052 motherdir = this;
1053
1054 TIter next(motherdir->GetList());
1055 TObject *obj = nullptr;
1056
1057 while ((obj = next()) != nullptr) {
1058 TDirectory *dir = dynamic_cast<TDirectory *>(obj);
1059 if (dir)
1060 if (dir->GetSeekDir() == keyid)
1061 return dir;
1062 }
1063
1064 return nullptr;
1065}
1066
1067////////////////////////////////////////////////////////////////////////////////
1068/// Read keys for directory
1069/// Make sense only once, while next time no new subnodes will be created
1070
1072{
1073 TKeyXML *key = FindDirKey(dir);
1074 if (!key)
1075 return 0;
1076
1077 return ReadKeysList(dir, key->KeyNode());
1078}
1079
1080////////////////////////////////////////////////////////////////////////////////
1081/// Update key attributes
1082
1084{
1085 TIter next(GetListOfKeys());
1086 TObject *obj = nullptr;
1087
1088 while ((obj = next()) != nullptr) {
1089 TKeyXML *key = dynamic_cast<TKeyXML *>(obj);
1090 if (key)
1091 key->UpdateAttributes();
1092 }
1093}
1094
1095////////////////////////////////////////////////////////////////////////////////
1096/// Write the directory header
1097
1099{
1100 TKeyXML *key = FindDirKey(dir);
1101 if (key)
1102 key->UpdateObject(dir);
1103}
virtual RooAbsTestStatistic * create(const char *name, const char *title, RooAbsReal &real, RooAbsData &data, const RooArgSet &projDeps, Configuration const &cfg)=0
static void update(gsl_integration_workspace *workspace, double a1, double b1, double area1, double error1, double a2, double b2, double area2, double error2)
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
long long Long64_t
Definition RtypesCore.h:80
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:377
#define gDirectory
Definition TDirectory.h:384
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
Definition TError.cxx:218
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:185
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:244
Option_t Option_t option
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 filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
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 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 type
char name[80]
Definition TGX11.cxx:110
Int_t gDebug
Definition TROOT.cxx:595
R__EXTERN TVirtualMutex * gROOTMutex
Definition TROOT.h:63
#define gROOT
Definition TROOT.h:406
@ kFileExists
Definition TSystem.h:42
@ kReadPermission
Definition TSystem.h:45
@ kWritePermission
Definition TSystem.h:44
R__EXTERN TSystem * gSystem
Definition TSystem.h:555
#define R__LOCKGUARD(mutex)
void * XMLNodePointer_t
Definition TXMLEngine.h:17
#define snprintf
Definition civetweb.c:1540
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:81
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Return a pointer to a newly allocated object of this class.
Definition TClass.cxx:4978
Bool_t InheritsFrom(const char *cl) const override
Return kTRUE if this class inherits from a class with name "classname".
Definition TClass.cxx:4874
Version_t GetClassVersion() const
Definition TClass.h:418
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:2968
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:76
Double_t fSum2Buffer
Sum of squares of buffer sizes of objects written so far.
Definition TFile.h:74
virtual void ReadStreamerInfo()
Read the list of StreamerInfo from this file.
Definition TFile.cxx:3583
TArrayC * fClassIndex
!Index of TStreamerInfo classes written to this file
Definition TFile.h:94
Long64_t fSeekInfo
Location on disk of StreamerInfo record.
Definition TFile.h:81
Int_t fVersion
File format version.
Definition TFile.h:83
Int_t fNbytesInfo
Number of bytes for StreamerInfo record.
Definition TFile.h:86
virtual void SetCompressionSettings(Int_t settings=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault)
Used to specify the compression level and algorithm.
Definition TFile.cxx:2316
Int_t GetCompressionLevel() const
Definition TFile.h:384
TString fOption
File options.
Definition TFile.h:91
Int_t fD
File descriptor.
Definition TFile.h:82
Char_t fUnits
Number of bytes for file pointers.
Definition TFile.h:92
TObjArray * fProcessIDs
!Array of pointers to TProcessIDs
Definition TFile.h:95
Long64_t fBytesWrite
Number of bytes written to this file.
Definition TFile.h:75
TList * fFree
Free segments linked list table.
Definition TFile.h:93
TString fRealName
Effective real file name (not original url)
Definition TFile.h:90
Double_t fSumBuffer
Sum of buffer sizes of objects written so far.
Definition TFile.h:73
@ kReproducible
Definition TFile.h:190
@ kDevNull
Definition TFile.h:186
@ kBinaryFile
Definition TFile.h:188
Int_t fNProcessIDs
Number of TProcessID written to this file.
Definition TFile.h:88
Int_t fWritten
Number of objects written so far.
Definition TFile.h:87
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:75
A doubly linked list.
Definition TList.h:38
void Add(TObject *obj) override
Definition TList.h:81
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
Definition TList.cxx:468
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:164
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:48
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition TNamed.cxx:140
An array of TObjects.
Definition TObjArray.h:31
TObject * At(Int_t idx) const override
Definition TObjArray.h:164
Int_t GetLast() const override
Return index of last object in array.
void Add(TObject *obj) override
Definition TObjArray.h:68
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:780
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
void Clear(Option_t *option="") override
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()
static TClass * Class()
static TClass * Class()
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
TClass * IsA() const override
virtual void SetType(Int_t dtype)
virtual void SetTypeName(const char *name)
static TClass * Class()
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.
Int_t GetClassVersion() const override
Int_t GetNumber() const override
TClass * IsA() const override
void SetClassVersion(Int_t vers) override
void SetOnFileClassVersion(Int_t vers)
void SetCheckSum(UInt_t checksum) override
TObjArray * GetElements() const override
UInt_t GetCheckSum() const override
const char * GetCountName() const
Int_t GetCountVersion() const
const char * GetCountClass() const
static TClass * Class()
Int_t GetCtype() const
Int_t GetSTLtype() const
static TClass * Class()
static TClass * Class()
Basic string class.
Definition TString.h:139
Ssiz_t Length() const
Definition TString.h:417
void ToLower()
Change string to lower-case.
Definition TString.cxx:1182
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
Definition TString.h:694
const char * Data() const
Definition TString.h:376
void ToUpper()
Change string to upper case.
Definition TString.cxx:1195
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:632
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:571
~TXMLFile() override
destructor of TXMLFile object
Definition TXMLFile.cxx:355
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:983
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:999
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:911
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:923
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:954
Int_t GetIOVersion() const
Definition TXMLFile.h:73
static constexpr Version_t Class_Version()
counter of created keys, used for keys id
Definition TXMLFile.h:140
void SetUsedDtd(Bool_t use=kTRUE) final
Specify usage of DTD for this file.
Definition TXMLFile.cxx:934
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:825
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:965
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:145