ROOT logo
ROOT » IO » XML » TXMLEngine

class TXMLEngine: public TObject


  TXMLEngine class is used to write and read ROOT XML files - TXMLFile.
  It does not conform to complete xml standard and cannot be used
  as parser for arbitrary XML files. For such cases TXMLParser should
  be used. This class was introduced to exclude dependency from
  external libraries (like libxml2) and improve speed / memory consumption.


Function Members (Methods)

public:
TXMLEngine()
TXMLEngine(const TXMLEngine&)
virtual~TXMLEngine()
voidTObject::AbstractMethod(const char* method) const
voidAddChild(XMLNodePointer_t parent, XMLNodePointer_t child)
voidAddChildFirst(XMLNodePointer_t parent, XMLNodePointer_t child)
Bool_tAddComment(XMLNodePointer_t parent, const char* comment)
Bool_tAddDocComment(XMLDocPointer_t xmldoc, const char* comment)
Bool_tAddDocRawLine(XMLDocPointer_t xmldoc, const char* line)
Bool_tAddDocStyleSheet(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)
Bool_tAddRawLine(XMLNodePointer_t parent, const char* line)
Bool_tAddStyleSheet(XMLNodePointer_t parent, const char* href, const char* type = "text/css", const char* title = 0, int alternate = -1, const char* media = 0, const char* charset = 0)
virtual voidTObject::AppendPad(Option_t* option = "")
voidAssignDtd(XMLDocPointer_t xmldoc, const char* dtdname, const char* rootname)
virtual voidTObject::Browse(TBrowser* b)
static TClass*Class()
virtual const char*TObject::ClassName() const
voidCleanNode(XMLNodePointer_t xmlnode)
virtual voidTObject::Clear(Option_t* = "")
virtual TObject*TObject::Clone(const char* newname = "") const
virtual Int_tTObject::Compare(const TObject* obj) const
virtual voidTObject::Copy(TObject& object) const
virtual voidTObject::Delete(Option_t* option = "")MENU
virtual Int_tTObject::DistancetoPrimitive(Int_t px, Int_t py)
XMLNodePointer_tDocGetRootElement(XMLDocPointer_t xmldoc)
voidDocSetRootElement(XMLDocPointer_t xmldoc, XMLNodePointer_t xmlnode)
virtual voidTObject::Draw(Option_t* option = "")
virtual voidTObject::DrawClass() constMENU
virtual TObject*TObject::DrawClone(Option_t* option = "") constMENU
virtual voidTObject::Dump() constMENU
virtual voidTObject::Error(const char* method, const char* msgfmt) const
virtual voidTObject::Execute(const char* method, const char* params, Int_t* error = 0)
virtual voidTObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0)
virtual voidTObject::ExecuteEvent(Int_t event, Int_t px, Int_t py)
virtual voidTObject::Fatal(const char* method, const char* msgfmt) const
virtual TObject*TObject::FindObject(const char* name) const
virtual TObject*TObject::FindObject(const TObject* obj) const
voidFreeAllAttr(XMLNodePointer_t xmlnode)
voidFreeAttr(XMLNodePointer_t xmlnode, const char* name)
voidFreeDoc(XMLDocPointer_t xmldoc)
voidFreeNode(XMLNodePointer_t xmlnode)
const char*GetAttr(XMLNodePointer_t xmlnode, const char* name)
const char*GetAttrName(XMLAttrPointer_t xmlattr)
const char*GetAttrValue(XMLAttrPointer_t xmlattr)
XMLNodePointer_tGetChild(XMLNodePointer_t xmlnode)
virtual Option_t*TObject::GetDrawOption() const
static Long_tTObject::GetDtorOnly()
XMLAttrPointer_tGetFirstAttr(XMLNodePointer_t xmlnode)
virtual const char*TObject::GetIconName() const
Int_tGetIntAttr(XMLNodePointer_t node, const char* name)
virtual const char*TObject::GetName() const
XMLNodePointer_tGetNext(XMLNodePointer_t xmlnode)
XMLAttrPointer_tGetNextAttr(XMLAttrPointer_t xmlattr)
const char*GetNodeContent(XMLNodePointer_t xmlnode)
const char*GetNodeName(XMLNodePointer_t xmlnode)
XMLNsPointer_tGetNS(XMLNodePointer_t xmlnode)
const char*GetNSName(XMLNsPointer_t ns)
const char*GetNSReference(XMLNsPointer_t ns)
virtual char*TObject::GetObjectInfo(Int_t px, Int_t py) const
static Bool_tTObject::GetObjectStat()
virtual Option_t*TObject::GetOption() const
XMLNodePointer_tGetParent(XMLNodePointer_t xmlnode)
Bool_tGetSkipComments() const
virtual const char*TObject::GetTitle() const
virtual UInt_tTObject::GetUniqueID() const
virtual Bool_tTObject::HandleTimer(TTimer* timer)
Bool_tHasAttr(XMLNodePointer_t xmlnode, const char* name)
virtual ULong_tTObject::Hash() const
virtual voidTObject::Info(const char* method, const char* msgfmt) const
virtual Bool_tTObject::InheritsFrom(const char* classname) const
virtual Bool_tTObject::InheritsFrom(const TClass* cl) const
virtual voidTObject::Inspect() constMENU
voidTObject::InvertBit(UInt_t f)
virtual TClass*IsA() const
Bool_tIsEmptyNode(XMLNodePointer_t xmlnode)
virtual Bool_tTObject::IsEqual(const TObject* obj) const
virtual Bool_tTObject::IsFolder() const
Bool_tTObject::IsOnHeap() const
virtual Bool_tTObject::IsSortable() const
Bool_tTObject::IsZombie() const
virtual voidTObject::ls(Option_t* option = "") const
voidTObject::MayNotUse(const char* method) const
XMLAttrPointer_tNewAttr(XMLNodePointer_t xmlnode, XMLNsPointer_t, const char* name, const char* value)
XMLNodePointer_tNewChild(XMLNodePointer_t parent, XMLNsPointer_t ns, const char* name, const char* content = 0)
XMLDocPointer_tNewDoc(const char* version = "1.0")
XMLAttrPointer_tNewIntAttr(XMLNodePointer_t xmlnode, const char* name, Int_t value)
XMLNsPointer_tNewNS(XMLNodePointer_t xmlnode, const char* reference, const char* name = 0)
virtual Bool_tTObject::Notify()
voidTObject::Obsolete(const char* method, const char* asOfVers, const char* removedFromVers) const
static voidTObject::operator delete(void* ptr)
static voidTObject::operator delete(void* ptr, void* vp)
static voidTObject::operator delete[](void* ptr)
static voidTObject::operator delete[](void* ptr, void* vp)
void*TObject::operator new(size_t sz)
void*TObject::operator new(size_t sz, void* vp)
void*TObject::operator new[](size_t sz)
void*TObject::operator new[](size_t sz, void* vp)
TXMLEngine&operator=(const TXMLEngine&)
virtual voidTObject::Paint(Option_t* option = "")
XMLDocPointer_tParseFile(const char* filename, Int_t maxbuf = 100000)
XMLDocPointer_tParseString(const char* xmlstring)
virtual voidTObject::Pop()
virtual voidTObject::Print(Option_t* option = "") const
virtual Int_tTObject::Read(const char* name)
XMLNodePointer_tReadSingleNode(const char* src)
virtual voidTObject::RecursiveRemove(TObject* obj)
voidTObject::ResetBit(UInt_t f)
virtual voidTObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU
voidSaveDoc(XMLDocPointer_t xmldoc, const char* filename, Int_t layout = 1)
virtual voidTObject::SavePrimitive(ostream& out, Option_t* option = "")
voidSaveSingleNode(XMLNodePointer_t xmlnode, TString* res, Int_t layout = 1)
voidTObject::SetBit(UInt_t f)
voidTObject::SetBit(UInt_t f, Bool_t set)
virtual voidTObject::SetDrawOption(Option_t* option = "")MENU
static voidTObject::SetDtorOnly(void* obj)
static voidTObject::SetObjectStat(Bool_t stat)
voidSetSkipComments(bool on = kTRUE)
virtual voidTObject::SetUniqueID(UInt_t uid)
voidShiftToNext(XMLNodePointer_t& xmlnode, bool tonode = true)
virtual voidShowMembers(TMemberInspector& insp)
voidSkipEmpty(XMLNodePointer_t& xmlnode)
virtual voidStreamer(TBuffer& b)
voidStreamerNVirtual(TBuffer& b)
virtual voidTObject::SysError(const char* method, const char* msgfmt) const
Bool_tTObject::TestBit(UInt_t f) const
Int_tTObject::TestBits(UInt_t f) const
voidUnlinkFreeNode(XMLNodePointer_t xmlnode)
voidUnlinkNode(XMLNodePointer_t node)
virtual voidTObject::UseCurrentStyle()
Bool_tValidateDocument(XMLDocPointer_t, Bool_t = kFALSE)
Bool_tValidateVersion(XMLDocPointer_t doc, const char* version = 0)
virtual voidTObject::Warning(const char* method, const char* msgfmt) const
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0)
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const
protected:
XMLAttrPointer_tAllocateAttr(int namelen, int valuelen, XMLNodePointer_t xmlnode)
XMLNodePointer_tAllocateNode(int namelen, XMLNodePointer_t parent)
voidDisplayError(Int_t error, Int_t linenumber)
virtual voidTObject::DoError(int level, const char* location, const char* fmt, va_list va) const
XMLNsPointer_tFindNs(XMLNodePointer_t xmlnode, const char* nsname)
char*Makenstr(const char* start, int len)
char*Makestr(const char* str)
voidTObject::MakeZombie()
voidOutputValue(char* value, TXMLOutputStream* out)
XMLDocPointer_tParseStream(TXMLInputStream* input)
XMLNodePointer_tReadNode(XMLNodePointer_t xmlparent, TXMLInputStream* inp, Int_t& resvalue)
voidSaveNode(XMLNodePointer_t xmlnode, TXMLOutputStream* out, Int_t layout, Int_t level)
voidTruncateNsExtension(XMLNodePointer_t xmlnode)
voidUnpackSpecialCharacters(char* target, const char* source, int srclen)

Data Members

protected:
Bool_tfSkipComments! if true, do not create comments nodes in document during parsing

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

TXMLEngine()
 default (normal) constructor of TXMLEngine class
~TXMLEngine()
 destructor for TXMLEngine object
Bool_t HasAttr(XMLNodePointer_t xmlnode, const char* name)
 checks if node has attribute of specified name
const char* GetAttr(XMLNodePointer_t xmlnode, const char* name)
 returns value of attribute for xmlnode
Int_t GetIntAttr(XMLNodePointer_t node, const char* name)
 returns value of attribute as integer
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
XMLAttrPointer_t NewIntAttr(XMLNodePointer_t xmlnode, const char* name, Int_t value)
 create node attribute with integer value
void FreeAttr(XMLNodePointer_t xmlnode, const char* name)
 remove attribute from xmlnode
void FreeAllAttr(XMLNodePointer_t xmlnode)
 Free all attributes of the node
XMLAttrPointer_t GetFirstAttr(XMLNodePointer_t xmlnode)
 return first attribute in the list, namespace (if exists) will be skiped
XMLAttrPointer_t GetNextAttr(XMLAttrPointer_t xmlattr)
 return next attribute in the list
const char* GetAttrName(XMLAttrPointer_t xmlattr)
 return name of the attribute
const char* GetAttrValue(XMLAttrPointer_t xmlattr)
 return value of attribute
XMLNodePointer_t NewChild(XMLNodePointer_t parent, XMLNsPointer_t ns, const char* name, const char* content = 0)
 create new child element for parent node
XMLNsPointer_t NewNS(XMLNodePointer_t xmlnode, const char* reference, const char* name = 0)
 create namespace attribute for xmlnode.
 namespace attribute will be always the first in list of node attributes
XMLNsPointer_t GetNS(XMLNodePointer_t xmlnode)
 return namespace attribute  (if exists)
const char* GetNSName(XMLNsPointer_t ns)
 return name id of namespace
const char* GetNSReference(XMLNsPointer_t ns)
 return reference id of namespace
void AddChild(XMLNodePointer_t parent, XMLNodePointer_t child)
 add child element to xmlnode
void AddChildFirst(XMLNodePointer_t parent, XMLNodePointer_t child)
 add node as first child
Bool_t AddComment(XMLNodePointer_t parent, const char* comment)
 Adds comment line to the node
Bool_t AddDocComment(XMLDocPointer_t xmldoc, const char* comment)
 add comment line to the top of the document
Bool_t AddRawLine(XMLNodePointer_t parent, const char* line)
 Add just line into xml file
 Line should has correct xml syntax that later it can be decoded by xml parser
 For instance, it can be comment or processing instructions
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 decoded by xml parser
Bool_t AddStyleSheet(XMLNodePointer_t parent, 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 to the specified node
 Creates <?xml-stylesheet alternate="yes" title="compact" href="small-base.css" type="text/css"?>
 Attributes href and type must be supplied,
  other attributes: title, alternate, media, charset are optional
 if alternate==0, attribyte alternate="no" will be created,
 if alternate>0, attribute alternate="yes"
 if alternate<0, attribute will not be created
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
void UnlinkNode(XMLNodePointer_t node)
 unlink (dettach) xml node from parent
void FreeNode(XMLNodePointer_t xmlnode)
 release all memory, allocated fro this node and
 destroyes node itself
void UnlinkFreeNode(XMLNodePointer_t xmlnode)
 combined operation. Unlink node and free used memory
const char* GetNodeName(XMLNodePointer_t xmlnode)
 returns name of xmlnode
const char* GetNodeContent(XMLNodePointer_t xmlnode)
 get contents (if any) of xml node
XMLNodePointer_t GetChild(XMLNodePointer_t xmlnode)
 returns first child of xml node
XMLNodePointer_t GetParent(XMLNodePointer_t xmlnode)
 returns parent of xmlnode
XMLNodePointer_t GetNext(XMLNodePointer_t xmlnode)
 return next to xmlnode node
void ShiftToNext(XMLNodePointer_t& xmlnode, bool tonode = true)
 shifts specified node to next
Bool_t IsEmptyNode(XMLNodePointer_t xmlnode)
 return kTRUE is this is node with special data like comments to data processing instructions
void SkipEmpty(XMLNodePointer_t& xmlnode)
 Skip all current empty nodes and locate on first "true" node
void CleanNode(XMLNodePointer_t xmlnode)
 remove all childs node from xmlnode
XMLDocPointer_t NewDoc(const char* version = "1.0")
 creates new xml document with provided version
void AssignDtd(XMLDocPointer_t xmldoc, const char* dtdname, const char* rootname)
 assignes dtd filename to document
void FreeDoc(XMLDocPointer_t xmldoc)
 frees allocated document data and deletes document itself
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
 xmlnodes. Xml file will have minimum size, but nonreadable structure
 if (layout>0) each node will be started from new line,
 and number of spaces will correspond to structure depth.
void DocSetRootElement(XMLDocPointer_t xmldoc, XMLNodePointer_t xmlnode)
 set main (root) node for document
XMLNodePointer_t DocGetRootElement(XMLDocPointer_t xmldoc)
 returns root node of document
XMLDocPointer_t ParseFile(const char* filename, Int_t maxbuf = 100000)
 Parses content of file and tries to produce xml structures.
 The maxbuf argument specifies the max size of the XML file to be
 parsed. The default value is 100000.
XMLDocPointer_t ParseString(const char* xmlstring)
 parses content of string and tries to produce xml structures
XMLDocPointer_t ParseStream(TXMLInputStream* input)
 parses content of the stream and tries to produce xml structures
Bool_t ValidateVersion(XMLDocPointer_t doc, const char* version = 0)
 check that first node is xml processing instruction with correct xml version number
void SaveSingleNode(XMLNodePointer_t xmlnode, TString* res, Int_t layout = 1)
 convert single xml node (and its child node) to string
 if layout<=0, no any spaces or newlines will be placed between
 xmlnodes. Xml file will have minimum size, but nonreadable structure
 if (layout>0) each node will be started from new line,
 and number of spaces will correspond to structure depth.
XMLNodePointer_t ReadSingleNode(const char* src)
 read single xml node from provided string
char* Makestr(const char* str)
 creates char* variable with copy of provided string
char* Makenstr(const char* start, int len)
 creates char* variable with copy of len symbols from provided string
XMLNodePointer_t AllocateNode(int namelen, XMLNodePointer_t parent)
 Allocates new xml node with specified namelength
XMLAttrPointer_t AllocateAttr(int namelen, int valuelen, XMLNodePointer_t xmlnode)
 Allocate new attribute with specified name length and value length
XMLNsPointer_t FindNs(XMLNodePointer_t xmlnode, const char* nsname)
 define if namespace of that name exists for xmlnode
void TruncateNsExtension(XMLNodePointer_t xmlnode)
 removes namespace extension of nodename
void UnpackSpecialCharacters(char* target, const char* source, int srclen)
 unpack special symbols, used in xml syntax to code characters
 these symbols: '<' - &lt, '>' - &gt, '&' - &amp, '"' - &quot
void OutputValue(char* value, TXMLOutputStream* out)
 output value to output stream
 if symbols '<' '&' '>' '"' appears in the string, they
 will be encoded to appropriate xml symbols: &lt, &amp, &gt, &quot
void SaveNode(XMLNodePointer_t xmlnode, TXMLOutputStream* out, Int_t layout, Int_t level)
 stream data of xmlnode to output
XMLNodePointer_t ReadNode(XMLNodePointer_t xmlparent, TXMLInputStream* inp, Int_t& resvalue)
 Tries to construct xml node from input stream. Node should be
 child of xmlparent node or it can be closing tag of xmlparent.
 resvalue <= 0 if error
 resvalue == 1 if this is endnode of parent
 resvalue == 2 if this is child
void DisplayError(Int_t error, Int_t linenumber)
 Displays xml parsing error
TXMLEngine()
void SetSkipComments(bool on = kTRUE)
{ fSkipComments = on; }
Bool_t GetSkipComments() const
{ return fSkipComments; }
Bool_t ValidateDocument(XMLDocPointer_t , Bool_t = kFALSE)
{ return kFALSE; }