ADTF  3.18.2
cDOM

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

Public Member Functions

A_UTILS_DEPRECATED() cDOM ()
 Default constructor. More...
 
virtual ~cDOM ()
 Destructor.
 
A_UTILS_DEPRECATED() 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_SharedRead|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...
 
const cDOMElementGetRoot () const
 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 () const
 For internal use only.
 
const cDOMElementListGetPostRootSibling () const
 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=nullptr)
 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
 

Static Protected Attributes

static const tSize m_nTABSIZE = 1
 TAB Size for IndentLevel.
 

Private Member Functions

tResult DropIncludes (cDOMElement *pElement=nullptr)
 
tVoid SetDOMError (cString &strError)
 
tBool IsIgnoreIncludesEnabled ()
 

Static Private Member Functions

static tVoid DOMError (cDOM *pDom, const tChar *pStart, const tChar *pCur, const tChar *pMsg)
 

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 458 of file builds/digitalwerk/solutions/adtf_content/adtf_base/adtf_core/src/libraries/a_utils/include/a_utils/std/dom.h.

Constructor & Destructor Documentation

◆ cDOM() [1/2]

Default constructor.

Deprecated:
Within further releases the cDOM will be completely reworked. API will change !!

◆ cDOM() [2/2]

A_UTILS_DEPRECATED() cDOM ( const cDOM oDOM)

Copy constructor.

Parameters
oDOM[in] The object to copy.

Member Function Documentation

◆ AddIncludedFile()

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

◆ FindNode()

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.

◆ FindNodes()

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.

◆ Free()

tResult Free ( )

Frees all allocated resources.

Returns

◆ FromString()

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

◆ GetFilePath()

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.

◆ GetIncludedFiles()

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.

◆ GetLastDOMError()

cString GetLastDOMError ( )

Returns the last error description occurred.

Returns
The last Error as cString object.

◆ GetRoot() [1/2]

cDOMElement& GetRoot ( )

Returns the root element of the dom.

Returns
The root element of the dom.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ GetRoot() [2/2]

const cDOMElement& GetRoot ( ) const

Returns the root element of the dom.

Returns
The root element of the dom.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ Load()

tResult Load ( const tChar strFilename,
const tBool bIgnoreIncludes = tFalse,
const tUInt32 ui32OpenMode = cFile::OM_Read|cFile::OM_SharedRead|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

◆ operator=()

cDOM& operator= ( const cDOM oDOM)

Copy assignment operator.

Parameters
oDOM[in] The element to copy to.
Returns
[in] A reference of the local object.

◆ Save()

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.

◆ SetRoot()

tVoid SetRoot ( const cDOMElement oNewRoot)

Set the root element of the dom.

Parameters
oNewRoot[in] The new root element.
Returns
void

◆ SkipComment()

static tResult SkipComment ( cDOM pDom,
const tChar *&  ptr,
std::list< cString > &  lstComment,
const tChar pStart = nullptr 
)
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.

◆ ToString()

cString ToString ( ) const

Creates an xml string representation of the dom.

Returns
An xml string representation of the dom.