Class IXmlNodeWrite#

Inheritance Relationships#

Derived Type#

Class Documentation#

class IXmlNodeWrite#

This interface provides write access to an XML-node.

Subclassed by libCZI::IXmlNodeRw

Public Functions

virtual std::shared_ptr<IXmlNodeRw> GetOrCreateChildNode(const char *path) = 0#

Gets or create a child node. The path is specified as node-names separated by slashes. A path “A/B/C” selects (or creates) a node-structure like this

<A>
  <B>
    <C/>
  </B>
</A>
Attributes can be specified with a node, in the form ‘NodeName[attr1=abc,attr2=xyz]’. This will search for nodes with the specified attributes, and if not found, create one. In this example “A/B[Id=ab,Name=xy]/C” we will get
<A>
  <B Id="ab" Name="xy">
    <C/>
  </B>
</A>

Parameters:

path – The path (in UTF8-encoding).

Returns:

Either an existing node or a newly created one.

virtual std::shared_ptr<IXmlNodeRw> GetChildNode(const char *path) = 0#

Gets an existing child node. The path is specified as node-names separated by slashes. A path “A/B/C” selects (or creates) a node-structure like this

<A>
  <B>
    <C/>
  </B>
</A>
Attributes can be specified with a node, in the form ‘NodeName[attr1=abc,attr2=xyz]’. This will search for nodes with the specified attributes, and if not found, create one. In this example “A/B[Id=ab,Name=xy]/C” we will get
<A>
  <B Id="ab" Name="xy">
    <C/>
  </B>
</A>
It is also possible to specify a number inside the square brackets, which indicates that the n-th element is to be selected. This index is zero-based. In this example
<A>
  <B Id="ab" Name="xy">
    <C Id="first"></C>
    <C Id="second"></C>
    <C Id="third"></C>
  </B>
</A>
the path “A/B/C[1]” will select the second node of name ‘C’. If the path does not exist, then a nullptr is returned. This method may throw an exception if the path is not well-formed and syntactically valid.

Parameters:

path – The path (in UTF8-encoding).

Returns:

The existing node conforming to the path if it exists, null otherwise.

virtual std::shared_ptr<IXmlNodeRw> AppendChildNode(const char *name) = 0#

Appends a child node with the specified name.

Parameters:

name – The name of the node to add.

Returns:

The newly added node.

virtual void SetAttribute(const char *name, const char *value) = 0#

Sets the attribute with the specified name to the specified value.

Parameters:
  • name – The name of the attribute (as UTF8-encoded string).

  • value – The value (as UTF8-encoded string).

virtual void SetAttribute(const wchar_t *name, const wchar_t *value) = 0#

Sets the attribute with the specified name to the specified value.

Parameters:
  • name – The name of the attribute.

  • value – The value.

virtual void SetValue(const char *str) = 0#

Sets the node value - which is specified as an UTF8-string.

Parameters:

str – The UTF8-encoded string.

virtual void SetValue(const wchar_t *str) = 0#

Sets the node value to the specified string.

Parameters:

str – The string.

virtual void SetValueI32(int value) = 0#

Sets value of the node with the specified integer.

Parameters:

value – The integer to write into the node.

virtual void SetValueUI32(unsigned int value) = 0#

Sets value of the node with the specified unsigned integer.

Parameters:

value – The unsigned integer to write into the node.

virtual void SetValueDbl(double value) = 0#

Sets value of the node with the specified double.

Parameters:

value – The double to write into the node.

virtual void SetValueFlt(float value) = 0#

Sets value of the node with the specified float.

Parameters:

value – The float to write into the node.

virtual void SetValueBool(bool value) = 0#

Sets value of the node with the specified boolean.

Parameters:

value – The boolean to write into the node.

virtual void SetValueI64(long long value) = 0#

Sets value of the node with the specified long integer.

Parameters:

value – The long integer to write into the node.

virtual void SetValueUI64(unsigned long long value) = 0#

Sets value of the node with the specified unsigned long integer.

Parameters:

value – The unsigned long integer to write into the node.

virtual void RemoveChildren() = 0#

Removes all children of this node.

virtual void RemoveAttributes() = 0#

Removes all attributes of this node.

virtual bool RemoveChild(const char *name) = 0#

Removes the child node with the specified name. In case that there a multiple children with the specified name, then only the first is removed.

Parameters:

name – The name of the node to be removed.

Returns:

True if the node was found and successfully removed; false otherwise (i.e. if it did not exist).

virtual bool RemoveAttribute(const char *name) = 0#

Removes the attribute with the specified name. In case that there a multiple attributes with the specified name, then only the first is removed.

Parameters:

name – The name of the attribute to be removed.

Returns:

True if the attribute was found and successfully removed; false otherwise (i.e. if it did not exist).

virtual ~IXmlNodeWrite() = default#
inline void SetValue(const std::string &str)#

Sets the node value - which is specified as an UTF8-string.

Parameters:

str – The UTF8-encoded string.

inline void SetValue(const std::wstring &str)#

Sets the node value to the specified string.

Parameters:

str – The string.

inline std::shared_ptr<IXmlNodeRw> GetOrCreateChildNode(const std::string &path)#

Gets or create a child node. The path is specified as node-names separated by slashes. At path “A/B/C” selects (or creates) a node-structure like this

<A>
  <B>
    <C/>
  </B>
</A>
Attributes can be specified with a node, in the form ‘NodeName[attr1=abc,attr2=xyz]’. This will search for nodes with the specified attributes, and if not found, create one. In this example “A/B[Id=ab,Name=xy]/C” we will get
<A>
  <B Id="ab" Name="xy">
    <C/>
  </B>
</A>

Parameters:

path – The path.

Returns:

Either an existing node or a newly created one.

inline std::shared_ptr<IXmlNodeRw> GetChildNode(const std::string &path)#

Gets a child node for the specified path.

Parameters:

path – Path of the childnode (in UTF8-encoding).

Returns:

The child node.