COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
Public Member Functions | Public Attributes | Private Member Functions | List of all members
XmlNode Class Reference

#include <XmlNode.hpp>

Inherited by XmlDoc.

Public Member Functions

 XmlNode ()
 
 XmlNode (rapidxml::xml_node< char > *impl)
 
 ~XmlNode ()
 
XmlNode add_node (const std::string &name, const std::string &value=std::string()) const
 
void set_attribute (const std::string &name, const std::string &value)
 
std::string attribute_value (const std::string &name) const
 
void set_name (const char *name)
 
void set_value (const char *value)
 
bool is_valid () const
 
void print (Uint nesting=0) const
 
void deep_copy (XmlNode &out) const
 

Public Attributes

rapidxml::xml_node< char > * content
 Pointer to the underlying XML implementation. More...
 

Private Member Functions

void deep_copy_names_values (const XmlNode &in, XmlNode &out) const
 

Detailed Description

Represents a XML node. This class uses the Pimpl idiom. Each object is only a wrapper for an object of an underlying XML implementation. This class provides functions that ease some XML manipulation, like adding a node or adding/modifying an attribute, that need memory allocation.
A XmlNode can be easily written to a file, converted to a string or printed to screen (not in XML format) using COOLFluiD logging facility.

Author
Quentin Gasper

Definition at line 44 of file XmlNode.hpp.

Constructor & Destructor Documentation

XmlNode ( )

Default constructor. Builds an invalid node.

Definition at line 22 of file XmlNode.cpp.

XmlNode ( rapidxml::xml_node< char > *  impl)

Builds a node from an existing one.

Parameters
implThe node.
~XmlNode ( )

Destructor. The node is removed from its parent and all its child nodes and attributes are removed.

Definition at line 26 of file XmlNode.cpp.

Member Function Documentation

XmlNode add_node ( const std::string &  name,
const std::string &  value = std::string() 
) const

Creates and add a node to this node with a value, if specified.

Parameters
nameThe name of the new name.
valueThe value of the new node. If empty, this parameter is ignored.
Returns
Returns the new node.

Definition at line 38 of file XmlNode.cpp.

std::string attribute_value ( const std::string &  name) const

Gets the value of an attribute.

Parameters
nameAttribute name.
Returns
Returns the value of the attribute or an empty string of the attribute was not found.

Definition at line 75 of file XmlNode.cpp.

void deep_copy ( XmlNode out) const

Deep copies this node into another with all the memory allocated in the second.

Parameters
outThe destination node.

Definition at line 109 of file XmlNode.cpp.

void deep_copy_names_values ( const XmlNode in,
XmlNode out 
) const
private

Helper function that copy the names and values to the memory pool of the out node

Precondition
Assumes that the nodes have been cloned before.
Assumes that the destination node is valid.
Parameters
inThe source node.
outThe destination node.

Definition at line 123 of file XmlNode.cpp.

bool is_valid ( ) const

Checks if the this node is valid. A node is valid if the its internal pointer to the underlying XML implementation is valid.

Returns
Returns true if the node is valid, otherwise returns false.

Definition at line 102 of file XmlNode.cpp.

void print ( Uint  nesting = 0) const

Prints the provided XML node to the logging facility.

Parameters
nodeThe node to print.
nestingIndentation between a node and its attributes or sub-nodes.
Note
The node is not printed in XML format.

Definition at line 152 of file XmlNode.cpp.

void set_attribute ( const std::string &  name,
const std::string &  value 
)

Sets an attribute of this node to a specified value. If an attribute with this name already exists, it is modified. If not, it is created.

Parameters
nameThe name of the new name.
valueThe value of the new node.
Returns
Returns the new attribute.

Definition at line 54 of file XmlNode.cpp.

void set_name ( const char *  name)

Sets a new name.

Parameters
nameThe new name

Definition at line 84 of file XmlNode.cpp.

void set_value ( const char *  value)

Sets a new value.

Parameters
nameThe new name

Definition at line 93 of file XmlNode.cpp.

Member Data Documentation

rapidxml::xml_node<char>* content

Pointer to the underlying XML implementation.

Definition at line 50 of file XmlNode.hpp.


The documentation for this class was generated from the following files:
Send comments to:
COOLFluiD Web Admin