Logo ROOT   6.12/07
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 "TBufferXML.h"
82 #include "TKeyXML.h"
83 #include "TObjArray.h"
84 #include "TArrayC.h"
85 #include "TStreamerInfo.h"
86 #include "TStreamerElement.h"
87 #include "TProcessID.h"
88 #include "TError.h"
89 #include "TClass.h"
90 #include "TVirtualMutex.h"
91 
93 
94 ////////////////////////////////////////////////////////////////////////////////
95 /// default TXMLFile constructor
96 
97 TXMLFile::TXMLFile() : TFile(), TXMLSetup(), fDoc(0), fStreamerInfoNode(0), fXML(0), fKeyCounter(0)
98 {
100  fIOVersion = TXMLFile::Class_Version();
101 }
102 
103 ////////////////////////////////////////////////////////////////////////////////
104 /// Open or creates local XML file with name filename.
105 /// It is recommended to specify filename as "<file>.xml". The suffix ".xml"
106 /// will be used by object browsers to automatically identify the file as
107 /// a XML file. If the constructor fails in any way IsZombie() will
108 /// return true. Use IsOpen() to check if the file is (still) open.
109 ///
110 /// If option = NEW or CREATE create a new file and open it for writing,
111 /// if the file already exists the file is
112 /// not opened.
113 /// = RECREATE create a new file, if the file already
114 /// exists it will be overwritten.
115 /// = 2xoo create a new file with specified xml settings
116 /// for more details see TXMLSetup class
117 /// = UPDATE open an existing file for writing.
118 /// if no file exists, it is created.
119 /// = READ open an existing file for reading.
120 ///
121 /// For more details see comments for TFile::TFile() constructor
122 ///
123 /// For a moment TXMLFile does not support TTree objects and subdirectories
124 
125 TXMLFile::TXMLFile(const char *filename, Option_t *option, const char *title, Int_t compression)
126  : TFile(), TXMLSetup(), fDoc(0), fStreamerInfoNode(0), fXML(0), fKeyCounter(0)
127 {
128  fXML = new TXMLEngine();
129 
130  if (!gROOT)
131  ::Fatal("TFile::TFile", "ROOT system not initialized");
132 
133  if (filename && !strncmp(filename, "xml:", 4))
134  filename += 4;
135 
136  gDirectory = 0;
137  SetName(filename);
138  SetTitle(title);
139  TDirectoryFile::Build(this, 0);
140 
141  fD = -1;
142  fFile = this;
143  fFree = 0;
144  fVersion = gROOT->GetVersionInt(); // ROOT version in integer format
145  fUnits = 4;
146  fOption = option;
147  SetCompressionSettings(compression);
148  fWritten = 0;
149  fSumBuffer = 0;
150  fSum2Buffer = 0;
151  fBytesRead = 0;
152  fBytesWrite = 0;
153  fClassIndex = 0;
154  fSeekInfo = 0;
155  fNbytesInfo = 0;
156  fProcessIDs = 0;
157  fNProcessIDs = 0;
158  fIOVersion = TXMLFile::Class_Version();
160 
161  fOption = option;
162  fOption.ToUpper();
163 
164  if (fOption == "NEW")
165  fOption = "CREATE";
166 
167  Bool_t create = (fOption == "CREATE") ? kTRUE : kFALSE;
168  Bool_t recreate = (fOption == "RECREATE") ? kTRUE : kFALSE;
169  Bool_t update = (fOption == "UPDATE") ? kTRUE : kFALSE;
170  Bool_t read = (fOption == "READ") ? kTRUE : kFALSE;
171  Bool_t xmlsetup = IsValidXmlSetup(option);
172  if (xmlsetup)
173  recreate = kTRUE;
174 
175  if (!create && !recreate && !update && !read) {
176  read = kTRUE;
177  fOption = "READ";
178  }
179 
180  Bool_t devnull = kFALSE;
181  const char *fname = 0;
182 
183  if (!filename || !filename[0]) {
184  Error("TXMLFile", "file name is not specified");
185  goto zombie;
186  }
187 
188  // support dumping to /dev/null on UNIX
189  if (!strcmp(filename, "/dev/null") && !gSystem->AccessPathName(filename, kWritePermission)) {
190  devnull = kTRUE;
191  create = kTRUE;
192  recreate = kFALSE;
193  update = kFALSE;
194  read = kFALSE;
195  fOption = "CREATE";
197  }
198 
199  gROOT->cd();
200 
201  fname = gSystem->ExpandPathName(filename);
202  if (fname) {
203  SetName(fname);
204  delete[](char *) fname;
205  fname = GetName();
206  } else {
207  Error("TXMLFile", "error expanding path %s", filename);
208  goto zombie;
209  }
210 
211  if (recreate) {
212  if (!gSystem->AccessPathName(fname, kFileExists))
213  gSystem->Unlink(fname);
214  recreate = kFALSE;
215  create = kTRUE;
216  fOption = "CREATE";
217  }
218 
219  if (create && !devnull && !gSystem->AccessPathName(fname, kFileExists)) {
220  Error("TXMLFile", "file %s already exists", fname);
221  goto zombie;
222  }
223 
224  if (update) {
225  if (gSystem->AccessPathName(fname, kFileExists)) {
226  update = kFALSE;
227  create = kTRUE;
228  }
229  if (update && gSystem->AccessPathName(fname, kWritePermission)) {
230  Error("TXMLFile", "no write permission, could not open file %s", fname);
231  goto zombie;
232  }
233  }
234 
235  if (read) {
236  if (gSystem->AccessPathName(fname, kFileExists)) {
237  Error("TXMLFile", "file %s does not exist", fname);
238  goto zombie;
239  }
240  if (gSystem->AccessPathName(fname, kReadPermission)) {
241  Error("TXMLFile", "no read permission, could not open file %s", fname);
242  goto zombie;
243  }
244  }
245 
246  fRealName = fname;
247 
248  if (create || update)
250  else
252 
253  if (create) {
254  if (xmlsetup)
255  ReadSetupFromStr(option);
256  else
258  }
259 
260  InitXmlFile(create);
261 
262  return;
263 
264 zombie:
265  MakeZombie();
266  gDirectory = gROOT;
267 }
268 
269 ////////////////////////////////////////////////////////////////////////////////
270 /// initialize xml file and correspondent structures
271 /// identical to TFile::Init() function
272 
274 {
275  Int_t len = gROOT->GetListOfStreamerInfo()->GetSize() + 1;
276  if (len < 5000)
277  len = 5000;
278  fClassIndex = new TArrayC(len);
279  fClassIndex->Reset(0);
280 
281  if (create) {
282  fDoc = fXML->NewDoc();
283  XMLNodePointer_t fRootNode = fXML->NewChild(0, 0, xmlio::Root, 0);
284  fXML->DocSetRootElement(fDoc, fRootNode);
285  } else {
286  ReadFromFile();
287  }
288 
289  {
291  gROOT->GetListOfFiles()->Add(this);
292  }
293  cd();
294 
295  fNProcessIDs = 0;
296  TKey *key = 0;
297  TIter iter(fKeys);
298  while ((key = (TKey *)iter()) != 0) {
299  if (!strcmp(key->GetClassName(), "TProcessID"))
300  fNProcessIDs++;
301  }
302 
304 }
305 
306 ////////////////////////////////////////////////////////////////////////////////
307 /// Close a XML file
308 /// For more comments see TFile::Close() function
309 
311 {
312  if (!IsOpen())
313  return;
314 
315  TString opt = option;
316  if (opt.Length() > 0)
317  opt.ToLower();
318 
319  if (IsWritable())
320  SaveToFile();
321 
322  fWritable = kFALSE;
323 
324  if (fDoc) {
325  fXML->FreeDoc(fDoc);
326  fDoc = 0;
327  }
328 
329  if (fClassIndex) {
330  delete fClassIndex;
331  fClassIndex = 0;
332  }
333 
334  if (fStreamerInfoNode) {
336  fStreamerInfoNode = 0;
337  }
338 
339  {
340  TDirectory::TContext ctxt(this);
341  // Delete all supported directories structures from memory
343  }
344 
345  // delete the TProcessIDs
346  TList pidDeleted;
347  TIter next(fProcessIDs);
348  TProcessID *pid;
349  while ((pid = (TProcessID *)next())) {
350  if (!pid->DecrementCount()) {
351  if (pid != TProcessID::GetSessionProcessID())
352  pidDeleted.Add(pid);
353  } else if (opt.Contains("r")) {
354  pid->Clear();
355  }
356  }
357  pidDeleted.Delete();
358 
360  gROOT->GetListOfFiles()->Remove(this);
361 }
362 
363 ////////////////////////////////////////////////////////////////////////////////
364 /// destructor of TXMLFile object
365 
367 {
368  Close();
369 
370  if (fXML != 0) {
371  delete fXML;
372  fXML = 0;
373  }
374 }
375 
376 ////////////////////////////////////////////////////////////////////////////////
377 /// make private to exclude copy operator
378 
380 {
381 }
382 
383 ////////////////////////////////////////////////////////////////////////////////
384 /// return kTRUE if file is opened and can be accessed
385 
387 {
388  return fDoc != 0;
389 }
390 
391 ////////////////////////////////////////////////////////////////////////////////
392 /// Reopen a file with a different access mode, like from READ to
393 /// See TFile::Open() for details
394 
396 {
397  cd();
398 
399  TString opt = mode;
400  opt.ToUpper();
401 
402  if (opt != "READ" && opt != "UPDATE") {
403  Error("ReOpen", "mode must be either READ or UPDATE, not %s", opt.Data());
404  return 1;
405  }
406 
407  if (opt == fOption || (opt == "UPDATE" && fOption == "CREATE"))
408  return 1;
409 
410  if (opt == "READ") {
411  // switch to READ mode
412 
413  if (IsOpen() && IsWritable())
414  SaveToFile();
415  fOption = opt;
416 
418 
419  } else {
420  fOption = opt;
421 
423  }
424 
425  return 0;
426 }
427 
428 ////////////////////////////////////////////////////////////////////////////////
429 /// create XML key, which will store object in xml structures
430 
431 TKey *TXMLFile::CreateKey(TDirectory *mother, const TObject *obj, const char *name, Int_t)
432 {
433  return new TKeyXML(mother, ++fKeyCounter, obj, name);
434 }
435 
436 ////////////////////////////////////////////////////////////////////////////////
437 /// create XML key, which will store object in xml structures
438 
439 TKey *TXMLFile::CreateKey(TDirectory *mother, const void *obj, const TClass *cl, const char *name, Int_t)
440 {
441  return new TKeyXML(mother, ++fKeyCounter, obj, cl, name);
442 }
443 
444 ////////////////////////////////////////////////////////////////////////////////
445 /// function produces pair of xml and dtd file names
446 
447 void TXMLFile::ProduceFileNames(const char *filename, TString &fname, TString &dtdname)
448 {
449  fname = filename;
450  dtdname = filename;
451 
452  Bool_t hasxmlext = kFALSE;
453 
454  if (fname.Length() > 4) {
455  TString last = fname(fname.Length() - 4, 4);
456  last.ToLower();
457  hasxmlext = (last == ".xml");
458  }
459 
460  if (hasxmlext) {
461  dtdname.Replace(dtdname.Length() - 4, 4, ".dtd");
462  } else {
463  fname += ".xml";
464  dtdname += ".dtd";
465  }
466 }
467 
468 ////////////////////////////////////////////////////////////////////////////////
469 /// Saves xml structures to the file
470 /// xml elements are kept in list of TKeyXML objects
471 /// When saving, all this elements are linked to root xml node
472 /// At the end StreamerInfo structures are added
473 /// After xml document is saved, all nodes will be unlinked from root node
474 /// and kept in memory.
475 /// Only Close() or destructor release memory, used by xml structures
476 
478 {
479  if (fDoc == 0)
480  return;
481 
482  if (gDebug > 1)
483  Info("SaveToFile", "File: %s", fRealName.Data());
484 
486 
487  fXML->FreeAttr(fRootNode, xmlio::Setup);
488  fXML->NewAttr(fRootNode, 0, xmlio::Setup, GetSetupAsString());
489 
490  fXML->FreeAttr(fRootNode, xmlio::Ref);
491  fXML->NewAttr(fRootNode, 0, xmlio::Ref, xmlio::Null);
492 
493  if (GetIOVersion() > 1) {
494 
495  fXML->FreeAttr(fRootNode, xmlio::CreateTm);
496  fXML->NewAttr(fRootNode, 0, xmlio::CreateTm, fDatimeC.AsSQLString());
497 
498  fXML->FreeAttr(fRootNode, xmlio::ModifyTm);
499  fXML->NewAttr(fRootNode, 0, xmlio::ModifyTm, fDatimeM.AsSQLString());
500 
501  fXML->FreeAttr(fRootNode, xmlio::ObjectUUID);
502  fXML->NewAttr(fRootNode, 0, xmlio::ObjectUUID, fUUID.AsString());
503 
504  fXML->FreeAttr(fRootNode, xmlio::Title);
505  if (strlen(GetTitle()) > 0)
506  fXML->NewAttr(fRootNode, 0, xmlio::Title, GetTitle());
507 
508  fXML->FreeAttr(fRootNode, xmlio::IOVersion);
510 
511  fXML->FreeAttr(fRootNode, "file_version");
512  fXML->NewIntAttr(fRootNode, "file_version", fVersion);
513  }
514 
515  TString fname, dtdname;
516  ProduceFileNames(fRealName, fname, dtdname);
517 
518  /*
519  TIter iter(GetListOfKeys());
520  TKeyXML* key = 0;
521  while ((key=(TKeyXML*)iter()) !=0)
522  fXML->AddChild(fRootNode, key->KeyNode());
523  */
524 
525  CombineNodesTree(this, fRootNode, kTRUE);
526 
528 
529  if (fStreamerInfoNode)
530  fXML->AddChild(fRootNode, fStreamerInfoNode);
531 
532  Int_t layout = GetCompressionLevel() > 5 ? 0 : 1;
533 
534  fXML->SaveDoc(fDoc, fname, layout);
535 
536  /* iter.Reset();
537  while ((key=(TKeyXML*)iter()) !=0)
538  fXML->UnlinkNode(key->KeyNode());
539  */
540  CombineNodesTree(this, fRootNode, kFALSE);
541 
542  if (fStreamerInfoNode)
544 }
545 
546 ////////////////////////////////////////////////////////////////////////////////
547 /// Connect/disconnect all file nodes to single tree before/after saving
548 
550 {
551  if (dir == 0)
552  return;
553 
554  TIter iter(dir->GetListOfKeys());
555  TKeyXML *key = 0;
556 
557  while ((key = (TKeyXML *)iter()) != 0) {
558  if (dolink)
559  fXML->AddChild(topnode, key->KeyNode());
560  else
561  fXML->UnlinkNode(key->KeyNode());
562  if (key->IsSubdir())
563  CombineNodesTree(FindKeyDir(dir, key->GetKeyId()), key->KeyNode(), dolink);
564  }
565 }
566 
567 ////////////////////////////////////////////////////////////////////////////////
568 /// read document from file
569 /// Now full content of document reads into the memory
570 /// Then document decomposed to separate keys and streamer info structures
571 /// All irrelevant data will be cleaned
572 
574 {
576  if (fDoc == 0)
577  return kFALSE;
578 
580 
581  if ((fRootNode == 0) || !fXML->ValidateVersion(fDoc)) {
582  fXML->FreeDoc(fDoc);
583  fDoc = 0;
584  return kFALSE;
585  }
586 
588 
589  if (fXML->HasAttr(fRootNode, xmlio::CreateTm)) {
590  TDatime tm(fXML->GetAttr(fRootNode, xmlio::CreateTm));
591  fDatimeC = tm;
592  }
593 
594  if (fXML->HasAttr(fRootNode, xmlio::ModifyTm)) {
595  TDatime tm(fXML->GetAttr(fRootNode, xmlio::ModifyTm));
596  fDatimeM = tm;
597  }
598 
599  if (fXML->HasAttr(fRootNode, xmlio::ObjectUUID)) {
600  TUUID id(fXML->GetAttr(fRootNode, xmlio::ObjectUUID));
601  fUUID = id;
602  }
603 
604  if (fXML->HasAttr(fRootNode, xmlio::Title))
605  SetTitle(fXML->GetAttr(fRootNode, xmlio::Title));
606 
607  if (fXML->HasAttr(fRootNode, xmlio::IOVersion))
609  else
610  fIOVersion = 1;
611 
612  if (fXML->HasAttr(fRootNode, "file_version"))
613  fVersion = fXML->GetIntAttr(fRootNode, "file_version");
614 
615  fStreamerInfoNode = fXML->GetChild(fRootNode);
617  while (fStreamerInfoNode != 0) {
618  if (strcmp(xmlio::SInfos, fXML->GetNodeName(fStreamerInfoNode)) == 0)
619  break;
621  }
623 
624  if (fStreamerInfoNode != 0)
626 
627  if (IsUseDtd())
628  if (!fXML->ValidateDocument(fDoc, gDebug > 0)) {
629  fXML->FreeDoc(fDoc);
630  fDoc = 0;
631  return kFALSE;
632  }
633 
634  ReadKeysList(this, fRootNode);
635 
636  fXML->CleanNode(fRootNode);
637 
638  return kTRUE;
639 }
640 
641 ////////////////////////////////////////////////////////////////////////////////
642 /// Read list of keys for directory
643 
645 {
646  if ((dir == 0) || (topnode == 0))
647  return 0;
648 
649  Int_t nkeys = 0;
650 
651  XMLNodePointer_t keynode = fXML->GetChild(topnode);
652  fXML->SkipEmpty(keynode);
653  while (keynode != 0) {
654  XMLNodePointer_t next = fXML->GetNext(keynode);
655 
656  if (strcmp(xmlio::Xmlkey, fXML->GetNodeName(keynode)) == 0) {
657  fXML->UnlinkNode(keynode);
658 
659  TKeyXML *key = new TKeyXML(dir, ++fKeyCounter, keynode);
660  dir->AppendKey(key);
661 
662  if (gDebug > 2)
663  Info("ReadKeysList", "Add key %s from node %s", key->GetName(), fXML->GetNodeName(keynode));
664 
665  nkeys++;
666  }
667 
668  keynode = next;
669  fXML->SkipEmpty(keynode);
670  }
671 
672  return nkeys;
673 }
674 
675 ////////////////////////////////////////////////////////////////////////////////
676 /// convert all TStreamerInfo, used in file, to xml format
677 
679 {
680  if (fStreamerInfoNode) {
682  fStreamerInfoNode = 0;
683  }
684 
685  if (!IsStoreStreamerInfos())
686  return;
687 
688  TObjArray list;
689 
690  TIter iter(gROOT->GetListOfStreamerInfo());
691 
692  TStreamerInfo *info = 0;
693 
694  while ((info = (TStreamerInfo *)iter()) != 0) {
695  Int_t uid = info->GetNumber();
696  if (fClassIndex->fArray[uid])
697  list.Add(info);
698  }
699 
700  if (list.GetSize() == 0)
701  return;
702 
704  for (int n = 0; n <= list.GetLast(); n++) {
705  info = (TStreamerInfo *)list.At(n);
706 
707  XMLNodePointer_t infonode = fXML->NewChild(fStreamerInfoNode, 0, "TStreamerInfo");
708 
709  fXML->NewAttr(infonode, 0, "name", info->GetName());
710  fXML->NewAttr(infonode, 0, "title", info->GetTitle());
711 
712  fXML->NewIntAttr(infonode, "v", info->IsA()->GetClassVersion());
713  fXML->NewIntAttr(infonode, "classversion", info->GetClassVersion());
714  fXML->NewAttr(infonode, 0, "canoptimize",
716  fXML->NewIntAttr(infonode, "checksum", info->GetCheckSum());
717 
718  TIter iter2(info->GetElements());
719  TStreamerElement *elem = 0;
720  while ((elem = (TStreamerElement *)iter2()) != 0) {
721  StoreStreamerElement(infonode, elem);
722  }
723  }
724 }
725 
726 ////////////////////////////////////////////////////////////////////////////////
727 /// Read streamerinfo structures from xml format and provide them in the list
728 /// It is user responsibility to destroy this list
729 
731 {
732  if (fStreamerInfoNode == 0)
733  return 0;
734 
735  TList *list = new TList();
736 
738  fXML->SkipEmpty(sinfonode);
739 
740  while (sinfonode != 0) {
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 == 0) || (strcmp(canoptimize, xmlio::False) == 0))
759  else
761 
762  XMLNodePointer_t node = fXML->GetChild(sinfonode);
763  fXML->SkipEmpty(node);
764  while (node != 0) {
765  ReadStreamerElement(node, info);
766  fXML->ShiftToNext(node);
767  }
768  }
769  fXML->ShiftToNext(sinfonode);
770  }
771 
772  list->SetOwner();
773 
774  return list;
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, 0, cl->GetName());
785 
786  char sbuf[100], namebuf[100];
787 
788  fXML->NewAttr(node, 0, "name", elem->GetName());
789  if (strlen(elem->GetTitle()) > 0)
790  fXML->NewAttr(node, 0, "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, 0, "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, 0, "baseversion", sbuf);
814  sprintf(sbuf, "%d", base->GetBaseCheckSum());
815  fXML->NewAttr(node, 0, "basechecksum", sbuf);
816  } else if (cl == TStreamerBasicPointer::Class()) {
818  fXML->NewIntAttr(node, "countversion", bptr->GetCountVersion());
819  fXML->NewAttr(node, 0, "countname", bptr->GetCountName());
820  fXML->NewAttr(node, 0, "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, 0, "countname", loop->GetCountName());
825  fXML->NewAttr(node, 0, "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 == 0) || !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 == 0))
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 == 0))
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 == 0))
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 == 0)
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 == 0)
1041  motherdir = this;
1042 
1043  TIter next(motherdir->GetListOfKeys());
1044  TObject *obj = 0;
1045 
1046  while ((obj = next()) != 0) {
1047  TKeyXML *key = dynamic_cast<TKeyXML *>(obj);
1048 
1049  if (key != 0)
1050  if (key->GetKeyId() == dir->GetSeekDir())
1051  return key;
1052  }
1053 
1054  return 0;
1055 }
1056 
1057 ////////////////////////////////////////////////////////////////////////////////
1058 /// Find a directory in motherdir with a seek equal to keyid
1059 
1061 {
1062  if (motherdir == 0)
1063  motherdir = this;
1064 
1065  TIter next(motherdir->GetList());
1066  TObject *obj = 0;
1067 
1068  while ((obj = next()) != 0) {
1069  TDirectory *dir = dynamic_cast<TDirectory *>(obj);
1070  if (dir != 0)
1071  if (dir->GetSeekDir() == keyid)
1072  return dir;
1073  }
1074 
1075  return 0;
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 == 0)
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 = 0;
1098 
1099  while ((obj = next()) != 0) {
1100  TKeyXML *key = dynamic_cast<TKeyXML *>(obj);
1101  if (key != 0)
1102  key->UpdateAttributes();
1103  }
1104 }
1105 
1106 ////////////////////////////////////////////////////////////////////////////////
1107 /// Write the directory header
1108 
1110 {
1111  TKeyXML *key = FindDirKey(dir);
1112  if (key != 0)
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:103
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:395
const char * GetCountClass() const
An array of TObjects.
Definition: TObjArray.h:37
Char_t fUnits
Number of bytes for file pointers.
Definition: TFile.h:85
void SetSubir()
Definition: TKeyXML.h:63
virtual ~TXMLFile()
destructor of TXMLFile object
Definition: TXMLFile.cxx:366
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:88
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:68
Long64_t GetKeyId() const
Definition: TKeyXML.h:61
Double_t fSumBuffer
Sum of buffer sizes of objects written so far.
Definition: TFile.h:66
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:87
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:128
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:46
void ToUpper()
Change string to upper case.
Definition: TString.cxx:1112
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:386
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:402
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:125
const char * Setup
Definition: TXMLSetup.cxx:47
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1099
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:310
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:431
Long64_t fSeekInfo
Location on disk of StreamerInfo record.
Definition: TFile.h:74
Int_t fIOVersion
object for interface with xml library
Definition: TXMLFile.h:134
Int_t GetIOVersion() const
Definition: TXMLFile.h:71
TXMLEngine * fXML
pointer of node with streamer info data
Definition: TXMLFile.h:132
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:628
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:79
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:130
TDatime fDatimeC
Date and time when directory is created.
Int_t fD
File descriptor.
Definition: TFile.h:75
void Class()
Definition: Class.C:29
TString fRealName
Effective real file name (not original url)
Definition: TFile.h:83
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:379
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:136
void InitXmlFile(Bool_t create)
initialize xml file and correspondent structures identical to TFile::Init() function ...
Definition: TXMLFile.cxx:273
void SaveToFile()
Saves xml structures to the file xml elements are kept in list of TKeyXML objects When saving...
Definition: TXMLFile.cxx:477
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:549
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:207
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:644
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:222
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:880
Ssiz_t Length() const
Definition: TString.h:386
Int_t DecrementCount()
The reference fCount is used to delete the TProcessID in the TFile destructor when fCount = 0...
Definition: TProcessID.cxx:222
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:938
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:447
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:884
virtual void ReadStreamerInfo()
Read the list of StreamerInfo from this file.
Definition: TFile.cxx:3476
Double_t fSum2Buffer
Sum of squares of buffer sizes of objects written so far.
Definition: TFile.h:67
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:86
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:847
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:202
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:570
#define R__LOCKGUARD(mutex)
virtual TList * GetStreamerInfoList()
Read streamerinfo structures from xml format and provide them in the list It is user responsibility t...
Definition: TXMLFile.cxx:730
TString fOption
File options.
Definition: TFile.h:84
static TProcessID * GetSessionProcessID()
static function returning the pointer to the session TProcessID
Definition: TProcessID.cxx:275
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
Definition: TXMLEngine.cxx:986
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:2215
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:573
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:97
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:81
virtual void SetNewType(Int_t dtype)
void UnlinkNode(XMLNodePointer_t node)
unlink (detach) xmlnode from parent
Definition: TXMLEngine.cxx:957
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:76
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:80
virtual Long64_t GetSize() const
Returns the current file size.
Definition: TXMLFile.h:69
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
Definition: TCollection.h:180
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:372
Long64_t fBytesRead
Number of bytes read from this file.
Definition: TFile.h:69
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:678
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:345
Array of chars or bytes (8 bits per element).
Definition: TArrayC.h:27