libCZI
Reading and Writing CZI documents made easy
Loading...
Searching...
No Matches
libCZI::IXmlNodeRead Class Referenceabstract

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

#include <libCZI_Metadata.h>

Inheritance diagram for libCZI::IXmlNodeRead:
libCZI::ICziMetadata libCZI::IXmlNodeRw

Public Member Functions

virtual std::wstring Name () const =0
 
virtual bool TryGetAttribute (const wchar_t *attributeName, std::wstring *attribValue) const =0
 
virtual void EnumAttributes (const std::function< bool(const std::wstring &attribName, const std::wstring &attribValue)> &enumFunc) const =0
 
virtual bool TryGetValue (std::wstring *value) const =0
 
virtual std::shared_ptr< IXmlNodeReadGetChildNodeReadonly (const char *path)=0
 
virtual void EnumChildren (const std::function< bool(std::shared_ptr< IXmlNodeRead >)> &enumChildren)=0
 
bool TryGetValueAsDouble (double *p)
 
bool TryGetValueAsFloat (float *p)
 
bool TryGetValueAsInt32 (std::int32_t *p)
 
bool TryGetValueAsUInt32 (std::uint32_t *p)
 
bool TryGetValueAsInt64 (std::int64_t *p)
 
bool TryGetValueAsUInt64 (std::uint64_t *p)
 
bool TryGetValueAsBool (bool *p)
 

Detailed Description

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

Member Function Documentation

◆ EnumAttributes()

virtual void libCZI::IXmlNodeRead::EnumAttributes ( const std::function< bool(const std::wstring &attribName, const std::wstring &attribValue)> &  enumFunc) const
pure virtual

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

Parameters
enumFuncThe enumeration function. If the function returns false, the enumeration will be cancelled immediately.

◆ EnumChildren()

virtual void libCZI::IXmlNodeRead::EnumChildren ( const std::function< bool(std::shared_ptr< IXmlNodeRead >)> &  enumChildren)
pure virtual

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

Parameters
enumChildrenThe function to be called with the children nodes.

◆ GetChildNodeReadonly()

virtual std::shared_ptr< IXmlNodeRead > libCZI::IXmlNodeRead::GetChildNodeReadonly ( const char *  path)
pure virtual

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
pathThe path (in UTF8-encoding).
Returns
Either the requested node if it exists or nullptr.

◆ Name()

virtual std::wstring libCZI::IXmlNodeRead::Name ( ) const
pure virtual

Gets the name of the node.

Returns
The name of the node.

◆ TryGetAttribute()

virtual bool libCZI::IXmlNodeRead::TryGetAttribute ( const wchar_t *  attributeName,
std::wstring *  attribValue 
) const
pure virtual

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
attributeNameName of the attribute.
[out]attribValueIf non-null, the attribute value will be put here (if the attribute exists).
Returns
True if it succeeds, false if it fails.

◆ TryGetValue()

virtual bool libCZI::IXmlNodeRead::TryGetValue ( std::wstring *  value) const
pure virtual

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

Parameters
[out]valueIf non-null, the value of the XML-node will be put here (if successful).
Returns
True if it succeeds, false if it fails.

◆ TryGetValueAsBool()

bool libCZI::IXmlNodeRead::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
[in,out]pIf non-null, a pointer to a bool to store the result in.
Returns
True if it succeeds, false if it fails.

◆ TryGetValueAsDouble()

bool libCZI::IXmlNodeRead::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
[in,out]pIf non-null, a pointer to a double to store the result in.
Returns
True if it succeeds, false if it fails.

◆ TryGetValueAsFloat()

bool libCZI::IXmlNodeRead::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
[in,out]pIf non-null, a pointer to a float to store the result in.
Returns
True if it succeeds, false if it fails.

◆ TryGetValueAsInt32()

bool libCZI::IXmlNodeRead::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
[in,out]pIf non-null, a pointer to an integer to store the result in.
Returns
True if it succeeds, false if it fails.

◆ TryGetValueAsInt64()

bool libCZI::IXmlNodeRead::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
[in,out]pIf non-null, a pointer to a long integer (64-bit) to store the result in.
Returns
True if it succeeds, false if it fails.

◆ TryGetValueAsUInt32()

bool libCZI::IXmlNodeRead::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
[in,out]pIf non-null, a pointer to an unsigned integer to store the result in.
Returns
True if it succeeds, false if it fails.

◆ TryGetValueAsUInt64()

bool libCZI::IXmlNodeRead::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
[in,out]pIf 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.

The documentation for this class was generated from the following file: