Class IXmlNodeRead#

Inheritance Relationships#

Derived Types#

Class Documentation#

class IXmlNodeRead#

This interface provides read-only access to an XML-node.

Subclassed by libCZI::ICziMetadata, libCZI::IXmlNodeRw

Public Functions

virtual std::wstring Name() const = 0#

Gets the name of the node.

Returns:

The name of the node.

virtual bool TryGetAttribute(const wchar_t *attributeName, std::wstring *attribValue) const = 0#

Attempts to get the attribute with the name specified by “attributeName”. If it exists, the value is stored in “attribValue” (if it is non-null) and the return value is true. Otherwise, the return value is false.

Parameters:
  • attributeName – Name of the attribute.

  • attribValue[out] If non-null, the attribute value will be put here (if the attribute exists).

Returns:

True if it succeeds, false if it fails.

virtual void EnumAttributes(const std::function<bool(const std::wstring &attribName, const std::wstring &attribValue)> &enumFunc) const = 0#

Enumerate the attributes in the node. The attribute-name and their respective value will be passed to the specified functor.

Parameters:

enumFunc – The enumeration function. If the function returns false, the enumeration will be cancelled immediately.

virtual bool TryGetValue(std::wstring *value) const = 0#

Attempts to get value of the XML-node. If the specified pointer “value” is non-null, the value will be put there.

Parameters:

value[out] If non-null, the value of the XML-node will be put here (if successful).

Returns:

True if it succeeds, false if it fails.

virtual std::shared_ptr<IXmlNodeRead> GetChildNodeReadonly(const char *path) = 0#

Gets a child node for the specified path/attribute specification if it exists. Otherwise, a nullptr is returned. The path is specified as node-names separated by slashes. A path “A/B/C” selects 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:

Either the requested node if it exists or nullptr.

virtual void EnumChildren(const std::function<bool(std::shared_ptr<IXmlNodeRead>)> &enumChildren) = 0#

Enumerate the children of the node. The functor will be called until there are no more children or if the function return false.

Parameters:

enumChildren – The function to be called with the children nodes.

bool TryGetValueAsDouble(double *p)#

Attempts to get value of this node as a double. If the text does not parse correctly (or is empty), we return false.

Parameters:

p[inout] If non-null, a pointer to a double to store the result in.

Returns:

True if it succeeds, false if it fails.

bool TryGetValueAsFloat(float *p)#

Attempts to get value of this node as a float. If the text does not parse correctly (or is empty), we return false.

Parameters:

p[inout] If non-null, a pointer to a float to store the result in.

Returns:

True if it succeeds, false if it fails.

bool TryGetValueAsInt32(std::int32_t *p)#

Attempts to get value of this node as an integer (32-bit). If the text does not parse correctly (or is empty), we return false.

Parameters:

p[inout] If non-null, a pointer to an integer to store the result in.

Returns:

True if it succeeds, false if it fails.

bool TryGetValueAsUInt32(std::uint32_t *p)#

Attempts to get value of this node as an unsigned integer (32-bit). If the text does not parse correctly (or is empty), we return false.

Parameters:

p[inout] If non-null, a pointer to an unsigned integer to store the result in.

Returns:

True if it succeeds, false if it fails.

bool TryGetValueAsInt64(std::int64_t *p)#

Attempts to get value of this node as a long integer (64-bit). If the text does not parse correctly (or is empty), we return false.

Parameters:

p[inout] If non-null, a pointer to a long integer (64-bit) to store the result in.

Returns:

True if it succeeds, false if it fails.

bool TryGetValueAsUInt64(std::uint64_t *p)#

Attempts to get value of this node as an unsigned long integer (64-bit). If the text does not parse correctly (or is empty), we return false.

Parameters:

p[inout] If non-null, a pointer to an unsigned long integer (64-bit) to store the result in.

Returns:

True if it succeeds, false if it fails.

bool TryGetValueAsBool(bool *p)#

Attempts to get value of this node as an unsigned long integer (64-bit). Valid values for true are: “true”, “yes” or “1”; valid values for false are “false”, “no” or “0” (case insensitive comparison).

Parameters:

p[inout] If non-null, a pointer to a bool to store the result in.

Returns:

True if it succeeds, false if it fails.

virtual ~IXmlNodeRead() = default#