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