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