hydrogen 1.1.1
XMLNode Class Reference

XMLNode is a subclass of QDomNode with read and write values methods. More...

#include <Xml.h>

Inheritance diagram for XMLNode:
Object

Public Member Functions

 XMLNode ()
 basic constructor More...
 
 XMLNode (QDomNode node)
 to wrap a QDomNode More...
 
XMLNode createNode (const QString &name)
 create a new XMLNode that has to be appended into de XMLDoc More...
 
int read_int (const QString &node, int default_value, bool inexistent_ok=true, bool empty_ok=true)
 reads an integer stored into a child node More...
 
bool read_bool (const QString &node, bool default_value, bool inexistent_ok=true, bool empty_ok=true)
 reads a boolean stored into a child node More...
 
float read_float (const QString &node, float default_value, bool inexistent_ok=true, bool empty_ok=true)
 reads a float stored into a child node More...
 
QString read_string (const QString &node, const QString &default_value, bool inexistent_ok=true, bool empty_ok=true)
 reads a string stored into a child node More...
 
QString read_attribute (const QString &attribute, const QString &default_value, bool inexistent_ok, bool empty_ok)
 reads an attribute from the node More...
 
QString read_text (bool empty_ok)
 reads the text (content) from the node More...
 
void write_int (const QString &node, const int value)
 write an integer into a child node More...
 
void write_bool (const QString &node, const bool value)
 write a boolean into a child node More...
 
void write_float (const QString &node, const float value)
 write a float into a child node More...
 
void write_string (const QString &node, const QString &value)
 write a string into a child node More...
 
void write_attribute (const QString &attribute, const QString &value)
 write a string as an attribute of the node More...
 
- Public Member Functions inherited from Object
 ~Object ()
 destructor More...
 
 Object (const Object &obj)
 copy constructor More...
 
 Object (const char *class_name)
 constructor More...
 
const char * class_name () const
 return the class name More...
 
virtual QString toQString (const QString &sPrefix, bool bShort=true) const
 Formatted string version for debugging purposes. More...
 
void Print (bool bShort=true) const
 Prints content of toQString() via DEBUGLOG. More...
 

Private Member Functions

QString read_child_node (const QString &node, bool inexistent_ok, bool empty_ok)
 reads a string stored into a child node More...
 
void write_child_node (const QString &node, const QString &text)
 write a string into a child node More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Object
static void set_count (bool flag)
 enable/disable class instances counting More...
 
static bool count_active ()
 return true if class instances counting is enabled More...
 
static unsigned objects_count ()
 return the number of objects More...
 
static void write_objects_map_to (std::ostream &out)
 output the full objects map to a given ostream More...
 
static void write_objects_map_to_cerr ()
 output objects map to stderr More...
 
static int bootstrap (Logger *logger, bool count=false)
 must be called before any Object instantiation ! More...
 
static Loggerlogger ()
 return the logger instance More...
 
- Static Public Attributes inherited from Object
static QString sPrintIndention = " "
 String used to format the debugging string output of some core classes. More...
 
- Static Protected Attributes inherited from Object
static Logger__logger = nullptr
 logger instance pointer More...
 

Detailed Description

XMLNode is a subclass of QDomNode with read and write values methods.

Constructor & Destructor Documentation

◆ XMLNode() [1/2]

XMLNode ( )

basic constructor

◆ XMLNode() [2/2]

XMLNode ( QDomNode  node)

to wrap a QDomNode

Member Function Documentation

◆ createNode()

XMLNode createNode ( const QString &  name)

create a new XMLNode that has to be appended into de XMLDoc

Parameters
namethe name of the node to create
Returns
the newly created node

◆ read_attribute()

QString read_attribute ( const QString &  attribute,
const QString &  default_value,
bool  inexistent_ok,
bool  empty_ok 
)

reads an attribute from the node

Parameters
attributethe name of the attribute to read
default_valuethe value returned if something goes wrong
inexistent_okif set to false output a DEBUG log line if the attribute doesn't exists
empty_okif set to false output a DEBUG log line if the attribute is empty

◆ read_bool()

bool read_bool ( const QString &  node,
bool  default_value,
bool  inexistent_ok = true,
bool  empty_ok = true 
)

reads a boolean stored into a child node

Parameters
nodethe name of the child node to read into
default_valuethe value returned if something goes wrong
inexistent_okif set to false output a DEBUG log line if the node doesn't exists
empty_okif set to false output a DEBUG log line if the child node is empty

◆ read_child_node()

QString read_child_node ( const QString &  node,
bool  inexistent_ok,
bool  empty_ok 
)
private

reads a string stored into a child node

Parameters
nodethe name of the child node to read into
inexistent_okif set to false output a DEBUG log line if the node doesn't exists
empty_okif set to false output a DEBUG log line if the child node is empty

◆ read_float()

float read_float ( const QString &  node,
float  default_value,
bool  inexistent_ok = true,
bool  empty_ok = true 
)

reads a float stored into a child node

Parameters
nodethe name of the child node to read into
default_valuethe value returned if something goes wrong
inexistent_okif set to false output a DEBUG log line if the node doesn't exists
empty_okif set to false output a DEBUG log line if the child node is empty

◆ read_int()

int read_int ( const QString &  node,
int  default_value,
bool  inexistent_ok = true,
bool  empty_ok = true 
)

reads an integer stored into a child node

Parameters
nodethe name of the child node to read into
default_valuethe value returned if something goes wrong
inexistent_okif set to false output a DEBUG log line if the node doesn't exists
empty_okif set to false output a DEBUG log line if the child node is empty

◆ read_string()

QString read_string ( const QString &  node,
const QString &  default_value,
bool  inexistent_ok = true,
bool  empty_ok = true 
)

reads a string stored into a child node

Parameters
nodethe name of the child node to read into
default_valuethe value returned if something goes wrong
inexistent_okif set to false output a DEBUG log line if the node doesn't exists
empty_okif set to false output a DEBUG log line if the child node is empty

◆ read_text()

QString read_text ( bool  empty_ok)

reads the text (content) from the node

Parameters
empty_okif set to false output a DEBUG log line if the node is empty

◆ write_attribute()

void write_attribute ( const QString &  attribute,
const QString &  value 
)

write a string as an attribute of the node

Parameters
attributethe name of the attribute to create
valuethe value to write in the attribute

◆ write_bool()

void write_bool ( const QString &  node,
const bool  value 
)

write a boolean into a child node

Parameters
nodethe name of the child node to create
valuethe value to write

◆ write_child_node()

void write_child_node ( const QString &  node,
const QString &  text 
)
private

write a string into a child node

Parameters
nodethe name of the child node to create
textthe text to write

◆ write_float()

void write_float ( const QString &  node,
const float  value 
)

write a float into a child node

Parameters
nodethe name of the child node to create
valuethe value to write

◆ write_int()

void write_int ( const QString &  node,
const int  value 
)

write an integer into a child node

Parameters
nodethe name of the child node to create
valuethe value to write

◆ write_string()

void write_string ( const QString &  node,
const QString &  value 
)

write a string into a child node

Parameters
nodethe name of the child node to create
valuethe value to write