This page has been translated automatically.
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
FAQ
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Containers
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
CIGI Client Plugin
Rendering-Related 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.

Unigine.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


static Xml()

Default constructor that creates an empty instance.

static 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.

static Xml(Xml xml)

Constructor. Creates a path out of the specified XML file.

Arguments

  • Xml xml - XML file instance.

int setArg(string name, string value)

Sets a literal value of a given argument.

Arguments

  • string name - The XML argument name.
  • string value - The XML argument value.

Return value

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

string getArg(string name)

Gets an XML argument.

Arguments

  • string name - The XML argument name.

Return value

Value of the argument, if it is found; otherwise, 0.

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.

void setArgName(int num, string name)

Sets the XML argument name.

Arguments

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

string getArgName(int num)

Returns argument name by its number.

Arguments

  • int num - Argument number.

Return value

Argument name.

void setArgValue(int num, string value)

Sets the XML argument value.

Arguments

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

string getArgValue(int num)

Returns the XML argument value.

Arguments

  • int num - The argument number.

Return value

Argument value.

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 the argument. Any non-zero value means true, the zero value means false.

Return value

Returns 1 if the operation was successful; 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.

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.

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 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.

Xml getChild(string name)

Returns the child of the XML tree.

Arguments

  • string name - The child number.

Return value

XML instance.

Xml getChild(int num)

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

  • int num - The child number.

Return value

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

int isChild(string name)

Checks if a child element with a given name exists.

Arguments

  • string name - Element name to check.

Return value

string getChildData(string name)

Gets the data from the XML child node.

Arguments

  • string name - Name of the child node.

Return value

The value of the child node.

void setData(string data)

Sets an XML data.

Arguments

  • string data - The XML data.

string getData()

Gets a data from the XML file.

Return value

Data.

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.

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.

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.

dmat4 getDMat4Data()

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

Return value

Data stored in the node.

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.

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.

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.

int setDoubleArrayArg(string name, double[] src)

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

Arguments

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

Return value

Always 1.

int getDoubleArrayArg(string name, out double[] name)

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

Arguments

  • string name - Name of a target argument.
  • out double[] name

Return value

1 if dest contains anything; otherwise, 0.

int setDoubleArrayData(double[] src)

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

Arguments

  • double[] src - Reference to a vector with double components.

Return value

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

int getDoubleArrayData(out double[] dest)

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

Arguments

  • out double[] dest - Reference to a vector with double components.

Return value

1 if dest contains anything; otherwise, 0.

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.

double getDoubleData()

Returns a double interpretation of data stored in the node.

Return value

Data stored in the node.

int setDVec2Arg(string name, dvec2 value)

Sets a value of a given dvec2 argument.

Arguments

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

Return value

Always 1.

dvec2 getDVec2Arg(string name)

Returns a value of a given dvec2 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 setDVec2Data(dvec2 data)

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

Arguments

  • dvec2 data - Content to set.

dvec2 getDVec2Data()

Returns a dvec2 interpretation of data stored in the node.

Return value

Data stored in the node.

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.

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.

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.

dvec3 getDVec3Data()

Returns a dvec3 interpretation of data stored in the node.

Return value

Data stored in the node.

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.

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 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.

dvec4 getDVec4Data()

Returns a dvec4 interpretation of data stored in the node.

Return value

Data stored in the node.

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.

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.

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.

int setFloatArrayArg(string name, float[] src)

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

Arguments

  • string name - Name of an argument.
  • float[] src - Target vector.

Return value

Always 1.

int getFloatArrayArg(string name, out float[] 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.
  • out float[] dest - Target vector.

Return value

1 if dest contains anything; otherwise, 0.

int setFloatArrayData(float[] src)

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

Arguments

  • float[] src - A float array data.

Return value

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

int getFloatArrayData(out float[] dest)

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

Arguments

  • out float[] dest - Reference to a vector.

Return value

1 if dest contains anything; otherwise, 0.

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.

float getFloatData()

Returns a float interpretation of data stored in the node.

Return value

Data stored in the node.

string getFormattedSubTree(string path = 0)

Converts an XML tree into the formatted string.

Arguments

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

Return value

The result.

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 getIntArg(string name)

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

Arguments

  • string name - Name of a target argument.

Return value

Argument value.

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 setIntArrayArg(string name, string[] src, int radix = 10)

Sets an array of integers as xml argument in a given number notation. By default, the decimal number notation is used.

Arguments

  • string name - Name of an argument.
  • string[] src - An array of integers.
  • int radix - Radix to use when setting a value.

Return value

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

int getIntArrayArg(string name, out 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.
  • out int[] dest - Reference to a vector or an array of integers.

Return value

1 if values are read successfully; otherwise, 0.

int setIntArrayData(int[] src, 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[] src - 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 getIntArrayData(out int[] dest)

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

Arguments

  • out int[] dest - Reference to a vector.

Return value

1 if values are read 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 getIntData()

Returns an integer interpretation of data stored in the node.

Return value

Data stored in the node.

int setIVec2Arg(string name, ivec2 value)

Sets a value of a given ivec2 argument.

Arguments

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

Return value

Always 1.

ivec2 getIVec2Arg(string name)

Returns a value of a given ivec2 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 setIVec2Data(ivec2 data)

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

Arguments

  • ivec2 data - Content to set.

ivec2 getIVec2Data()

Returns a ivec2 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.

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.

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.

ivec3 getIVec3Data()

Returns a ivec3 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.

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.

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.

ivec4 getIVec4Data()

Returns a ivec4 interpretation of data stored in the node.

Return value

Data stored in the node.

void setLongData(long data)

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

Arguments

  • long data - Content to be set.

long getLongData()

Returns a long interpretation of data stored in the node.

Return value

Data stored in the node.

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.

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.

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.

mat4 getMat4Data()

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

Return value

Data stored in the node.

void setName(string name)

Sets a name of the node.

Arguments

  • string name - Node name.

string getName()

Returns a name of the node.

Return value

Node name.

int getNumArgs()

Returns a number of arguments.

Return value

Number of arguments.

int getNumChildren()

Returns the number of the node children.

Return value

The result.

int isOwner()

Returns the owner flag. If the pointer is the owner, on its deletion the image also will be deleted. Use grab() and release() functions to change ownership.

Return value

Owner flag.

Xml getParent()

Returns the parent of the current XML node.

Return value

XML node.

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.

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.

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.

quat getQuatData()

Returns a quaternion 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.

int setStringArrayArg(string name, string[] src)

Sets a vector of strings 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.
  • string[] src - An array of strings.

Return value

Always 1.

int getStringArrayArg(string name, string[] dest)

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

Arguments

  • string name - Name of the string.
  • string[] dest - Reference to a vector.

Return value

1 if dest contains anything; otherwise, 0.

int setStringArrayData(string[] src, string delimiter = ",")

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

Arguments

  • string[] src - Vector of strings.
  • string delimiter - Character(s) to be used as a delimiter to split tokens.

Return value

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

int getStringArrayData(string[] dest, string delimiter = ",")

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

Arguments

  • string[] dest - Vector of strings.
  • string delimiter - Character(s) to be used as a delimiter to split tokens.

Return value

1 if dest contains anything; otherwise, 0.

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 setVec2Arg(string name, vec2 value)

Sets a value of a given vec2 argument.

Arguments

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

Return value

Always 1.

vec2 getVec2Arg(string name)

Returns a value of a given vec2 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 setVec2Data(vec2 data)

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

Arguments

  • vec2 data - Content to set.

vec2 getVec2Data()

Returns a vec2 interpretation of data stored in the node.

Return value

Data stored in the node.

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.

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.

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.

vec3 getVec3Data()

Returns a vec3 interpretation of data stored in the node.

Return value

Data stored in the node.

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.

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.

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.

vec4 getVec4Data()

Returns a vec4 interpretation of data stored in the node.

Return value

Data stored in the node.

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

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

Xml addChild(string name, string args = 0)

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

Arguments

  • string name - 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.

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:
    • Xml xml - XML node.
    • string name - Name of the XML node.

Return value

Created XML node.

void clear()

Clears all data associated with the node.

void clearChildren()

Clears all children of the current XML node.

void clearUnusedData()

Clears the unused nodes and arguments.

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.

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.

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.

Xml find(string path)

Searches for an XML sub-tree.

Arguments

  • string path - Path to the XML sub-tree.

Return value

XML node.

int findArg(string name)

Searches for a XML argument by its name.

Arguments

  • string name - XML argument name.

Return value

XML argument number.

int findChild(string name)

Searches for the number of the XML node child by name.

Arguments

  • string name - Name of the XML node child.

Return value

The number of the XML node child if it is exists; otherwise, -1.

void grab()

Grabs the image (sets the owner flag to 1). The image should not be handled by the engine after this function is called.

int load(string name)

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

Arguments

  • string name - File name.

Return value

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

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.

void printUnusedData(string name)

Logs warnings of unused data for debugging.

Arguments

  • string name - Path to the file.

void release()

Sets the owner flag to 0 for the world pointer. The world should be handled by the class after this function is called.

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 if the argument is deleted successfully; otherwise, 0.

Xml removeChild(Xml xml)

Removes a child node and its descendants from the current XML node.

Arguments

  • Xml xml - XML sub-tree smart pointer.

Return value

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

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 the file.
  • int binary - Binary format flag.

Return value

string symbols(string arg1)

Replaces ampersand characters with character entity references.

Arguments

  • string arg1 - String to encode.

Return value

String which contains replaced ampersand characters with character entity references.
Last update: 2018-06-04
Build: ()