CRM64Pro GDK v0.14.0
A free cross-platform game development kit built on top of SDL 3.0
Loading...
Searching...
No Matches
CRM64Pro::XML

XML Object class. More...

Detailed Description

XML Object class.

Public Member Functions

bool info (Sint32 iMode=0) override
 Request XML object information.
const string & getName () const override
 Get the name.
Uint32 getID () const override
 Get the ID.
bool nodePointTo (Sint32 iParam, char *szNodes,...)
 Point to a node using a va_list of node names.
bool nodeFirst ()
 Point to the first XML node (the root node).
bool nodeNext ()
 Point to the next node (from current pointed node).
bool nodePrev ()
 Point to the previous node (from current pointed node).
bool nodeParent ()
 Point to the parent node (from current pointed node).
bool nodeChild ()
 Point to the first child node (from current pointed node).
bool nodeStore ()
 Store node pointer position.
bool nodeRestore ()
 Restore node pointer position.
bool nodeRemove ()
 Remove pointed node and all its subnodes and attributes.
bool nodeCreate (const string &sNode)
 Create a new node inside the pointed node and point to it.
bool nodeRename (const string &sNode)
 Rename pointed node.
bool nodeGetName (string &sNode)
 Get the name of pointed node.
bool setAttribute (const string &sAttr, const string &sValue)
 Set an attribute inside pointed node with a string value.
bool setAttribute (const string &sAttr, const Sint32 &iValue)
 Set an attribute inside pointed node with an integer value.
bool setAttribute (const string &sAttr, const float &fValue)
 Set an attribute inside pointed node with a float value.
bool getAttribute (const string &sAttr, string &sValue)
 Get the string value of an attribute inside the pointed node.
bool getAttribute (const string &sAttr, Sint32 &iValue)
 Get the integer value of an attribute inside the pointed node.
bool getAttribute (const string &sAttr, float &fValue)
 Get the float value of an attribute inside the pointed node.
bool removeAttribute (const string &sAttr)
 Remove an attribute and its value inside the pointed node.
bool setText (const string &sText)
 Set a text inside the pointed node.
bool getText (string &sText)
 Get the text contained in the pointed node.
bool removeText ()
 Remove the text inside the pointed node.
bool setComment (const string &sComment)
 Set a comment text inside the pointed node.
bool getComment (string &sComment)
 Get the comment text contained in the pointed node.
bool removeComment ()
 Remove the comment text inside the pointed node.
Sint32 saveToFile (const string &sFile)
 Export the XML to an external file.
Sint32 save (const string &sCDCFile, const string &sResourceName="")
 Save the XML into a CDC file.
Sint32 save (const Sint32 idCDC, const string &sResourceName="")
 Save the XML in to a CDC file.

Member Function Documentation

◆ info()

bool CRM64Pro::XML::info ( Sint32 iMode = 0)
override

Request XML object information.

Writes information to the default log.

Parameters
iModeunused for the time being.
Returns
true on success or false on failure.

◆ getName()

const string & CRM64Pro::XML::getName ( ) const
override

Get the name.

Returns
The object name.

◆ getID()

Uint32 CRM64Pro::XML::getID ( ) const
override

Get the ID.

Returns
Object ID.

◆ nodePointTo()

bool CRM64Pro::XML::nodePointTo ( Sint32 iParam,
char * szNodes,
... )

Point to a node using a va_list of node names.

Parameters
iParamnumber of arguments.
szNodesvariable arguments list of strings (char*) with the node names.
Returns
true on success or false on failure.

◆ nodeFirst()

bool CRM64Pro::XML::nodeFirst ( )

Point to the first XML node (the root node).

Returns
true on success (found root) or false on failure (empty document).

◆ nodeNext()

bool CRM64Pro::XML::nodeNext ( )

Point to the next node (from current pointed node).

Returns
true on success (moved to next node) or false on failure (no more nodes or current node is null).

◆ nodePrev()

bool CRM64Pro::XML::nodePrev ( )

Point to the previous node (from current pointed node).

Returns
true on success (moved to previous node) or false on failure (no previous node or current node is null).

◆ nodeParent()

bool CRM64Pro::XML::nodeParent ( )

Point to the parent node (from current pointed node).

Returns
true on success (moved to parent node) or false on failure (no parent node or current node is null).

◆ nodeChild()

bool CRM64Pro::XML::nodeChild ( )

Point to the first child node (from current pointed node).

Returns
true on success (moved to child node) or false on failure (no child nodes or current node is null).

◆ nodeStore()

bool CRM64Pro::XML::nodeStore ( )

Store node pointer position.

Each XML has a single slot, so it keeps only the most recently stored position.

Returns
true on success or false on failure.

◆ nodeRestore()

bool CRM64Pro::XML::nodeRestore ( )

Restore node pointer position.

Each XML has a single slot, so it restores the position saved by the last nodeStore() call.

Returns
true on success or false on failure.

◆ nodeRemove()

bool CRM64Pro::XML::nodeRemove ( )

Remove pointed node and all its subnodes and attributes.

Returns
true on success or false on failure.

◆ nodeCreate()

bool CRM64Pro::XML::nodeCreate ( const string & sNode)

Create a new node inside the pointed node and point to it.

Parameters
sNodestring containing the node name.
Returns
true on success or false on failure.

◆ nodeRename()

bool CRM64Pro::XML::nodeRename ( const string & sNode)

Rename pointed node.

Parameters
sNodestring containing the node name.
Returns
true on success or false on failure.

◆ nodeGetName()

bool CRM64Pro::XML::nodeGetName ( string & sNode)

Get the name of pointed node.

Parameters
sNodea string variable. Will not be modified when there is not a valid pointed node.
Returns
true on success or false on failure.

◆ setAttribute() [1/3]

bool CRM64Pro::XML::setAttribute ( const string & sAttr,
const string & sValue )

Set an attribute inside pointed node with a string value.

If the attribute does not exist, it will be created.

Parameters
sAttrattribute name string.
sValuestring value.
Returns
true on success or false on failure.

◆ setAttribute() [2/3]

bool CRM64Pro::XML::setAttribute ( const string & sAttr,
const Sint32 & iValue )

Set an attribute inside pointed node with an integer value.

If the attribute does not exist, it will be created.

Parameters
sAttrattribute name string.
iValueinteger value.
Returns
true on success or false on failure.

◆ setAttribute() [3/3]

bool CRM64Pro::XML::setAttribute ( const string & sAttr,
const float & fValue )

Set an attribute inside pointed node with a float value.

If the attribute does not exist, it will be created.

Parameters
sAttrattribute name string.
fValuefloat value.
Returns
true on success or false on failure.

◆ getAttribute() [1/3]

bool CRM64Pro::XML::getAttribute ( const string & sAttr,
string & sValue )

Get the string value of an attribute inside the pointed node.

Parameters
sAttrattribute name string.
sValuea string variable. Not modified if the attribute does not exist.
Returns
true on success or false on failure.

◆ getAttribute() [2/3]

bool CRM64Pro::XML::getAttribute ( const string & sAttr,
Sint32 & iValue )

Get the integer value of an attribute inside the pointed node.

Parameters
sAttrattribute name string.
iValuean integer variable. Not modified if the attribute does not exist.
Returns
true on success or false on failure.

◆ getAttribute() [3/3]

bool CRM64Pro::XML::getAttribute ( const string & sAttr,
float & fValue )

Get the float value of an attribute inside the pointed node.

Parameters
sAttrattribute name string.
fValuea float variable. Not modified if the attribute does not exist.
Returns
true on success or false on failure.

◆ removeAttribute()

bool CRM64Pro::XML::removeAttribute ( const string & sAttr)

Remove an attribute and its value inside the pointed node.

Parameters
sAttrattribute name string.
Returns
true on success or false on failure.

◆ setText()

bool CRM64Pro::XML::setText ( const string & sText)

Set a text inside the pointed node.

If there is not any text, it will be created. Otherwise, the text will be appended to the exiting one.

Parameters
sTexttext string.
Returns
true on success or false on failure.>

◆ getText()

bool CRM64Pro::XML::getText ( string & sText)

Get the text contained in the pointed node.

Parameters
sTexta string variable. Not modified if no text exists.
Returns
true on success or false on failure.

◆ removeText()

bool CRM64Pro::XML::removeText ( )

Remove the text inside the pointed node.

Returns
true on success or false on failure.

◆ setComment()

bool CRM64Pro::XML::setComment ( const string & sComment)

Set a comment text inside the pointed node.

If a comment already exists, it will be pushed down and the new comment will be the first one.

Parameters
sCommentcomment text string.
Returns
true on success or false on failure.

◆ getComment()

bool CRM64Pro::XML::getComment ( string & sComment)

Get the comment text contained in the pointed node.

Parameters
sCommenta string variable. Not modified if no comment exists.
Returns
true on success or false on failure.
Note
Only gets the first comment text block found.

◆ removeComment()

bool CRM64Pro::XML::removeComment ( )

Remove the comment text inside the pointed node.

Returns
true on success or false on failure.
Note
Only removes the first comment text block found. Call repeatedly until a negative error code to remove all comments.

◆ saveToFile()

Sint32 CRM64Pro::XML::saveToFile ( const string & sFile)

Export the XML to an external file.

Parameters
sFilestring containing [directory]+filename+[extension]. Ideally should have the .xml extension. If the file exists, it will be overwritten. Directory separators '\' and '/' are supported.
Returns
0 or greater on success or a negative error code on failure.

◆ save() [1/2]

Sint32 CRM64Pro::XML::save ( const string & sCDCFile,
const string & sResourceName = "" )

Save the XML into a CDC file.

If the XML already exists on the CDC, it will be overwritten.

Parameters
sCDCFilestring containing [directory]+filename+[extension]. Directory separators '\' and '/' are supported.
sResourceNameOptional resource name to use in the CDC. If empty (default), uses the XML object's internal name.
Returns
greater than 0 on success (the size of this block on the CDC) or a negative error code on failure.
Note
If the CDC file is secured, this call will fail. Open the CDC first using ArchiveMgr::open() and use XML::save() with the CDC id instead.

◆ save() [2/2]

Sint32 CRM64Pro::XML::save ( const Sint32 idCDC,
const string & sResourceName = "" )

Save the XML in to a CDC file.

If the XML already exists on the CDC, it will be overwritten.

Parameters
idCDCCDC id.
sResourceNameOptional resource name to use in the CDC. If empty (default), uses the XML object's internal name.
Returns
greater than 0 on success or a negative error code on failure.