UFO: Alien Invasion
Loading...
Searching...
No Matches
xml.cpp File Reference

UFO:AI interface functions to mxml. More...

#include "xml.h"
#include "../shared/cxx.h"
#include "../shared/shared.h"
Include dependency graph for xml.cpp:

Go to the source code of this file.

Macros

#define MXML_DESCEND_NONE   MXML_NO_DESCEND
#define MXML_TYPE_INTEGER   MXML_INTEGER
#define MXML_TYPE_OPAQUE   MXML_OPAQUE
#define MXML_TYPE_REAL   MXML_REAL
#define MXML_TYPE_TEXT   MXML_TEXT

Functions

void XML_AddString (xmlNode_t *parent, const char *name, const char *value)
 add a String attribute to the XML Node
void XML_AddStringValue (xmlNode_t *parent, const char *name, const char *value)
 add a non-empty String attribute to the XML Node
void XML_AddBool (xmlNode_t *parent, const char *name, bool value)
 add a Boolean attribute to the XML Node
void XML_AddBoolValue (xmlNode_t *parent, const char *name, bool value)
 add a non-false Boolean attribute to the XML Node
void XML_AddFloat (xmlNode_t *parent, const char *name, float value)
 add a Float attribute to the XML Node
void XML_AddFloatValue (xmlNode_t *parent, const char *name, float value)
 add a non-zero Float attribute to the XML Node
void XML_AddDouble (xmlNode_t *parent, const char *name, double value)
 add a Double attribute to the XML Node
void XML_AddDoubleValue (xmlNode_t *parent, const char *name, double value)
 add a non-zero Double attribute to the XML Node
void XML_AddByte (xmlNode_t *parent, const char *name, byte value)
 add a Byte attribute to the XML Node
void XML_AddByteValue (xmlNode_t *parent, const char *name, byte value)
 add a non-zero Byte attribute to the XML Node
void XML_AddShort (xmlNode_t *parent, const char *name, short value)
 add a Short attribute to the XML Node
void XML_AddShortValue (xmlNode_t *parent, const char *name, short value)
 add a non-zero Short attribute to the XML Node
void XML_AddInt (xmlNode_t *parent, const char *name, int value)
 add an Int attribute to the XML Node
void XML_AddIntValue (xmlNode_t *parent, const char *name, int value)
 add a non-zero Int attribute to the XML Node
void XML_AddLong (xmlNode_t *parent, const char *name, long value)
 add a Long attribute to the XML Node
void XML_AddLongValue (xmlNode_t *parent, const char *name, long value)
 add a non-zero Long attribute to the XML Node
void XML_AddPos3 (xmlNode_t *parent, const char *name, const vec3_t pos)
 add a Pos3 data to the XML Tree
void XML_AddPos2 (xmlNode_t *parent, const char *name, const vec2_t pos)
 add a Pos2 data to the XML Tree
void XML_AddDate (xmlNode_t *parent, const char *name, const int day, const int sec)
 add a date data to the XML Tree
xmlNode_tXML_AddNode (xmlNode_t *parent, const char *name)
 add a new node to the XML tree
bool XML_GetBool (xmlNode_t *parent, const char *name, const bool defaultval)
 retrieve a Boolean attribute from an XML Node
int XML_GetInt (xmlNode_t *parent, const char *name, const int defaultval)
 retrieve an Int attribute from an XML Node
short XML_GetShort (xmlNode_t *parent, const char *name, const short defaultval)
 retrieve a Short attribute from an XML Node
long XML_GetLong (xmlNode_t *parent, const char *name, const long defaultval)
 retrieve a Long attribute from an XML Node
const char * XML_GetString (xmlNode_t *parent, const char *name)
 retrieve a String attribute from an XML Node
float XML_GetFloat (xmlNode_t *parent, const char *name, const float defaultval)
 retrieve a Float attribute from an XML Node
double XML_GetDouble (xmlNode_t *parent, const char *name, const double defaultval)
 retrieve a Double attribute from an XML Node
xmlNode_tXML_GetPos2 (xmlNode_t *parent, const char *name, vec2_t pos)
 retrieve the first Pos2 data from an XML Node
xmlNode_tXML_GetNextPos2 (xmlNode_t *actual, xmlNode_t *parent, const char *name, vec2_t pos)
 retrieve the next Pos2 data from an XML Node
xmlNode_tXML_GetPos3 (xmlNode_t *parent, const char *name, vec3_t pos)
 retrieve the first Pos3 data from an XML Node
xmlNode_tXML_GetNextPos3 (xmlNode_t *actual, xmlNode_t *parent, const char *name, vec3_t pos)
 retrieve the next Pos3 data from an XML Node
xmlNode_tXML_GetDate (xmlNode_t *parent, const char *name, int *day, int *sec)
 retrieve the date data from an XML Node
xmlNode_tXML_GetNode (xmlNode_t *parent, const char *name)
 Get first Node of the XML tree by name.
xmlNode_tXML_GetNextNode (xmlNode_t *current, xmlNode_t *parent, const char *name)
 Get next Node of the XML tree by name.
static mxml_type_t mxml_ufo_type_cb (xmlNode_t *node)
 callback function for parsing the node tree
xmlNode_tXML_Parse (const char *buffer)

Detailed Description

UFO:AI interface functions to mxml.

Definition in file xml.cpp.

Macro Definition Documentation

◆ MXML_DESCEND_NONE

#define MXML_DESCEND_NONE   MXML_NO_DESCEND

Definition at line 31 of file xml.cpp.

Referenced by XML_GetNextNode().

◆ MXML_TYPE_INTEGER

#define MXML_TYPE_INTEGER   MXML_INTEGER

Definition at line 32 of file xml.cpp.

Referenced by mxml_ufo_type_cb().

◆ MXML_TYPE_OPAQUE

#define MXML_TYPE_OPAQUE   MXML_OPAQUE

Definition at line 33 of file xml.cpp.

Referenced by mxml_ufo_type_cb().

◆ MXML_TYPE_REAL

#define MXML_TYPE_REAL   MXML_REAL

Definition at line 34 of file xml.cpp.

Referenced by mxml_ufo_type_cb().

◆ MXML_TYPE_TEXT

#define MXML_TYPE_TEXT   MXML_TEXT

Definition at line 35 of file xml.cpp.

Referenced by mxml_ufo_type_cb().

Function Documentation

◆ mxml_ufo_type_cb()

mxml_type_t mxml_ufo_type_cb ( xmlNode_t * node)
static

callback function for parsing the node tree

Definition at line 517 of file xml.cpp.

References MXML_TYPE_INTEGER, MXML_TYPE_OPAQUE, MXML_TYPE_REAL, MXML_TYPE_TEXT, Q_streq, type, and xmlNode_t.

Referenced by XML_Parse().

◆ XML_AddBool()

void XML_AddBool ( xmlNode_t * parent,
const char * name,
bool value )

add a Boolean attribute to the XML Node

Parameters
[out]parentXML Node structure to add to
[in]nameName of the attribute
[in]valueValue of the attribute

Definition at line 71 of file xml.cpp.

References name, and xmlNode_t.

Referenced by GAME_GetImportData(), and XML_AddBoolValue().

◆ XML_AddBoolValue()

void XML_AddBoolValue ( xmlNode_t * parent,
const char * name,
bool value )

add a non-false Boolean attribute to the XML Node

Parameters
[out]parentXML Node structure to add to
[in]nameName of the attribute
[in]valueValue of the attribute
Note
if the value is false nothing will be added

Definition at line 83 of file xml.cpp.

References name, XML_AddBool(), and xmlNode_t.

Referenced by GAME_GetImportData(), and cgame_import_t::void().

◆ XML_AddByte()

void XML_AddByte ( xmlNode_t * parent,
const char * name,
byte value )

add a Byte attribute to the XML Node

Parameters
[out]parentXML Node structure to add to
[in]nameName of the attribute
[in]valueValue of the attribute

Definition at line 146 of file xml.cpp.

References name, XML_AddLong(), and xmlNode_t.

Referenced by GAME_GetImportData().

◆ XML_AddByteValue()

void XML_AddByteValue ( xmlNode_t * parent,
const char * name,
byte value )

add a non-zero Byte attribute to the XML Node

Parameters
[out]parentXML Node structure to add to
[in]nameName of the attribute
[in]valueValue of the attribute
Note
if the value is zero nothing will be added

Definition at line 158 of file xml.cpp.

References name, XML_AddLongValue(), and xmlNode_t.

Referenced by GAME_GetImportData(), and cgame_import_t::void().

◆ XML_AddDate()

void XML_AddDate ( xmlNode_t * parent,
const char * name,
const int day,
const int sec )

add a date data to the XML Tree

Parameters
[out]parentXML Node structure to add to
[in]nameName of the node to add
[in]dayDay part of the date
[in]secSecond part of the date
Note
it creates a new node and adds day/sec attributes to the node

Definition at line 273 of file xml.cpp.

References name, XML_AddInt(), and xmlNode_t.

Referenced by GAME_GetImportData().

◆ XML_AddDouble()

void XML_AddDouble ( xmlNode_t * parent,
const char * name,
double value )

add a Double attribute to the XML Node

Parameters
[out]parentXML Node structure to add to
[in]nameName of the attribute
[in]valueValue of the attribute

Definition at line 119 of file xml.cpp.

References name, and xmlNode_t.

Referenced by GAME_GetImportData(), XML_AddDoubleValue(), and XML_AddFloat().

◆ XML_AddDoubleValue()

void XML_AddDoubleValue ( xmlNode_t * parent,
const char * name,
double value )

add a non-zero Double attribute to the XML Node

Parameters
[out]parentXML Node structure to add to
[in]nameName of the attribute
[in]valueValue of the attribute
Note
if the value is zero nothing will be added

Definition at line 133 of file xml.cpp.

References name, XML_AddDouble(), and xmlNode_t.

Referenced by GAME_GetImportData(), cgame_import_t::void(), and XML_AddFloatValue().

◆ XML_AddFloat()

void XML_AddFloat ( xmlNode_t * parent,
const char * name,
float value )

add a Float attribute to the XML Node

Parameters
[out]parentXML Node structure to add to
[in]nameName of the attribute
[in]valueValue of the attribute

Definition at line 96 of file xml.cpp.

References name, XML_AddDouble(), and xmlNode_t.

Referenced by GAME_GetImportData(), XML_AddPos2(), and XML_AddPos3().

◆ XML_AddFloatValue()

void XML_AddFloatValue ( xmlNode_t * parent,
const char * name,
float value )

add a non-zero Float attribute to the XML Node

Parameters
[out]parentXML Node structure to add to
[in]nameName of the attribute
[in]valueValue of the attribute
Note
if the value is zero nothing will be added

Definition at line 108 of file xml.cpp.

References name, XML_AddDoubleValue(), and xmlNode_t.

Referenced by GAME_GetImportData(), and cgame_import_t::void().

◆ XML_AddInt()

void XML_AddInt ( xmlNode_t * parent,
const char * name,
int value )

add an Int attribute to the XML Node

Parameters
[out]parentXML Node structure to add to
[in]nameName of the attribute
[in]valueValue of the attribute

Definition at line 192 of file xml.cpp.

References name, XML_AddLong(), and xmlNode_t.

Referenced by GAME_GetImportData(), GAME_SaveCharacter(), GAME_SaveItem(), and XML_AddDate().

◆ XML_AddIntValue()

void XML_AddIntValue ( xmlNode_t * parent,
const char * name,
int value )

add a non-zero Int attribute to the XML Node

Parameters
[out]parentXML Node structure to add to
[in]nameName of the attribute
[in]valueValue of the attribute
Note
if the value is zero nothing will be added

Definition at line 204 of file xml.cpp.

References name, XML_AddLongValue(), and xmlNode_t.

Referenced by GAME_GetImportData(), GAME_SaveCharacter(), GAME_SaveItem(), GAME_SaveTeam(), and cgame_import_t::void().

◆ XML_AddLong()

void XML_AddLong ( xmlNode_t * parent,
const char * name,
long value )

add a Long attribute to the XML Node

Parameters
[out]parentXML Node structure to add to
[in]nameName of the attribute
[in]valueValue of the attribute

Definition at line 215 of file xml.cpp.

References name, and xmlNode_t.

Referenced by GAME_GetImportData(), XML_AddByte(), XML_AddInt(), XML_AddLongValue(), and XML_AddShort().

◆ XML_AddLongValue()

void XML_AddLongValue ( xmlNode_t * parent,
const char * name,
long value )

add a non-zero Long attribute to the XML Node

Parameters
[out]parentXML Node structure to add to
[in]nameName of the attribute
[in]valueValue of the attribute
Note
if the value is zero nothing will be added

Definition at line 229 of file xml.cpp.

References name, XML_AddLong(), and xmlNode_t.

Referenced by GAME_GetImportData(), cgame_import_t::void(), XML_AddByteValue(), XML_AddIntValue(), and XML_AddShortValue().

◆ XML_AddNode()

xmlNode_t * XML_AddNode ( xmlNode_t * parent,
const char * name )

add a new node to the XML tree

Parameters
[out]parentXML Node structure to add to
[in]nameName of the new node return pointer to the new XML Node structure

Definition at line 286 of file xml.cpp.

References name, and xmlNode_t.

Referenced by GAME_GetImportData(), GAME_SaveCharacter(), GAME_SaveInventory(), GAME_SaveTeam(), and GAME_SaveTeamInfo().

◆ XML_AddPos2()

void XML_AddPos2 ( xmlNode_t * parent,
const char * name,
const vec2_t pos )

add a Pos2 data to the XML Tree

Parameters
[out]parentXML Node structure to add to
[in]nameName of the node to add
[in]posPos2 structure with position data
Note
it creates a new node and adds coordinate(s) to the node as attributes

Definition at line 258 of file xml.cpp.

References name, XML_AddFloat(), and xmlNode_t.

Referenced by GAME_GetImportData().

◆ XML_AddPos3()

void XML_AddPos3 ( xmlNode_t * parent,
const char * name,
const vec3_t pos )

add a Pos3 data to the XML Tree

Parameters
[out]parentXML Node structure to add to
[in]nameName of the node to add
[in]posPos3 structure with position data
Note
it creates a new node and adds coordinate(s) to the node as attributes

Definition at line 243 of file xml.cpp.

References name, XML_AddFloat(), and xmlNode_t.

Referenced by GAME_GetImportData().

◆ XML_AddShort()

void XML_AddShort ( xmlNode_t * parent,
const char * name,
short value )

add a Short attribute to the XML Node

Parameters
[out]parentXML Node structure to add to
[in]nameName of the attribute
[in]valueValue of the attribute

Definition at line 169 of file xml.cpp.

References name, XML_AddLong(), and xmlNode_t.

Referenced by GAME_GetImportData().

◆ XML_AddShortValue()

void XML_AddShortValue ( xmlNode_t * parent,
const char * name,
short value )

add a non-zero Short attribute to the XML Node

Parameters
[out]parentXML Node structure to add to
[in]nameName of the attribute
[in]valueValue of the attribute
Note
if the value is zero nothing will be added

Definition at line 181 of file xml.cpp.

References name, XML_AddLongValue(), and xmlNode_t.

Referenced by GAME_GetImportData(), and cgame_import_t::void().

◆ XML_AddString()

void XML_AddString ( xmlNode_t * parent,
const char * name,
const char * value )

add a String attribute to the XML Node

Parameters
[out]parentXML Node structure to add to
[in]nameName of the attribute
[in]valueValue of the attribute

Definition at line 45 of file xml.cpp.

References name, and xmlNode_t.

Referenced by GAME_GetImportData(), GAME_SaveCharacter(), GAME_SaveItem(), GAME_SaveTeam(), and XML_AddStringValue().

◆ XML_AddStringValue()

void XML_AddStringValue ( xmlNode_t * parent,
const char * name,
const char * value )

add a non-empty String attribute to the XML Node

Parameters
[out]parentXML Node structure to add to
[in]nameName of the attribute
[in]valueValue of the attribute
Note
if the value is empty nothing will be added

Definition at line 58 of file xml.cpp.

References name, Q_strnull(), XML_AddString(), and xmlNode_t.

Referenced by GAME_GetImportData(), and cgame_import_t::void().

◆ XML_GetBool()

bool XML_GetBool ( xmlNode_t * parent,
const char * name,
const bool defaultval )

retrieve a Boolean attribute from an XML Node

Parameters
[in]parentXML Node structure to get from
[in]nameName of the attribute
[in]defaultvalDefault value to return if no such attribute defined

Definition at line 297 of file xml.cpp.

References name, Q_streq, and xmlNode_t.

Referenced by cgame_import_t::bool(), and GAME_GetImportData().

◆ XML_GetDate()

xmlNode_t * XML_GetDate ( xmlNode_t * parent,
const char * name,
int * day,
int * sec )

retrieve the date data from an XML Node

Parameters
[in]parentXML Node structure to get child from
[in]nameName of the pos node
[out]dayDay part of the date to fill
[out]secSecond part of the date to fill
Returns
pointer to the node the data was retrieved from
nullptr if no node with name found

Definition at line 480 of file xml.cpp.

References name, XML_GetInt(), XML_GetNode(), and xmlNode_t.

Referenced by GAME_GetImportData().

◆ XML_GetDouble()

double XML_GetDouble ( xmlNode_t * parent,
const char * name,
const double defaultval )

retrieve a Double attribute from an XML Node

Parameters
[in]parentXML Node structure to get from
[in]nameName of the attribute
[in]defaultvalDefault value to return if no such attribute defined

Definition at line 387 of file xml.cpp.

References name, and xmlNode_t.

Referenced by GAME_GetImportData().

◆ XML_GetFloat()

float XML_GetFloat ( xmlNode_t * parent,
const char * name,
const float defaultval )

retrieve a Float attribute from an XML Node

Parameters
[in]parentXML Node structure to get from
[in]nameName of the attribute
[in]defaultvalDefault value to return if no such attribute defined

Definition at line 373 of file xml.cpp.

References name, and xmlNode_t.

Referenced by GAME_GetImportData(), XML_GetNextPos2(), XML_GetNextPos3(), XML_GetPos2(), and XML_GetPos3().

◆ XML_GetInt()

int XML_GetInt ( xmlNode_t * parent,
const char * name,
const int defaultval )

retrieve an Int attribute from an XML Node

Parameters
[in]parentXML Node structure to get from
[in]nameName of the attribute
[in]defaultvalDefault value to return if no such attribute defined

Definition at line 317 of file xml.cpp.

References name, and xmlNode_t.

Referenced by GAME_GetImportData(), GAME_LoadCharacter(), GAME_LoadItem(), GAME_LoadTeam(), and XML_GetDate().

◆ XML_GetLong()

long XML_GetLong ( xmlNode_t * parent,
const char * name,
const long defaultval )

retrieve a Long attribute from an XML Node

Parameters
[in]parentXML Node structure to get from
[in]nameName of the attribute
[in]defaultvalDefault value to return if no such attribute defined

Definition at line 345 of file xml.cpp.

References name, and xmlNode_t.

Referenced by GAME_GetImportData().

◆ XML_GetNextNode()

xmlNode_t * XML_GetNextNode ( xmlNode_t * current,
xmlNode_t * parent,
const char * name )

Get next Node of the XML tree by name.

Parameters
[in]currentPointer to the previous Node was found
[in]parentParent XML Node structure
[in]nameName of the node to retrieve
Returns
pointer to the found XML Node structure or nullptr

Definition at line 508 of file xml.cpp.

References MXML_DESCEND_NONE, name, and xmlNode_t.

Referenced by AIR_LoadAircraftSlotsXML(), B_LoadBaseSlotsXML(), GAME_GetImportData(), GAME_LoadCharacter(), GAME_LoadInventory(), GAME_LoadTeam(), GAME_LoadTeamInfo(), XML_GetNextPos2(), and XML_GetNextPos3().

◆ XML_GetNextPos2()

xmlNode_t * XML_GetNextPos2 ( xmlNode_t * actual,
xmlNode_t * parent,
const char * name,
vec2_t pos )

retrieve the next Pos2 data from an XML Node

Parameters
[in]actualXML Node pointer of the previous pos data
[in]parentXML Node structure to get child from
[in]nameName of the pos node
[out]posvec2_t structure to fill
Returns
pointer to the node the data was retrieved from
nullptr if no Node with name found

Definition at line 422 of file xml.cpp.

References name, XML_GetFloat(), XML_GetNextNode(), and xmlNode_t.

Referenced by GAME_GetImportData().

◆ XML_GetNextPos3()

xmlNode_t * XML_GetNextPos3 ( xmlNode_t * actual,
xmlNode_t * parent,
const char * name,
vec3_t pos )

retrieve the next Pos3 data from an XML Node

Parameters
[in]actualXML Node pointer of the previous pos data
[in]parentXML Node structure to get child from
[in]nameName of the pos node
[out]posvec3_t structure to fill
Returns
pointer to the node the data was retrieved from
nullptr if no Node with name found

Definition at line 460 of file xml.cpp.

References name, XML_GetFloat(), XML_GetNextNode(), and xmlNode_t.

Referenced by GAME_GetImportData().

◆ XML_GetNode()

xmlNode_t * XML_GetNode ( xmlNode_t * parent,
const char * name )

Get first Node of the XML tree by name.

Parameters
[in]parentParent XML Node structure
[in]nameName of the node to retrieve
Returns
pointer to the found XML Node structure or nullptr

Definition at line 496 of file xml.cpp.

References name, and xmlNode_t.

Referenced by GAME_GetImportData(), GAME_LoadCharacter(), GAME_LoadInventory(), GAME_LoadTeam(), GAME_LoadTeamInfo(), XML_GetDate(), XML_GetPos2(), and XML_GetPos3().

◆ XML_GetPos2()

xmlNode_t * XML_GetPos2 ( xmlNode_t * parent,
const char * name,
vec2_t pos )

retrieve the first Pos2 data from an XML Node

Parameters
[in]parentXML Node structure to get child from
[in]nameName of the pos node
[out]posvec2_t structure to fill
Returns
pointer to the node the data was retrieved from
nullptr if no node with name found

Definition at line 403 of file xml.cpp.

References name, XML_GetFloat(), XML_GetNode(), and xmlNode_t.

Referenced by GAME_GetImportData().

◆ XML_GetPos3()

xmlNode_t * XML_GetPos3 ( xmlNode_t * parent,
const char * name,
vec3_t pos )

retrieve the first Pos3 data from an XML Node

Parameters
[in]parentXML Node structure to get child from
[in]nameName of the pos node
[out]posvec3_t structure to fill
Returns
pointer to the node the data was retrieved from
nullptr if no node with name found

Definition at line 440 of file xml.cpp.

References name, XML_GetFloat(), XML_GetNode(), and xmlNode_t.

Referenced by GAME_GetImportData().

◆ XML_GetShort()

short XML_GetShort ( xmlNode_t * parent,
const char * name,
const short defaultval )

retrieve a Short attribute from an XML Node

Parameters
[in]parentXML Node structure to get from
[in]nameName of the attribute
[in]defaultvalDefault value to return if no such attribute defined

Definition at line 331 of file xml.cpp.

References name, and xmlNode_t.

Referenced by GAME_GetImportData().

◆ XML_GetString()

const char * XML_GetString ( xmlNode_t * parent,
const char * name )

retrieve a String attribute from an XML Node

Parameters
[in]parentXML Node structure to get from
[in]nameName of the attribute
Returns
empty string if no such attribute defined

Definition at line 359 of file xml.cpp.

References name, and xmlNode_t.

Referenced by GAME_GetImportData(), GAME_LoadCharacter(), GAME_LoadItem(), and GAME_LoadTeam().

◆ XML_Parse()

xmlNode_t * XML_Parse ( const char * buffer)

Definition at line 544 of file xml.cpp.

References mxml_ufo_type_cb(), and xmlNode_t.

Referenced by GAME_GetImportData(), and GAME_LoadTeam().