This page has been translated automatically.
Programming
Fundamentials
Setting Up Development Environment
UnigineScript
High-Level Systems
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Bounds-Related Classes
Containers
Controls-Related Classes
Engine-Related Classes
GUI-Related Classes
Node-Related Classes
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
Rendering-Related Classes
Utility Classes
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Xml Class

As Unigine extensively uses Xml for storing different types of data, it also provides functionality for parsing and saving files of this type.

Xml Class

Members


Xml ()

Default constructor that creates an empty instance.

Xml (string name, string args = 0)

Creates an Xml tree with a given node as a root.

Arguments

  • string name - Name of the node that will be a root.
  • string args - Optional arguments to the root node. If provided, they should be in this form:

    arg1=\"value1\" arg2=\"value2\" …

    If values do not contain spaces, escaped quotes can be omitted.

int setIntArrayData (int data, int radix)

Sets a vector of integers as a content for the Xml node in a given number notation. By default, the decimal number notation is used. This can be done only for Xml nodes with no children.

Arguments

  • int data - Reference to a vector.
  • int radix - Radix to use when setting a value.

Return value

1 if the content is set successfully; otherwise, 0.

int setBoolArg (string name, int value)

Sets a value of a given boolean argument.

Arguments

  • string name - Name of an argument.
  • int value - Value of an argument. Any non-zero value means true, the zero value means false.

Return value

Always 1.

String decode (string arg1)

Decodes special xml characters (less-than, greater-than, ampersand, double-quote and apostrophe) and numeric character references.

Arguments

  • string arg1 - Data to decode.

Return value

Decoded string.

variable getChildData (string name, variable value)

Allows to get the data from the Xml child node.

Arguments

  • string name - Name of the child node.
  • variable value - Type of the child (int, float, vec3, vec4, dvec3, dvec4, ivec3, ivec4, mat4, dmat4, quat, string).

Return value

The value of the child node.

void clearChildren ()

Clears all children of the current Xml node.

int getIntArrayData (int dest)

Returns an interpretation of data stored in the node as a vector of integers.

Arguments

  • int dest - Reference to a vector .

Return value

1 if values are read successfully; otherwise, 0.

int getIntArg (string name)

Returns a value of a given int argument.
Notice
To check, if an argument exists, use the isArg() method.

Arguments

  • string name - Name of a target argument.

Return value

Argument value.

dmat4 getDMat4Arg (string name)

Returns a value of a given dmat4 argument.
Notice
To check, if an argument exists, use the isArg() method.

Arguments

  • string name - Name of a target argument.

Return value

Argument value.

String getSubTree (string path = 0)

Dumps the node tree.

Arguments

  • string path - Path to the node. See the description of find() for more details.

Return value

Single-line non-indented output of the node tree. If no arguments are passed, the entire Xml tree would be output.

int getIntData ()

Returns an integer interpretation of data stored in the node.

Return value

Data stored in the node.

int setStringArrayData (int data)

Sets a vector of strings as a content for the node. This can be done only for nodes with no children.

Arguments

  • int data - Reference to a vector .

Return value

1 if the content is set successfully; otherwise, 0.

void setArgName (int num, string name)

Sets the Xml argument name.

Arguments

  • int num - The argument number.
  • string name - The argument name.

int isArg (string name)

Checks whether an argument with a given name exists.

Arguments

  • string name - Name to check.

Return value

1 if the argument exists; otherwise, 0.

int getNumArgs ()

Returns a number of arguments.

Return value

Number of arguments.

float getFloatData ()

Returns a float interpretation of data stored in the node.

Return value

Data stored in the node.

int setIVec3Arg (string name, ivec3 value)

Sets a value of a given ivec3 argument.

Arguments

  • string name - Name of an argument.
  • ivec3 value - Value of an argument.

Return value

Always 1.

void setArg (string name, variable value)

Sets a literal value of a given argument.

Arguments

  • string name - Name of an argument.
  • variable value - Value of an argument.

dvec4 getDVec4Data ()

Returns a dvec4 interpretation of data stored in the node.

Return value

Data stored in the node.

int getFloatArrayData (int dest)

Returns an interpretation of data stored in the node as a vector of floats.

Arguments

  • int dest - Reference to a vector .

Return value

1 if dest contains anything; otherwise, 0.

int getBoolArg (string name, int value)

Returns a value of a given boolean argument.
Notice
To check, if an argument exists, use the isArg() method.

Arguments

  • string name - Name of a target argument.
  • int value - Default value of the argument.

Return value

1 if the argument has a value 1, true or TRUE; 0, if the argument has a value 0, false or FALSE; otherwise, 0.

float getFloatArg (string name, float value)

Returns a value of a given float argument.
Notice
To check, if an argument exists, use the isArg() method.

Arguments

  • string name - Name of a target argument.
  • float value - Default value of the argument.

Return value

Argument value.

dmat4 getDMat4Data ()

Returns a dmat4 matrix interpretation of data stored in the node.

Return value

Data stored in the node.

double getDoubleData ()

Returns a double interpretation of data stored in the node.

Return value

Data stored in the node.

int getStringArrayData (int dest)

Returns an interpretation of data stored in the node as a vector of strings.

Arguments

  • int dest - Reference to a vector .

Return value

1 if dest contains anything; otherwise, 0.

String symbols (string arg1)

Replaces ampersand characters with character entity references.

Arguments

  • string arg1 - to encode.

Return value

String which contains replaced ampersand characters with character entity references.

void clearUnusedData ()

Clears all unused data.

double getDoubleArg (string name, double value)

Returns a value of a given double argument.
Notice
To check, if an argument exists, use the isArg() method.

Arguments

  • string name - Name of a target argument.
  • double value - Default value of the argument.

Return value

Argument value.

void setVec4Data (vec4 data)

Sets a vec4 content for the node. This can be done only for nodes with no children.

Arguments

  • vec4 data - Content to set.

void setIVec4Data (ivec4 data)

Sets a ivec4 content for the node. This can be done only for nodes with no children.

Arguments

  • ivec4 data - Content to set.

vec4 getVec4Data ()

Returns a vec4 interpretation of data stored in the node.

Return value

Data stored in the node.

int setRawData (string data)

Sets a raw content for the node. Raw data will be automatically formatted as a CDATA section. This can be done only for nodes with no children.

Arguments

  • string data - Content to set.

Return value

1 if the content is set successfully; otherwise, 0.

void setDMat4Data (dmat4 data)

Sets a dmat4 matrix content for the node. This can be done only for nodes with no children.

Arguments

  • dmat4 data - Content to set.

int setIntArrayArg (string name, int value, int radix)

Sets a vector of integers as a value of a given argument in a given number notation. By default, the decimal number notation is used.

Arguments

  • string name - Name of an argument.
  • int value - Reference to a vector.
  • int radix - Radix to use when setting a value.

Return value

1 if the vector is set successfully; otherwise, 0.

int setStringArrayArg (string name, int value)

Sets a vector of strings as a value of a given argument.

Arguments

  • string name - Name of an argument.
  • int value - Reference to a vector .

Return value

Always 1.

vec4 getVec4Arg (string name)

Returns a value of a given vec4 argument.
Notice
To check, if an argument exists, use the isArg() method.

Arguments

  • string name - Name of a target argument.

Return value

Argument value.

dvec4 getDVec4Arg (string name)

Returns a value of a given dvec4 argument.
Notice
To check, if an argument exists, use the isArg() method.

Arguments

  • string name - Name of a target argument.

Return value

Argument value.

void setBoolData (int data)

Sets a boolean content for the node. This can be done only for nodes with no children.

Arguments

  • int data - Content to set. Any non-zero value means true, the zero value means false.

int getStringArrayArg (string name, int dest)

Returns a set of string values stored in an argument and puts them in a vector.

Arguments

  • string name - Name of a target argument.
  • int dest - Reference to a vector .

Return value

1 if dest contains anything; otherwise, 0.

int findArg (string name)

Find a Xml argument by its name.

Arguments

  • string name - Xml argument name.

Return value

Xml argument number.

int setMat4Arg (string name, mat4 value)

Sets a value of a given mat4 argument.

Arguments

  • string name - Name of an argument.
  • mat4 value - Value of an argument.

Return value

Always 1.

quat getQuatData ()

Returns a quaternion interpretation of data stored in the node.

Return value

Data stored in the node.

int setIVec4Arg (string name, ivec4 value)

Sets a value of a given ivec4 argument.

Arguments

  • string name - Name of an argument.
  • ivec4 value - Value of an argument.

Return value

Always 1.

void setDoubleData (double data)

Sets a double content for the node. This can be done only for nodes with no children.

Arguments

  • double data - Content to set.

ivec3 getIVec3Data ()

Returns a ivec3 interpretation of data stored in the node.

Return value

Data stored in the node.

string getName ()

Returns a name of the node.

Return value

Node name.

int getDoubleArrayData (int src)

Returns an interpretation of data stored in the node as a vector of double components.

Arguments

  • int src - Reference to a vector with double components.

Return value

1 if dest contains anything; otherwise, 0.

mat4 getMat4Data ()

Returns a mat4 matrix interpretation of data stored in the node.

Return value

Data stored in the node.

int setFloatArrayData (int data)

Sets a vector of floats as a content for the node. This can be done only for nodes with no children.

Arguments

  • int data - Reference to a vector .

Return value

1 if the content is set successfully; otherwise, 0.

void setArgValue (int num, string value)

Sets the Xml argument value.

Arguments

  • int num - The argument number.
  • string value - The argument value.

ivec4 getIVec4Data ()

Returns a ivec4 interpretation of data stored in the node.

Return value

Data stored in the node.

void setFloatData (float data)

Sets a float content for the node. This can be done only for nodes with no children.

Arguments

  • float data - Content to set.

string getArgValue (int num)

Returns the Xml argument value.

Arguments

  • int num - Argument number.

Return value

Argument value.

void printUnusedData (string name)

Logs warnings of unused data for debugging.

Arguments

  • string name - Path to the file.

void setMat4Data (mat4 data)

Sets a mat4 matrix content for the node. This can be done only for nodes with no children.

Arguments

  • mat4 data - Content to set.

int getDoubleArrayArg (string name, int dest)

Returns a set of double values stored in an argument and puts them in a vector.

Arguments

  • string name - Name of a target argument.
  • int dest - Reference to a vector with double components.

Return value

1 if dest contains anything; otherwise, 0.

void setQuatData (quat data)

Sets a quaternion content for the node. This can be done only for nodes with no children.

Arguments

  • quat data - Content to set.

Xml addChild (Xml xml)

Appends a new Xml node to the current Xml node as a child.

Arguments

  • Xml xml - Argument of one of the following types:
    • Xmlxml - Xml node.
    • stringname - Name of the Xml node.

Return value

Created Xml node.

int getBoolArg (string name)

Returns a value of a given boolean argument.
Notice
To check, if an argument exists, use the isArg() method.

Arguments

  • string name - Name of a target argument.

Return value

1 if the argument has a value 1, true or TRUE; 0, if the argument has a value 0, false or FALSE; otherwise, 0.

int setDoubleArrayData (int src)

Sets a vector of double components as a content for the node. This can be done only for nodes with no children.

Arguments

  • int src - Reference to a vector with double components.

Return value

1 if the content is set successfully; otherwise, 0.

int getBoolData ()

Returns a boolean interpretation of data stored in the node.

Return value

1 if a value equals to 1, true or TRUE; 0, if the value equals to 0, false or FALSE; otherwise, 0.

dvec3 getDVec3Data ()

Returns a dvec3 interpretation of data stored in the node.

Return value

Data stored in the node.

String getFormattedSubTree (string path = 0)

Formats the node tree for "pretty printing". If no arguments are passed, the entire Xml tree would be output.

Arguments

  • string path - Path to the node. See the description of find() for more details.

Return value

Multi-line indented output of the node tree.

int setFloatArg (string name, float value)

Sets a value of a given float argument.

Arguments

  • string name - Name of an argument.
  • float value - Value of an argument.

Return value

Always 1.

int parse (string src)

Parses a string with Xml mark-up and sets the current node to be the root of the parsed tree.

Arguments

  • string src - String with an Xml content.

Return value

1 if a string is successfully parsed; otherwise 0.

quat getQuatArg (string name)

Returns a value of a given quat argument.
Notice
To check, if an argument exists, use the isArg() method.

Arguments

  • string name - Name of a target argument.

Return value

Argument value.

int removeArg (string name)

Removes the argument with the given name from the list of the current Xml node arguments.

Arguments

  • string name - Name of the target argument.

Return value

1 of the argument is removed successfully; otherwise, 0.

ivec3 getIVec3Arg (string name)

Returns a value of a given ivec3 argument.
Notice
To check, if an argument exists, use the isArg() method.

Arguments

  • string name - Name of a target argument.

Return value

Argument value.

int findChild (string name)

Find the number of the Xml node child by its name.

Arguments

  • string name - Name of the child of the current Xml node.

Return value

The number of the Xml node child.

int setQuatArg (string name, quat value)

Sets a value of a given quat argument.

Arguments

  • string name - Name of an argument.
  • quat value - Value of an argument.

Return value

Always 1.

void setDVec4Data (dvec4 data)

Sets a dvec4 content for the node. This can be done only for nodes with no children.

Arguments

  • dvec4 data - Content to set.

variable removeChild (variable v)

Removes an child node and its descendants from the current Xml node.

Arguments

  • variable v - Argument of one of the following types:
    • Xmlxml - Xml child node (and its descendants) to be removed.
    • stringpath - Path to the Xml child node that need to be removed. The path should have the following form:

      /node_a arg1=\"value1\"…/node_b arg1=\"value1\"…/…

      Notice
      See also the find() function.

Return value

Removed child node and its descendants, if they are found; otherwise, NULL.

int getFloatArrayArg (string name, int dest)

Returns a set of float values stored in an argument and puts them in a vector.

Arguments

  • string name - Name of a target argument.
  • int dest - Reference to a vector .

Return value

1 if dest contains anything; otherwise, 0.

vec3 getVec3Arg (string name)

Returns a value of a given vec3 argument.
Notice
To check, if an argument exists, use the isArg() method.

Arguments

  • string name - Name of a target argument.

Return value

Argument value.

int setIntArg (string name, int value, int radix = 10)

Sets a value for a given int argument in a given number notation. By default, the decimal number notation is used.

Arguments

  • string name - Name of an argument.
  • int value - Value of an argument.
  • int radix - Radix to use when setting a value.

Return value

1 if the value is set successfully; otherwise, 0.

int setIntData (int value, int radix = 10)

Sets an integer as a content for the Xml node in a given number notation. By default, the decimal number notation is used. This can be done only for Xml nodes with no children.

Arguments

  • int value - Content to set.
  • int radix - Radix to use when setting a value.

Return value

1 if the content is set successfully; otherwise, 0.

int load (string name)

Loads an Xml document and sets the current node to be the root of the parsed tree.

Arguments

  • string name - Path to an Xml file.

Return value

1 if the file is read and parsed successfully; otherwise, 0.

int setVec4Arg (string name, vec4 value)

Sets a value of a given vec4 argument.

Arguments

  • string name - Name of an argument.
  • vec4 value - Value of an argument.

Return value

Always 1.

int setFloatArrayArg (string name, int value)

Sets a vector of floats as a value of a given argument.

Arguments

  • string name - Name of an argument.
  • int value - Reference to a vector .

Return value

Always 1.

Xml getChild (variable id)

Returns a child node by its name or index number in the child list.
Notice
To check, if a child with a given name exists, use the isChild() method.

Arguments

  • variable id - Name of a node ( string ) or its index number in the child list ( int ).

Return value

Target child node, if it is found; otherwise, 0.

int getNumChildren ()

Returns a number of children contained in the node.

In the standard Xml model the child nodes can be of the following types: node, text node and comment. The data of the Xml node is considered to be an unnamed child node, resulting in correct parsing of such a code:

Source code(XML)
<text>
	text</br>text
</text>
Hence if a node has the data, it will add to the number of its children.

Return value

Number of children.

int setDVec4Arg (string name, dvec4 value)

Sets a value of a given dvec4 argument.

Arguments

  • string name - Name of an argument.
  • dvec4 value - Value of an argument.

Return value

Always 1.

int setDVec3Arg (string name, dvec3 value)

Sets a value of a given dvec3 argument.

Arguments

  • string name - Name of an argument.
  • dvec3 value - Value of an argument.

Return value

Always 1.

int setDMat4Arg (string name, dmat4 value)

Sets a value of a given dmat4 argument.

Arguments

  • string name - Name of an argument.
  • dmat4 value - Value of an argument.

Return value

Always 1.

void setDVec3Data (dvec3 data)

Sets a dvec3 content for the node. This can be done only for nodes with no children.

Arguments

  • dvec3 data - Content to set.

Xml addChild (variable v, string args)

Appends a new Xml node to the current Xml node as a child.

Arguments

  • variable v - Argument of one of the following types:
    • Xmlxml - Xml node.
    • stringname - Name of the Xml node.
  • string args - Arguments of the Xml node. The default value is 0.
    Notice
    This value should be passed if the first argument is a string

Return value

Created Xml node.

mat4 getMat4Arg (string name)

Returns a value of a given mat4 argument.
Notice
To check, if an argument exists, use the isArg() method.

Arguments

  • string name - Name of a target argument.

Return value

Argument value.

float getFloatArg (string name)

Returns a value of a given float argument.
Notice
To check, if an argument exists, use the isArg() method.

Arguments

  • string name - Name of a target argument.

Return value

Argument value.

void clear ()

Clears all data associated with the node.

int isChild (string name)

Checks if a child element with a given name exists.

Arguments

  • string name - Element name to check.

Return value

1 if a child with the provided name exists; otherwise, 0.

int getIntArg (string name, int value)

Returns a value of a given int argument.
Notice
To check, if an argument exists, use the isArg() method.

Arguments

  • string name - Name of a target argument.
  • int value - Default value of the argument.

Return value

Argument value.

int save (string name, int binary = 0)

Formats the tree of the current node and writes is to a file.

Arguments

  • string name - Path to an Xml file.
  • int binary - Binary format flag.

Return value

1 if the file is written successfully; otherwise, 0.

dvec3 getDVec3Arg (string name)

Returns a value of a given dvec3 argument.
Notice
To check, if an argument exists, use the isArg() method.

Arguments

  • string name - Name of a target argument.

Return value

Argument value.

int setDoubleArg (string name, double value)

Sets a value of a given double argument.

Arguments

  • string name - Name of an argument.
  • double value - Value of an argument.

Return value

Always 1.

void setIVec3Data (ivec3 data)

Sets a ivec3 content for the node. This can be done only for nodes with no children.

Arguments

  • ivec3 data - Content to set.

void copy (Xml source)

Copies all data (name, arguments, data, flags and a child hierarchy) from the source Xml node to the current one.

Arguments

  • Xml source - Source Xml node.

ivec4 getIVec4Arg (string name)

Returns a value of a given ivec4 argument.
Notice
To check, if an argument exists, use the isArg() method.

Arguments

  • string name - Name of a target argument.

Return value

Argument value.

vec3 getVec3Data ()

Returns a vec3 interpretation of data stored in the node.

Return value

Data stored in the node.

int setDoubleArrayArg (string name, int src)

Sets a vector of double as a value of a given argument.

Arguments

  • string name - Name of an argument.
  • int src - Reference to a vector with double components.

Return value

Always 1.

int setXmlData (string data)

Sets an unquoted string to data stored in the node. This string can also contain xml sub-tree with rich text formating.

Arguments

  • string data - Unquoted string to set.

Return value

Returns 1 if the string is set successfully; otherwise, 0.

string getArgName (int num)

Returns argument name by its number.

Arguments

  • int num - Argument number.

Return value

Argument name.

int setVec3Arg (string name, vec3 value)

Sets a value of a given vec3 argument.

Arguments

  • string name - Name of an argument.
  • vec3 value - Value of an argument.

Return value

Always 1.

void setName (string name)

Sets a name of the node.

Arguments

  • string name - Node name.

String encode (string arg1)

Encodes special xml characters (less-than, greater-than, ampersand, double-quote and apostrophe) to their character entity reference.

Arguments

  • string arg1 - Data to encode.

Return value

Encoded string.

double getDoubleArg (string name)

Returns a value of a given double argument.
Notice
To check, if an argument exists, use the isArg() method.

Arguments

  • string name - Name of a target argument.

Return value

Argument value.

void setVec3Data (vec3 data)

Sets a vec3 content for the node. This can be done only for nodes with no children.

Arguments

  • vec3 data - Content to set.

int getIntArrayArg (string name, int dest)

Returns a set of int values stored in an argument and puts them in a vector.

Arguments

  • string name - Name of a target argument.
  • int dest - Reference to a vector .

Return value

1 if values are read successfully; otherwise, 0.

Xml getParent ()

Returns the parent of the current Xml node.

Return value

Parent node of the current Xml node.
Last update: 2017-07-03
Build: ()