libCZI
Reading and Writing CZI documents made easy
libCZI::IXmlNodeWrite Class Referenceabstract

This interface provides write access to an XML-node. More...

#include <libCZI_Metadata.h>

Inheritance diagram for libCZI::IXmlNodeWrite:
libCZI::IXmlNodeRw

Public Member Functions

virtual std::shared_ptr< IXmlNodeRwGetOrCreateChildNode (const char *path)=0
 
virtual std::shared_ptr< IXmlNodeRwGetChildNode (const char *path)=0
 
virtual std::shared_ptr< IXmlNodeRwAppendChildNode (const char *name)=0
 
virtual void SetAttribute (const char *name, const char *value)=0
 
virtual void SetAttribute (const wchar_t *name, const wchar_t *value)=0
 
virtual void SetValue (const char *str)=0
 
virtual void SetValue (const wchar_t *str)=0
 
virtual void SetValueI32 (int value)=0
 
virtual void SetValueUI32 (unsigned int value)=0
 
virtual void SetValueDbl (double value)=0
 
virtual void SetValueFlt (float value)=0
 
virtual void SetValueBool (bool value)=0
 
virtual void SetValueI64 (long long value)=0
 
virtual void SetValueUI64 (unsigned long long value)=0
 
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
 
virtual bool RemoveAttribute (const char *name)=0
 
void SetValue (const std::string &str)
 
void SetValue (const std::wstring &str)
 
std::shared_ptr< IXmlNodeRwGetOrCreateChildNode (const std::string &path)
 
std::shared_ptr< IXmlNodeRwGetChildNode (const std::string &path)
 

Detailed Description

This interface provides write access to an XML-node.

Member Function Documentation

◆ AppendChildNode()

virtual std::shared_ptr<IXmlNodeRw> libCZI::IXmlNodeWrite::AppendChildNode ( const char *  name)
pure virtual

Appends a child node with the specified name.

Parameters
nameThe name of the node to add.
Returns
The newly added node.

◆ GetChildNode() [1/2]

virtual std::shared_ptr<IXmlNodeRw> libCZI::IXmlNodeWrite::GetChildNode ( const char *  path)
pure virtual

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
pathThe path (in UTF8-encoding).
Returns
The existing node conforming to the path if it exists, null otherwise.

◆ GetChildNode() [2/2]

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

Gets a child node for the specified path.

Parameters
pathPath of the childnode (in UTF8-encoding).
Returns
The child node.

◆ GetOrCreateChildNode() [1/2]

virtual std::shared_ptr<IXmlNodeRw> libCZI::IXmlNodeWrite::GetOrCreateChildNode ( const char *  path)
pure virtual

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
pathThe path (in UTF8-encoding).
Returns
Either an existing node or a newly created one.

◆ GetOrCreateChildNode() [2/2]

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

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
pathThe path.
Returns
Either an existing node or a newly created one.

◆ RemoveAttribute()

virtual bool libCZI::IXmlNodeWrite::RemoveAttribute ( const char *  name)
pure virtual

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

◆ RemoveChild()

virtual bool libCZI::IXmlNodeWrite::RemoveChild ( const char *  name)
pure virtual

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

◆ SetAttribute() [1/2]

virtual void libCZI::IXmlNodeWrite::SetAttribute ( const char *  name,
const char *  value 
)
pure virtual

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

Parameters
nameThe name of the attribute (as UTF8-encoded string).
valueThe value (as UTF8-encoded string).

◆ SetAttribute() [2/2]

virtual void libCZI::IXmlNodeWrite::SetAttribute ( const wchar_t *  name,
const wchar_t *  value 
)
pure virtual

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

Parameters
nameThe name of the attribute.
valueThe value.

◆ SetValue() [1/4]

virtual void libCZI::IXmlNodeWrite::SetValue ( const char *  str)
pure virtual

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

Parameters
strThe UTF8-encoded string.

◆ SetValue() [2/4]

void libCZI::IXmlNodeWrite::SetValue ( const std::string &  str)
inline

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

Parameters
strThe UTF8-encoded string.

◆ SetValue() [3/4]

void libCZI::IXmlNodeWrite::SetValue ( const std::wstring &  str)
inline

Sets the node value to the specified string.

Parameters
strThe string.

◆ SetValue() [4/4]

virtual void libCZI::IXmlNodeWrite::SetValue ( const wchar_t *  str)
pure virtual

Sets the node value to the specified string.

Parameters
strThe string.

◆ SetValueBool()

virtual void libCZI::IXmlNodeWrite::SetValueBool ( bool  value)
pure virtual

Sets value of the node with the specified boolean.

Parameters
valueThe boolean to write into the node.

◆ SetValueDbl()

virtual void libCZI::IXmlNodeWrite::SetValueDbl ( double  value)
pure virtual

Sets value of the node with the specified double.

Parameters
valueThe double to write into the node.

◆ SetValueFlt()

virtual void libCZI::IXmlNodeWrite::SetValueFlt ( float  value)
pure virtual

Sets value of the node with the specified float.

Parameters
valueThe float to write into the node.

◆ SetValueI32()

virtual void libCZI::IXmlNodeWrite::SetValueI32 ( int  value)
pure virtual

Sets value of the node with the specified integer.

Parameters
valueThe integer to write into the node.

◆ SetValueI64()

virtual void libCZI::IXmlNodeWrite::SetValueI64 ( long long  value)
pure virtual

Sets value of the node with the specified long integer.

Parameters
valueThe long integer to write into the node.

◆ SetValueUI32()

virtual void libCZI::IXmlNodeWrite::SetValueUI32 ( unsigned int  value)
pure virtual

Sets value of the node with the specified unsigned integer.

Parameters
valueThe unsigned integer to write into the node.

◆ SetValueUI64()

virtual void libCZI::IXmlNodeWrite::SetValueUI64 ( unsigned long long  value)
pure virtual

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

Parameters
valueThe unsigned long integer to write into the node.

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