ADTF  v2.14.3
cDOM Class Reference

cDOM implements a XML parser which can be used to read in XML files and perform simple (!) queries. More...

Public Member Functions

 cDOM ()
 Default constructor.
 
virtual ~cDOM ()
 Destructor.
 
 cDOM (const cDOM &oDOM)
 Copy constructor. More...
 
cDOMoperator= (const cDOM &oDOM)
 Copy assignment operator. More...
 
tResult Load (const tChar *strFilename, const tBool &bIgnoreIncludes=tFalse, const tUInt32 &ui32OpenMode=cFile::OM_Read|cFile::OM_SequentialAccess)
 Loads an xml file and creates the dom. More...
 
tResult Save (const tChar *strFilename, const tBool &bKeepIncludes=tFalse) const
 Save dom to an xml file. More...
 
tResult FromString (const tChar *ptrXML, const tBool &bIgnoreIncludes=tFalse)
 Create the dom from an input string. More...
 
cString ToString () const
 Creates an xml string representation of the dom. More...
 
tResult Free ()
 Frees all allocated resources. More...
 
cDOMElementGetRoot ()
 Returns the root element of the dom. More...
 
tVoid SetRoot (const cDOMElement &oNewRoot)
 Set the root element of the dom. More...
 
tVoid AddPreRootSibling (const cDOMElement &oChild)
 For internal use only.
 
tVoid AddPostRootSibling (const cDOMElement &oChild)
 For internal use only.
 
const cDOMElementListGetPreRootSibling ()
 For internal use only.
 
const cDOMElementListGetPostRootSibling ()
 For internal use only.
 
tResult FindNode (const tChar *strQuery, cDOMElement *&poElement)
 Finds a node based on a query, see cDOMElement::FindNode. More...
 
tResult FindNodes (const tChar *strQuery, cDOMElementRefList &lstElements)
 Finds nodes based on a query, see cDOMElement::FindNode. More...
 
cString GetFilePath ()
 Returns the name of the file that the dom was created from. More...
 
cStringList GetIncludedFiles ()
 Returns a list of files that are included in the loaded file. More...
 
tVoid AddIncludedFile (const cString &strIncludedFile)
 Adds an include file statement to the dom. More...
 
cString GetLastDOMError ()
 Returns the last error description occurred. More...
 

Static Public Member Functions

static tResult SkipComment (cDOM *pDom, const tChar *&ptr, std::list< cString > &lstComment, const tChar *pStart=0)
 Skips xml comment sections in a string. More...
 

Protected Attributes

cFilename m_strFilePath
 path of xml file
 
cDOMElement m_oRoot
 root element of dom
 
cDOMElementList m_lstPreRootSibling
 pre root siblings
 
cDOMElementList m_lstPostRootSibling
 post root siblings
 
cStringList m_lstIncludedFile
 list of included files
 
tBool m_bIgnoreIncludesEnabled
 special tag include is enabled or not
 
cString m_strLastErrorDescription
 if error occurs this will hold the parser error description
 

Friends

class cDOMElement
 

Detailed Description

cDOM implements a XML parser which can be used to read in XML files and perform simple (!) queries.

It does neither support any specific XML standard nor is it intended to support any standards in future releases! You should include other XML libraries (e.g. MSXML or TinyXml) if you need specific functions that are not implemented in cDOM.

cDOM does not perform complete XML validation, so make sure that only valid XML files are used as input.

Actually the "encoding" is ignored! So if there are characters which are NOT ASCII-Format then the result can be strange!

Definition at line 430 of file dom.h.

Constructor & Destructor Documentation

cDOM ( const cDOM oDOM)

Copy constructor.

Parameters
oDOM[in] The object to copy.

Member Function Documentation

tVoid AddIncludedFile ( const cString strIncludedFile)

Adds an include file statement to the dom.

Included files have to be encapsulated by a root node which is omitted on including.

Parameters
strIncludedFile[in] The file to include.
Returns
void
tResult FindNode ( const tChar strQuery,
cDOMElement *&  poElement 
)

Finds a node based on a query, see cDOMElement::FindNode.

See cDOMElement::FindNode for the syntax.

Parameters
strQuery[in] The query string.
poElement[out] This will point to the found element.
Returns
Standard result.
tResult FindNodes ( const tChar strQuery,
cDOMElementRefList lstElements 
)

Finds nodes based on a query, see cDOMElement::FindNode.

See cDOMElement::FindNode for the syntax.

Parameters
strQuery[in] The query string.
lstElements[out] This list will be filled with the found elements.
Returns
Standard result.
tResult Free ( )

Frees all allocated resources.

Returns
tResult FromString ( const tChar ptrXML,
const tBool bIgnoreIncludes = tFalse 
)

Create the dom from an input string.

Parameters
ptrXML[in] The string.
bIgnoreIncludes[in] the special tag 'include' will be ignored!
Return values
ERR_UNEXPECTEDInvalid XML tag
cString GetFilePath ( )

Returns the name of the file that the dom was created from.

Returns
The name of the file that the dom was created from.
cStringList GetIncludedFiles ( )

Returns a list of files that are included in the loaded file.

Returns
A list of files that are included in the loaded file.
cString GetLastDOMError ( )

Returns the last error description occurred.

Returns
The last Error as cString object.
cDOMElement& GetRoot ( )

Returns the root element of the dom.

Returns
The root element of the dom.
This method is real-time safe.
See The ADTF Real-Time Extension.
tResult Load ( const tChar strFilename,
const tBool bIgnoreIncludes = tFalse,
const tUInt32 ui32OpenMode = cFile::OM_Read|cFile::OM_SequentialAccess 
)

Loads an xml file and creates the dom.

Included files have to be encapsulated by a root node which is omitted on including.

Parameters
strFilename[in] The filename.
bIgnoreIncludes[in] the special tag 'include' will be ignored!
ui32OpenMode[in] Open mode of the file access see cFile::tOpenMode (should be at least cFile::OM_Read)
Return values
ERR_OPEN_FAILEDReading process failed
ERR_UNEXPECTEDInvalid XML tag
cDOM& operator= ( const cDOM oDOM)

Copy assignment operator.

Parameters
oDOM[in] The element to copy to.
Returns
[in] A reference of the local object.
tResult Save ( const tChar strFilename,
const tBool bKeepIncludes = tFalse 
) const

Save dom to an xml file.

Parameters
strFilename[in] The filename.
bKeepIncludes[in] If tTrue, will write existing xml includes into the file.
Return values
ERR_FAILEDSaving process failed.
tVoid SetRoot ( const cDOMElement oNewRoot)

Set the root element of the dom.

Parameters
oNewRoot[in] The new root element.
Returns
void
static tResult SkipComment ( cDOM pDom,
const tChar *&  ptr,
std::list< cString > &  lstComment,
const tChar pStart = 0 
)
static

Skips xml comment sections in a string.

Parameters
pDom[in] The pointer to the dom
ptr[inout] The location where to start skipping comments. This pointer will be advanced to the location after the comments.
lstComment[out] A list of comment sections that where encountered.
pStart[in] The beginning of the search
Returns
Standard result.
cString ToString ( ) const

Creates an xml string representation of the dom.

Returns
An xml string representation of the dom.

Copyright © Audi Electronics Venture GmbH. All rights reserved. (Generated on Fri Mar 22 2019 by doxygen 1.8.10)