This page has been translated automatically.
Programming
Fundamentals
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
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
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

Header:#include <UnigineXml.h>

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 XmlPtr create()

Default constructor that creates an empty instance.

static XmlPtr create(const char * name, const char * args = 0)

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

Arguments

  • const char * name - Name of the node that will be a root.
  • const char * 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 XmlPtr create(const Ptr<Xml> & xml)

Arguments

  • const Ptr<Xml> & xml

int setArg(const char * name, const char * value)

Sets a literal value of a given argument.

Arguments

  • const char * name - The xml argument name.
  • const char * value - The xml argument value.

Return value

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

const char * getArg(const char * name)

Gets an xml argument.

Arguments

  • const char * name - The xml argument name.

Return value

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

int isArg(const char * name)

Checks if the xml has specified argument.

Arguments

  • const char * name - Name of xml argument.

Return value

The result.

void setArgName(int num, const char * name)

Sets the xml argument name.

Arguments

  • int num - The argument number.
  • const char * name - The argument name.

const char * getArgName(int num)

Returns the xml argument name.

Arguments

  • int num - The argument number.

Return value

The result.

void setArgValue(int num, const char * value)

Sets the xml argument value.

Arguments

  • int num - The argument number.
  • const char * value - The argument value.

const char * getArgValue(int num)

Returns the xml argument value.

Arguments

  • int num - The argument number.

Return value

The result.

int setBoolArg(const char * name, int value)

Sets a boolean as xml argument.

Arguments

  • const char * name - The xml argument name.
  • int value - The xml argument value.

Return value

Returns 1 if the operation was a success; otherwise, 0 is returned.

int getBoolArg(const char * name, int value)

Gets a boolean xml argument.

Arguments

  • const char * name - Name of a target argument.
  • int value - Default value of the argument.

Return value

The result.

int getBoolArg(const char * name)

Gets a boolean xml argument.

Arguments

  • const char * name - The xml argument name.

Return value

The result.

void setBoolData(int data)

Sets a boolean as xml data.

Arguments

  • int data - The xml argument value.

int getBoolData()

Gets a boolean xml data.

Return value

The result.

Ptr<Xml> getChild(const char * name)

Returns the child of the xml tree.

Arguments

  • const char * name - The child number.

Return value

The result.

Ptr<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(const char * name)

Checks if the xml has specified child.

Arguments

  • const char * name - Name of the xml child.

Return value

The result.

const char * getChildData(const char * name)

Allows to get the data from the Xml child node.

Arguments

  • const char * name - Name of the child node.

Return value

The value of the child node.

void setData(const char * data)

Sets a xml data.

Arguments

  • const char * data - The xml data.

const char * getData()

Gets a xml data.

Return value

The result.

int setDMat4Arg(const char * name, const Math::dmat4 & value)

Sets a value of a given dmat4 argument.

Arguments

  • const char * name - Name of an argument.
  • const Math::dmat4 & value - Value of an argument.

Return value

Always 1.

Math::dmat4 getDMat4Arg(const char * name)

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

Arguments

  • const char * name - Name of a target argument.

Return value

Argument value.

void setDMat4Data(const Math::dmat4 & data)

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

Arguments

  • const Math::dmat4 & data - Content to set.

Math::dmat4 getDMat4Data()

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

Return value

Data stored in the node.

int setDoubleArg(const char * name, double value)

Sets a value of a given double argument.

Arguments

  • const char * name - Name of an argument.
  • double value - Value of an argument.

Return value

Always 1.

double getDoubleArg(const char * name, double value)

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

Arguments

  • const char * name - Name of a target argument.
  • double value - Default value of the argument.

Return value

Argument value.

double getDoubleArg(const char * name)

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

Arguments

  • const char * name - Name of a target argument.

Return value

Argument value.

int setDoubleArrayArg(const char * name, double[] src)

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

Arguments

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

Return value

Always 1.

int getDoubleArrayArg(out double[] name)

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

Arguments

  • 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 setDVec3Arg(const char * name, const Math::dvec3 & value)

Sets a value of a given dvec3 argument.

Arguments

  • const char * name - Name of an argument.
  • const Math::dvec3 & value - Value of an argument.

Return value

Always 1.

Math::dvec3 getDVec3Arg(const char * name)

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

Arguments

  • const char * name - Name of a target argument.

Return value

Argument value.

void setDVec3Data(const Math::dvec3 & data)

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

Arguments

  • const Math::dvec3 & data - Content to set.

Math::dvec3 getDVec3Data()

Returns a dvec3 interpretation of data stored in the node.

Return value

Data stored in the node.

int setDVec4Arg(const char * name, const Math::dvec4 & value)

Sets a value of a given dvec4 argument.

Arguments

  • const char * name - Name of an argument.
  • const Math::dvec4 & value - Value of an argument.

Return value

Always 1.

Math::dvec4 getDVec4Arg(const char * name)

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

Arguments

  • const char * name - Name of a target argument.

Return value

Argument value.

void setDVec4Data(const Math::dvec4 & data)

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

Arguments

  • const Math::dvec4 & data - Content to set.

Math::dvec4 getDVec4Data()

Returns a dvec4 interpretation of data stored in the node.

Return value

Data stored in the node.

int setFloatArg(const char * name, float value)

Sets a value of a given float argument.

Arguments

  • const char * name - Name of an argument.
  • float value - Value of an argument.

Return value

Always 1.

float getFloatArg(const char * name, float value)

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

Arguments

  • const char * name - Name of a target argument.
  • float value - Default value of the argument.

Return value

Argument value.

float getFloatArg(const char * name)

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

Arguments

  • const char * name - Name of a target argument.

Return value

Argument value.

int setFloatArrayArg(const char * name, float[] src)

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

Arguments

  • const char * name - Name of an argument.
  • float[] src

Return value

Always 1.

int getFloatArrayArg(const char * name, out float[] dest)

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

Arguments

  • const char * 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(const char * path = 0)

Converts an xml tree into the formatted string.

Arguments

  • const char * path - Path to xml sub-tree.

Return value

The result.

int setIntArg(const char * name, int value, int radix = 10)

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

Arguments

  • const char * name - The xml argument name.
  • int value - The xml argument value.
  • int radix - Radix to use when setting a value.

Return value

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

int getIntArg(const char * name)

Gets an integer xml argument.

Arguments

  • const char * name - The xml argument name.

Return value

The result.

int getIntArg(const char * name, int value)

Gets an integer xml argument.

Arguments

  • const char * name - Name of a target argument.
  • int value - Default value of the argument.

Return value

The result.

int setIntArrayArg(const char * name, const Vector< 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

  • const char * name - Name of an argument.
  • const Vector< 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(const char * name)

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

Arguments

  • const char * name - Name of a target argument.

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 xml data in a given number notation. By default, the decimal number notation is used.

Arguments

  • int value - The xml argument value.
  • int radix - Radix to use when setting a value.

Return value

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

int getIntData()

Gets an integer xml data.

Return value

The result.

int setIVec3Arg(const char * name, const Math::ivec3 & value)

Sets a value of a given ivec3 argument.

Arguments

  • const char * name - Name of an argument.
  • const Math::ivec3 & value - Value of an argument.

Return value

Always 1.

Math::ivec3 getIVec3Arg(const char * name)

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

Arguments

  • const char * name - Name of a target argument.

Return value

Argument value.

void setIVec3Data(const Math::ivec3 & data)

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

Arguments

  • const Math::ivec3 & data - Content to set.

Math::ivec3 getIVec3Data()

Returns a ivec3 interpretation of data stored in the node.

Return value

Data stored in the node.

int setIVec4Arg(const char * name, const Math::ivec4 & value)

Sets a value of a given ivec4 argument.

Arguments

  • const char * name - Name of an argument.
  • const Math::ivec4 & value - Value of an argument.

Return value

Always 1.

Math::ivec4 getIVec4Arg(const char * name)

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

Arguments

  • const char * name - Name of a target argument.

Return value

Argument value.

void setIVec4Data(const Math::ivec4 & data)

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

Arguments

  • const Math::ivec4 & data - Content to set.

Math::ivec4 getIVec4Data()

Returns a ivec4 interpretation of data stored in the node.

Return value

Data stored in the node.

int setMat4Arg(const char * name, const Math::mat4 & value)

Sets a value of a given mat4 argument.

Arguments

  • const char * name - Name of an argument.
  • const Math::mat4 & value - Value of an argument.

Return value

Always 1.

Math::mat4 getMat4Arg(const char * name)

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

Arguments

  • const char * name - Name of a target argument.

Return value

Argument value.

void setMat4Data(const Math::mat4 & data)

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

Arguments

  • const Math::mat4 & data - Content to set.

Math::mat4 getMat4Data()

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

Return value

Data stored in the node.

void setName(const char * name)

Sets the xml node name.

Arguments

  • const char * name - Name of the xml node.

const char * getName()

Returns the xml node name.

Return value

The result.

int getNumArgs()

Returns the number of xml arguments.

Return value

The result.

int getNumChildren()

Returns the number of xml children.

Return value

The result.

int isOwner()

Ptr<Xml> getParent()

Parent node of the current XML node.Returns the parent of the current XML node.

int setQuatArg(const char * name, const Math::quat & value)

Sets a value of a given quat argument.

Arguments

  • const char * name - Name of an argument.
  • const Math::quat & value - Value of an argument.

Return value

Always 1.

Math::quat getQuatArg(const char * name)

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

Arguments

  • const char * name - Name of a target argument.

Return value

Argument value.

void setQuatData(const Math::quat & data)

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

Arguments

  • const Math::quat & data - Content to set.

Math::quat getQuatData()

Returns a quaternion interpretation of data stored in the node.

Return value

Data stored in the node.

int setRawData(const char * data)

Sets a xml raw data.

Arguments

  • const char * data - The xml raw data.

Return value

Returns 1 if the operation was a success; otherwise, 0 is returned.

int setStringArrayArg(const char * name, const Vector< String > & src)

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

Arguments

  • const char * name - Name of an argument.
  • const Vector< String > & src - An array of strings.

Return value

Always 1.

int getStringArrayArg(const char * name, Vector< String > & dest)

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

Arguments

  • const char * name - Name of the string.
  • Vector< String > & dest - Reference to a vector.

Return value

1 if dest contains anything; otherwise, 0.

int setStringArrayData(const Vector< String > & src)

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

Arguments

  • const Vector< String > & src - Reference to a vector.

Return value

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

int getStringArrayData(Vector< String > & dest)

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

Arguments

  • Vector< String > & dest - Reference to a vector.

Return value

1 if dest contains anything; otherwise, 0.

String getSubTree(const char * path = 0)

Converts an xml tree into the string.

Arguments

  • const char * path - Path to xml sub-tree.

Return value

The result.

int setVec3Arg(const char * name, const Math::vec3 & value)

Sets a value of a given vec3 argument.

Arguments

  • const char * name - Name of an argument.
  • const Math::vec3 & value - Value of an argument.

Return value

Always 1.

Math::vec3 getVec3Arg(const char * name)

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

Arguments

  • const char * name - Name of a target argument.

Return value

Argument value.

void setVec3Data(const Math::vec3 & data)

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

Arguments

  • const Math::vec3 & data - Content to set.

Math::vec3 getVec3Data()

Returns a vec3 interpretation of data stored in the node.

Return value

Data stored in the node.

int setVec4Arg(const char * name, const Math::vec4 & value)

Sets a value of a given vec4 argument.

Arguments

  • const char * name - Name of an argument.
  • const Math::vec4 & value - Value of an argument.

Return value

Always 1.

Math::vec4 getVec4Arg(const char * name)

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

Arguments

  • const char * name - Name of a target argument.

Return value

Argument value.

void setVec4Data(const Math::vec4 & data)

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

Arguments

  • const Math::vec4 & data - Content to set.

Math::vec4 getVec4Data()

Returns a vec4 interpretation of data stored in the node.

Return value

Data stored in the node.

int setXmlData(const char * data)

Sets a xml xml data.

Arguments

  • const char * data - The xml xml data.

Return value

Returns 1 if the operation was a success; otherwise, 0 is returned.

Ptr<Xml> addChild(const char * name, const char * args = 0)

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

Arguments

  • const char * name - Name of the XML node.
  • const char * 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.

Ptr<Xml> addChild(const Ptr<Xml> & xml)

Appends a new xml child.

Arguments

  • const Ptr<Xml> & xml - Xml sub-tree smart pointer.

Return value

Created xml node.

void clear()

Clears the xml tree.

void clearChildren()

Clears all children of the current xml node.

void clearUnusedData()

Clears the unused nodes and arguments.

void copy(const Ptr<Xml> & source)

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

Arguments

  • const Ptr<Xml> & source - Source Xml node.

String decode(const char * arg1)

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

Arguments

  • const char * arg1 - Data to decode.

Return value

Decoded string.

String encode(const char * arg1)

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

Arguments

  • const char * arg1 - Data to encode.

Return value

Encoded string.

Ptr<Xml> find(const char * path)

Finds an xml sub-tree.

Arguments

  • const char * path - Path to the xml sub-tree.

Return value

The result.

int findArg(const char * name)

Finds a xml argument by its name.

Arguments

  • const char * name - Xml argument name.

Return value

Xml argument number.

int findChild(const char * name)

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

Arguments

  • const char * name - Name of the Xml node child.

Return value

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

void grab()

int load(const char * name)

Loads the xml tree from the specified file.

Arguments

  • const char * name - File name.

Return value

Returns 1 if the operation was a success; otherwise, 0 is returned.

int parse(const char * src)

Parses string and creates the xml tree.

Arguments

  • const char * src - String pointer.

Return value

Returns 1 if the operation was a success; otherwise, 0 is returned.

void printUnusedData(const char * name)

Prints the unused nodes and arguments.

Arguments

  • const char * name - Name of the xml file.

void release()

int removeArg(const char * name)

Deletes an xml argument.

Arguments

  • const char * name - The xml argument name.

Return value

1 if the argument is deleted successfully; otherwise, 0.

Ptr<Xml> removeChild(const Ptr<Xml> & xml)

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

Arguments

  • const Ptr<Xml> & xml - Xml sub-tree smart pointer.

Return value

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

int save(const char * name, int binary = 0)

Saves the xml tree into the specified file.

Arguments

  • const char * name - File name.
  • int binary - Binary xml format.

Return value

Returns 1 if the operation was a success; otherwise, 0 is returned.

String symbols(const char * arg1)

Replaces ampersand characters with character entity references.

Arguments

  • const char * arg1 - to encode.

Return value

String which contains replaced ampersand characters with character entity references.
Last update: 2017-07-03
Build: ()