| CRM64Pro GDK v0.16.0 A free cross-platform game development kit built on top of SDL 3.0

Loading...
Searching...
No Matches
CRM64Pro::XMLMgr
Core modules » XML

XML Manager class. More...

## Detailed Description

XML Manager class.

## Public Member Functions
bool | info (Sint32 iMode=0) override
| Request XML Manager information.
Sint32 | create (const string &sMainNode, Uint32 iUnused=0) override
| Create a new XML.
bool | close (Sint32 idXML) override
| Close and destroy a XML object.
Sint32 | getCount () const override
| Get number of loaded objects.
Sint32 | setName (Sint32 idXML, const string &sName) override
| Change the object name.
XML * | get (Sint32 idXML=0)
| Get a pointer to the XML using its handler.
Sint32 | loadFromFile (const string &sFile, const string &sName="")
| Load a XML from an external file.
Sint32 | loadFromBuffer (const void *pBuffer, Sint32 iSize, const string &sName)
| Load a XML from a buffer.
Sint32 | load (const string &sCDCFile, const string &sName)
| Load a XML file stored in a CDC file.
Sint32 | load (const Sint32 idCDC, const string &sName)
| Load a XML file stored in a CDC file.
Sint32 | remove (Sint32 idCDC, const string &sName)
| Remove a XML file stored in a CDC file.
bool | exist (const Sint32 idCDC, const string &sName)
| Check if a XML is stored in a CDC file.
bool | exist (const string &sCDCFile, const string &sName)
| Check if a XML is stored in a CDC file.

## Member Function Documentation

## ◆ info()

bool CRM64Pro::XMLMgr::info | ( | Sint32 | iMode = 0 | ) |
| override

Request XML Manager information.

Writes information to the default log.

Parameters

  iMode | -1 to display only manager information. 0 (default) to display manager and all objects. Specific object ID to display manager and only that object.

Returns
  true on success or false on failure.

## ◆ create()

Sint32 CRM64Pro::XMLMgr::create | ( | const string & | sMainNode,
|  | Uint32 | iUnused = 0 )
| override

Create a new XML.

Parameters

  sMainNode | The name for the main node (e.g. 'myRootNode'). Also used as the XML object name. Must be unique, max 64 characters (truncated if longer).
  iUnused | unused for the time being.

Returns
  greater than 0 on success (the XML id) or a negative error code on failure.

## ◆ close()

bool CRM64Pro::XMLMgr::close | ( | Sint32 | idXML | ) |
| override

Close and destroy a XML object.

Parameters

  idXML | 0 for closing all XMLs or the XML id.

Returns
  true if at least one XML object was closed, or false if none were closed.

Note
  If you forget to close a XML, it will be automatically closed once the GDK is terminated.

## ◆ getCount()

Sint32 CRM64Pro::XMLMgr::getCount | ( |  | ) | const
| override

Get number of loaded objects.

Returns
  the number of XML objects.

## ◆ setName()

Sint32 CRM64Pro::XMLMgr::setName | ( | Sint32 | idXML,
|  | const string & | sName )
| override

Change the object name.

Parameters

  idXML | XML id.
  sName | The name for the XML object (e.g. 'myXML'). Must be unique, max 64 characters (truncated if longer).

Returns
  0 on success, or a negative error code on failure.

## ◆ get()

XML * CRM64Pro::XMLMgr::get | ( | Sint32 | idXML = 0 | ) |

Get a pointer to the XML using its handler.

Parameters

  idXML | XML id. By default it returns the first XML.

Returns
  nullptr the XML was not found.
  A pointer to the XML object.

## ◆ loadFromFile()

Sint32 CRM64Pro::XMLMgr::loadFromFile | ( | const string & | sFile,
|  | const string & | sName = "" )

Load a XML from an external file.

Parameters

  sFile | string containing [directory]+filename+[extension]. Directory separators '\' and '/' are supported.
  sName | the XML object name. If empty (default), uses the filename without extension. Must be unique, max 64 characters (truncated if longer).

Returns
  greater than 0 on success (the XML id) or a negative error code on failure.

## ◆ loadFromBuffer()

Sint32 CRM64Pro::XMLMgr::loadFromBuffer | ( | const void * | pBuffer,
|  | Sint32 | iSize,
|  | const string & | sName )

Load a XML from a buffer.

Parameters

  pBuffer | pointer to buffer data containing the XML to be loaded.
  iSize | size in bytes of the buffer data.
  sName | the XML object name. Must be unique, max 64 characters (truncated if longer).

Returns
  greater than 0 on success (the XML id) or a negative error code on failure.

## ◆ load() [1/2]

Sint32 CRM64Pro::XMLMgr::load | ( | const string & | sCDCFile,
|  | const string & | sName )

Load a XML file stored in a CDC file.

Parameters

  sCDCFile | string containing [directory]+filename+[extension]. Directory separators '\' and '/' are supported.
  sName | string containing the XML object name. Must be unique, max 64 characters (truncated if longer).

Returns
  greater than 0 on success (the XML id) 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 XMLMgr::load() with the CDC id instead.

## ◆ load() [2/2]

Sint32 CRM64Pro::XMLMgr::load | ( | const Sint32 | idCDC,
|  | const string & | sName )

Load a XML file stored in a CDC file.

Parameters

  idCDC | CDC id
  sName | string containing the XML object name. Must be unique, max 64 characters (truncated if longer).

Returns
  greater than 0 on success (the XML id) or a negative error code on failure.

## ◆ remove()

Sint32 CRM64Pro::XMLMgr::remove | ( | Sint32 | idCDC,
|  | const string & | sName )

Remove a XML file stored in a CDC file.

Parameters

  idCDC | CDC id.
  sName | string containing the XML object name (maximum size of 64 characters).

Returns
  greater than 0 on success, or a negative error code on failure.

Note
  The XML object must be closed before trying to remove it from the CDC.

## ◆ exist() [1/2]

bool CRM64Pro::XMLMgr::exist | ( | const Sint32 | idCDC,
|  | const string & | sName )

Check if a XML is stored in a CDC file.

Parameters

  idCDC | CDC id.
  sName | string with the XML name (maximum size of 64 characters).

Returns
  true on success (it exists) or false on failure (it does not exist).

## ◆ exist() [2/2]

bool CRM64Pro::XMLMgr::exist | ( | const string & | sCDCFile,
|  | const string & | sName )

Check if a XML is stored in a CDC file.

Parameters

  sCDCFile | Path to the CDC archive file.
  sName | string with the XML name (maximum size of 64 characters).

Returns
  true on success (it exists) or false on failure (it does not exist).