CRM64Pro GDK v0.11.0
A free cross-platform game development kit built on top of SDL 3.0
|
v1.10 (23 April 2023)
The XML module includes the XML Manager and XML objects providing a full XML parsing system.
Each object loaded(a XML file) or created (a XML created on the fly) owns an internal state containing very important variables as the current node pointer and others.
In case you access to the same object from different functions or threads, you must keep in mind this internal state or unexpected results may happen. A workaround for it is to load an object, change its name and load the same object, this will allow you to have read-only concurrency from two different threads to the same but duplicated object.
This is a standard manager: objects are not shared and must be unique using its name as the key, in other words, you can not create an object with the same name of another one already created.
Only a single instance of the XML Manager exists which is created once Main is instantiated.
You can get a reference to this manager using Main::IXMLMgr() method.
Classes | |
class | CRM64Pro::XML |
XML Object class. More... | |
class | CRM64Pro::XMLMgr |
XML Manager class. More... | |
Functions | |
Sint32 | CRM64Pro::XML::info (Sint32 iMode=0) |
Request XML object information. | |
Sint32 | CRM64Pro::XML::getName (string &sName) |
Get the name. | |
Uint32 | CRM64Pro::XML::getID () |
Get the ID. | |
Sint32 | CRM64Pro::XML::nodePointTo (Sint32 iParam, char *szNodes,...) |
Search and point to the given node or subnode at any level. | |
Sint32 | CRM64Pro::XML::nodeFirst () |
Point to the first XML node (the root node). | |
Sint32 | CRM64Pro::XML::nodeNext () |
Point to the next node (from current pointed node). | |
Sint32 | CRM64Pro::XML::nodePrev () |
Point to the previous node (from current pointed node). | |
Sint32 | CRM64Pro::XML::nodeParent () |
Point to the parent node (from current pointed node). | |
Sint32 | CRM64Pro::XML::nodeChild () |
Point to the first child node (from current pointed node). | |
Sint32 | CRM64Pro::XML::nodeStore () |
Store node pointer position. | |
Sint32 | CRM64Pro::XML::nodeRestore () |
Restore node pointer position. | |
Sint32 | CRM64Pro::XML::nodeRemove () |
Remove pointed node and all its subnodes and attributes. | |
Sint32 | CRM64Pro::XML::nodeCreate (const string &sNode) |
Create a new node inside the pointed node and point to it. | |
Sint32 | CRM64Pro::XML::nodeRename (const string &sNode) |
Rename pointed node. | |
Sint32 | CRM64Pro::XML::nodeGetName (string &sNode) |
Get the name of pointed node. | |
Sint32 | CRM64Pro::XML::setAttribute (const string &sAttr, const string &sValue) |
Set an attribute inside pointed node with a string value. | |
Sint32 | CRM64Pro::XML::setAttribute (const string &sAttr, const Sint32 &iValue) |
Set an attribute inside pointed node with an integer value. | |
Sint32 | CRM64Pro::XML::setAttribute (const string &sAttr, const double &dValue) |
Set an attribute inside pointed node with an integer value. | |
Sint32 | CRM64Pro::XML::getAttribute (const string &sAttr, string &sValue) |
Get the string value of an attribute inside the pointed node. | |
Sint32 | CRM64Pro::XML::getAttribute (const string &sAttr, Sint32 &iValue) |
Get the integer value of an attribute inside the pointed node. | |
Sint32 | CRM64Pro::XML::getAttribute (const string &sAttr, double &dValue) |
Get the double value of an attribute inside the pointed node. | |
Sint32 | CRM64Pro::XML::removeAttribute (const string &sAttr) |
Remove an attribute and its value inside the pointed node. | |
Sint32 | CRM64Pro::XML::setText (const string &sText) |
Set a text inside the pointed node. | |
Sint32 | CRM64Pro::XML::getText (string &sText) |
Get the text contained in the pointed node. | |
Sint32 | CRM64Pro::XML::removeText () |
Remove the text inside the pointed node. | |
Sint32 | CRM64Pro::XML::setComment (const string &sComment) |
Set a comment text inside the pointed node. | |
Sint32 | CRM64Pro::XML::getComment (string &sComment) |
Get the comment text contained in the pointed node. | |
Sint32 | CRM64Pro::XML::removeComment () |
Remove the comment text inside the pointed node. | |
Sint32 | CRM64Pro::XML::saveToFile (const string &sFile) |
Export the XML to an external file. | |
Sint32 | CRM64Pro::XML::save (const string &sFileCDC) |
Save the XML in to a CDC file. | |
Sint32 | CRM64Pro::XML::save (Sint32 idCDC) |
Save the XML in to a CDC file. | |
Sint32 | CRM64Pro::XMLMgr::info (Sint32 idXML=0) |
Request XML Manager information. | |
Sint32 | CRM64Pro::XMLMgr::create (const string &sMainNode, Uint32 iUnused=0) |
Create a new XML. | |
Sint32 | CRM64Pro::XMLMgr::close (Sint32 idXML) |
Close and destroy a XML. | |
Sint32 | CRM64Pro::XMLMgr::getNum () |
Get number of loaded objects. | |
Sint32 | CRM64Pro::XMLMgr::setName (Sint32 idXML, const string &sName) |
Change the object name. | |
XML * | CRM64Pro::XMLMgr::get (Sint32 idXML=0) |
Get a pointer to the XML using its handler. | |
Sint32 | CRM64Pro::XMLMgr::loadFromFile (const string &sFile, const string &sName="") |
Load a XML file. | |
Sint32 | CRM64Pro::XMLMgr::loadFromBuffer (const unsigned char *szData, const Sint32 iSize, const string &sName) |
Load a XML from a buffer. | |
Sint32 | CRM64Pro::XMLMgr::load (const string &sFileCDC, const string &sName) |
Load a XML file stored in a CDC file. | |
Sint32 | CRM64Pro::XMLMgr::load (Sint32 idCDC, const string &sName) |
Load a XML file stored in a CDC file. | |
Sint32 | CRM64Pro::XMLMgr::remove (Sint32 idCDC, const string &sName) |
Remove a XML file stored in a CDC file. | |
Sint32 CRM64Pro::XML::info | ( | Sint32 | iMode = 0 | ) |
Request XML object information.
For displaying the information, it uses the default log.
iMode | unused for the time being. |
Sint32 CRM64Pro::XML::getName | ( | string & | sName | ) |
Get the name.
sName | a string containing the XML object name. |
Uint32 CRM64Pro::XML::getID | ( | ) |
Get the ID.
Sint32 CRM64Pro::XML::nodePointTo | ( | Sint32 | iParam, |
char * | szNodes, | ||
... | |||
) |
Search and point to the given node or subnode at any level.
It only changes the pointer when all node+[subnodes] are valid.
iParam | number node+[subnodes] in 'szNodes'. |
szNodes | string zero pointer with the node+[subnodes]. |
Sint32 CRM64Pro::XML::nodeFirst | ( | ) |
Point to the first XML node (the root node).
It only changes the pointer when it finds a valid node.
Sint32 CRM64Pro::XML::nodeNext | ( | ) |
Point to the next node (from current pointed node).
It only changes the pointer when it finds a valid node.
Sint32 CRM64Pro::XML::nodePrev | ( | ) |
Point to the previous node (from current pointed node).
It only changes the pointer when it finds a valid node.
Sint32 CRM64Pro::XML::nodeParent | ( | ) |
Point to the parent node (from current pointed node).
It only changes the pointer when it finds a valid node.
Sint32 CRM64Pro::XML::nodeChild | ( | ) |
Point to the first child node (from current pointed node).
It only changes the pointer when it finds a valid node.
Sint32 CRM64Pro::XML::nodeStore | ( | ) |
Store node pointer position.
There is only one slot per each XML so it only keeps the position of the last time this method is called.
Sint32 CRM64Pro::XML::nodeRestore | ( | ) |
Restore node pointer position.
There is only one slot per each XML so it restores the position of the last time nodeStore() method was called.
Sint32 CRM64Pro::XML::nodeRemove | ( | ) |
Remove pointed node and all its subnodes and attributes.
Sint32 CRM64Pro::XML::nodeCreate | ( | const string & | sNode | ) |
Create a new node inside the pointed node and point to it.
sNode | string containing the node name. |
Sint32 CRM64Pro::XML::nodeRename | ( | const string & | sNode | ) |
Rename pointed node.
sNode | string containing the node name. |
Sint32 CRM64Pro::XML::nodeGetName | ( | string & | sNode | ) |
Get the name of pointed node.
sNode | a string variable. Will not be modified when there is not a valid pointed node. |
Sint32 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.
sAttr | attribute name string. |
sValue | string value. |
Sint32 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.
sAttr | attribute name string. |
iValue | integer value. |
Sint32 CRM64Pro::XML::setAttribute | ( | const string & | sAttr, |
const double & | dValue | ||
) |
Set an attribute inside pointed node with an integer value.
If the attribute does not exist, it will be created.
sAttr | attribute name string. |
dValue | integer value. |
Sint32 CRM64Pro::XML::getAttribute | ( | const string & | sAttr, |
string & | sValue | ||
) |
Get the string value of an attribute inside the pointed node.
sAttr | attribute name string. |
sValue | a string variable. Will not be modified when the attribute does not exist. |
Sint32 CRM64Pro::XML::getAttribute | ( | const string & | sAttr, |
Sint32 & | iValue | ||
) |
Get the integer value of an attribute inside the pointed node.
sAttr | attribute name string. |
iValue | an integer variable. Will not be modified when the attribute does not exist. |
Sint32 CRM64Pro::XML::getAttribute | ( | const string & | sAttr, |
double & | dValue | ||
) |
Get the double value of an attribute inside the pointed node.
sAttr | attribute name string. |
dValue | a double variable. Will not be modified when the attribute does not exist. |
Sint32 CRM64Pro::XML::removeAttribute | ( | const string & | sAttr | ) |
Remove an attribute and its value inside the pointed node.
sAttr | attribute name string. |
Sint32 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.
sText | text string. |
Sint32 CRM64Pro::XML::getText | ( | string & | sText | ) |
Get the text contained in the pointed node.
sText | a string variable. Will not be modified when the text does not exist. |
Sint32 CRM64Pro::XML::removeText | ( | ) |
Remove the text inside the pointed node.
Sint32 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.
sComment | comment text string. |
Sint32 CRM64Pro::XML::getComment | ( | string & | sComment | ) |
Get the comment text contained in the pointed node.
sComment | a string variable. Will not be modified when the comment does not exist. |
Sint32 CRM64Pro::XML::removeComment | ( | ) |
Remove the comment text inside the pointed node.
Sint32 CRM64Pro::XML::saveToFile | ( | const string & | sFile | ) |
Export the XML to an external file.
sFile | string containing the [directory]+filename+[extension]. Ideally, it should have the .xml extension. If the XML file already exists, it will be overwritten. Directory separators '\' and '/' are supported. |
Sint32 CRM64Pro::XML::save | ( | const string & | sFileCDC | ) |
Save the XML in to a CDC file.
If the XML already exists on the CDC, it will be overwritten.
sFileCDC | string containing the [directory]+filename+[extension]. Directory separators '\' and '/' are supported. |
Sint32 CRM64Pro::XML::save | ( | Sint32 | idCDC | ) |
Sint32 CRM64Pro::XMLMgr::info | ( | Sint32 | iMode = 0 | ) |
Request XML Manager information.
For displaying the information, it uses the default log.
iMode | -1 for displaying only Manager information. 0 for displaying Manager and all Objects information. This is the default value. idXML for displaying Manager and given XML id information. |
Sint32 CRM64Pro::XMLMgr::create | ( | const string & | sMainNode, |
Uint32 | iUnused = 0 |
||
) |
Create a new XML.
sMainNode | The name to give to the the main node (e.g. 'myRootNode'). It is also used to set the XML object name. The object name must be unique and with a maximum size of 64 characters or will be truncated. |
iUnused | unused for the time being. |
Sint32 CRM64Pro::XMLMgr::close | ( | Sint32 | idXML | ) |
Sint32 CRM64Pro::XMLMgr::getNum | ( | ) |
Get number of loaded objects.
Sint32 CRM64Pro::XMLMgr::setName | ( | Sint32 | idXML, |
const string & | sName | ||
) |
XML * CRM64Pro::XMLMgr::get | ( | Sint32 | idXML = 0 | ) |
Sint32 CRM64Pro::XMLMgr::loadFromFile | ( | const string & | sFile, |
const string & | sName = "" |
||
) |
Load a XML file.
sFile | string containing the [directory]+filename+[extension]. Directory separators '\' and '/' are supported. |
sName | the XML object name. By default, it is set to empty to use the filename (without extension) for setting the XML object name. The object name must be unique and with a maximum size of 64 characters or will be truncated. |
Sint32 CRM64Pro::XMLMgr::loadFromBuffer | ( | const unsigned char * | szData, |
const Sint32 | iSize, | ||
const string & | sName | ||
) |
Load a XML from a buffer.
szData | pointer to buffer data that contains the XML to be loaded. |
iSize | size in bytes of the buffer data. |
sName | the XML object name. By default, it is set to empty to use the filename (without extension) for setting the XML object name. The object name must be unique and with a maximum size of 64 characters or will be truncated. |
Sint32 CRM64Pro::XMLMgr::load | ( | const string & | sFileCDC, |
const string & | sName | ||
) |
Load a XML file stored in a CDC file.
sFileCDC | string containing the [directory]+filename+[extension]. Directory separators '\' and '/' are supported. |
sName | string containing the XML object name. The object name must be unique and with a maximum size of 64 characters or will be truncated. |
Sint32 CRM64Pro::XMLMgr::load | ( | Sint32 | idCDC, |
const string & | sName | ||
) |
Sint32 CRM64Pro::XMLMgr::remove | ( | Sint32 | idCDC, |
const string & | sName | ||
) |