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