File indexing completed on 2025-01-18 10:12:35
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TXMLFile
0013 #define ROOT_TXMLFile
0014
0015 #include "TFile.h"
0016 #include "TXMLSetup.h"
0017 #include "TXMLEngine.h"
0018 #include "Compression.h"
0019 #include <memory>
0020
0021 class TKeyXML;
0022 class TStreamerElement;
0023 class TStreamerInfo;
0024
0025 class TXMLFile final : public TFile, public TXMLSetup {
0026
0027 protected:
0028 void InitXmlFile(Bool_t create);
0029
0030 Int_t SysOpen(const char *, Int_t, UInt_t) final { return 0; }
0031 Int_t SysClose(Int_t) final { return 0; }
0032 Int_t SysRead(Int_t, void *, Int_t) final { return 0; }
0033 Int_t SysWrite(Int_t, const void *, Int_t) final { return 0; }
0034 Long64_t SysSeek(Int_t, Long64_t, Int_t) final { return 0; }
0035 Int_t SysStat(Int_t, Long_t *, Long64_t *, Long_t *, Long_t *) final { return 0; }
0036 Int_t SysSync(Int_t) final { return 0; }
0037
0038
0039 Long64_t DirCreateEntry(TDirectory *) final;
0040 Int_t DirReadKeys(TDirectory *) final;
0041 void DirWriteKeys(TDirectory *) final;
0042 void DirWriteHeader(TDirectory *) final;
0043
0044 InfoListRet GetStreamerInfoListImpl(bool lookupSICache) final;
0045
0046 private:
0047 TXMLFile(const TXMLFile &) = delete;
0048 void operator=(const TXMLFile &) = delete;
0049
0050 public:
0051 TXMLFile() {}
0052 TXMLFile(const char *filename, Option_t *option = "read", const char *title = "title", Int_t compression = ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault);
0053 ~TXMLFile() override;
0054
0055 void Close(Option_t *option = "") final;
0056 TKey *CreateKey(TDirectory *mother, const TObject *obj, const char *name, Int_t bufsize) final;
0057 TKey *CreateKey(TDirectory *mother, const void *obj, const TClass *cl, const char *name, Int_t bufsize) final;
0058 void DrawMap(const char * = "*", Option_t * = "") final {}
0059 void FillBuffer(char *&) final {}
0060 void Flush() final {}
0061
0062 Long64_t GetEND() const final { return 0; }
0063 Int_t GetErrno() const final { return 0; }
0064 void ResetErrno() const final {}
0065
0066 Int_t GetNfree() const final { return 0; }
0067 Int_t GetNbytesInfo() const final { return 0; }
0068 Int_t GetNbytesFree() const final { return 0; }
0069 Long64_t GetSeekFree() const final { return 0; }
0070 Long64_t GetSeekInfo() const final { return 0; }
0071 Long64_t GetSize() const final { return 0; }
0072
0073 Int_t GetIOVersion() const { return fIOVersion; }
0074
0075 Bool_t IsOpen() const final;
0076
0077 void MakeFree(Long64_t, Long64_t) final {}
0078 void MakeProject(const char *, const char * = "*", Option_t * = "new") final {}
0079 void Map(Option_t *) final {}
0080 void Map() final {}
0081 void Paint(Option_t * = "") final {}
0082 void Print(Option_t * = "") const final {}
0083 Bool_t ReadBuffer(char *, Int_t) final { return kFALSE; }
0084 Bool_t ReadBuffer(char *, Long64_t, Int_t) final { return kFALSE; }
0085 void ReadFree() final {}
0086 Int_t Recover() final { return 0; }
0087 Int_t ReOpen(Option_t *mode) final;
0088 void Seek(Long64_t, ERelativeTo = kBeg) final {}
0089
0090 void SetEND(Long64_t) final {}
0091 Int_t Sizeof() const final { return 0; }
0092
0093 Bool_t WriteBuffer(const char *, Int_t) final { return kFALSE; }
0094 Int_t Write(const char * = nullptr, Int_t = 0, Int_t = 0) final { return 0; }
0095 Int_t Write(const char * = nullptr, Int_t = 0, Int_t = 0) const final { return 0; }
0096 void WriteFree() final {}
0097 void WriteHeader() final {}
0098 void WriteStreamerInfo() final;
0099
0100
0101
0102 void SetXmlLayout(EXMLLayout layout) final;
0103 void SetStoreStreamerInfos(Bool_t iConvert = kTRUE) final;
0104 void SetUsedDtd(Bool_t use = kTRUE) final;
0105 void SetUseNamespaces(Bool_t iUseNamespaces = kTRUE) final;
0106
0107 Bool_t AddXmlComment(const char *comment);
0108 Bool_t AddXmlStyleSheet(const char *href, const char *type = "text/css", const char *title = nullptr, int alternate = -1,
0109 const char *media = nullptr, const char *charset = nullptr);
0110 Bool_t AddXmlLine(const char *line);
0111
0112 TXMLEngine *XML() { return fXML.get(); }
0113
0114 protected:
0115
0116
0117 void StoreStreamerElement(XMLNodePointer_t node, TStreamerElement *elem);
0118 void ReadStreamerElement(XMLNodePointer_t node, TStreamerInfo *info);
0119
0120 Bool_t ReadFromFile();
0121 Int_t ReadKeysList(TDirectory *dir, XMLNodePointer_t topnode);
0122 TKeyXML *FindDirKey(TDirectory *dir);
0123 TDirectory *FindKeyDir(TDirectory *mother, Long64_t keyid);
0124 void CombineNodesTree(TDirectory *dir, XMLNodePointer_t topnode, Bool_t dolink);
0125
0126 void SaveToFile();
0127
0128 static void ProduceFileNames(const char *filename, TString &fname, TString &dtdname);
0129
0130 XMLDocPointer_t fDoc{nullptr};
0131
0132 XMLNodePointer_t fStreamerInfoNode{nullptr};
0133
0134 std::unique_ptr<TXMLEngine> fXML;
0135
0136 Int_t fIOVersion{0};
0137
0138 Long64_t fKeyCounter{0};
0139
0140 ClassDefOverride(TXMLFile, 3)
0141 };
0142
0143 #endif