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

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 iReserved=0) override
 Create a new XML.
Sint32 close (Sint32 idXML) override
 Close and destroy an XML object.
Sint32 getCount () const override
 Get number of loaded objects.
Sint32 setName (Sint32 idXML, const string &sName) override
 Change the object name.
XMLget (Sint32 idXML)
 Get a pointer to the XML using its handle.
Sint32 loadFromFile (const string &sFile, const string &sName="")
 Load an XML object from an external file.
Sint32 loadFromBuffer (const void *pBuffer, Sint32 iSize, const string &sName)
 Load an XML object from a buffer.
Sint32 load (const string &sCDCFile, const string &sName)
 Load an XML file stored in a CDC file.
Sint32 load (Sint32 idCDC, const string &sName)
 Load an XML file stored in a CDC file.
Sint32 remove (Sint32 idCDC, const string &sName)
 Remove an XML file stored in a CDC file.
bool exists (Sint32 idCDC, const string &sName) const
 Check if an XML is stored in a CDC file.
bool exists (const string &sCDCFile, const string &sName) const
 Check if an XML is stored in a CDC file.

Member Function Documentation

◆ info()

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

Request XML Manager information.

Writes manager information to the default log.

Parameters
iMode-1 to display only manager information. 0 (default) to display manager and all objects. A specific object ID displays manager information and only that object.
Returns
true on success, or false on failure.

◆ create()

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

Create a new XML.

Parameters
sMainNodeThe name for the main node (e.g. 'rootNode'). Also used as the XML object name. Must be unique and shorter than 64 characters.
iReservedReserved for future use. Pass 0.
Returns
Greater than 0 on success (the XML id), or a negative error code on failure.

◆ close()

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

Close and destroy an XML object.

Parameters
idXML0 for closing all XML objects, or a specific XML id.
Returns
0 on success, or a negative error code on failure.
Note
If you forget to close an XML object, 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
idXMLXML id.
sNameThe name for the XML object (e.g. 'demoXML'). Must be unique and shorter than 64 characters.
Returns
0 on success, or a negative error code on failure.

◆ get()

XML * CRM64Pro::XMLMgr::get ( Sint32 idXML)

Get a pointer to the XML using its handle.

Parameters
idXMLXML id. Passing 0 returns the first loaded XML.
Returns
Borrowed pointer to the XML object, or nullptr if not found.
Note
The returned pointer must not be deleted. It remains valid until the XML object is closed or XMLMgr is reset or terminated.

◆ loadFromFile()

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

Load an XML object from an external file.

Parameters
sFilestring containing [directory]+filename+[extension]. Directory separators '\' and '/' are supported.
sNamethe XML object name. If empty (default), uses the filename without extension. Must be unique and shorter than 64 characters.
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 an XML object from a buffer.

Parameters
pBufferpointer to buffer data containing the XML to be loaded.
iSizesize in bytes of the buffer data.
sNamethe XML object name. Must be unique and shorter than 64 characters.
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 an XML file stored in a CDC file.

Parameters
sCDCFilestring containing [directory]+filename+[extension]. Directory separators '\' and '/' are supported.
sNamestring containing the XML object name. Must be unique and shorter than 64 characters.
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. Load the CDC first using ArchiveMgr::load() and use XMLMgr::load() with the CDC id instead.

◆ load() [2/2]

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

Load an XML file stored in a CDC file.

Parameters
idCDCCDC id.
sNamestring containing the XML object name. Must be unique and shorter than 64 characters.
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 an XML file stored in a CDC file.

Parameters
idCDCCDC id.
sNamestring containing the XML object name (shorter than 64 characters).
Returns
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.

◆ exists() [1/2]

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

Check if an XML is stored in a CDC file.

Parameters
idCDCCDC id.
sNamestring with the XML name (shorter than 64 characters).
Returns
true if the resource is stored in the CDC file, or false otherwise. No error is reported.

◆ exists() [2/2]

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

Check if an XML is stored in a CDC file.

Parameters
sCDCFilePath to the CDC archive file.
sNamestring with the XML name (shorter than 64 characters).
Returns
true if the resource is stored in the CDC file, or false otherwise. No error is reported.