hydrogen 1.2.6
XMLNode Class Reference

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

#include <Xml.h>

Inheritance diagram for XMLNode:
Object< XMLNode > Base

Public Member Functions

 XMLNode ()
 basic constructor
 
 XMLNode (QDomNode node)
 to wrap a QDomNode
 
XMLNode createNode (const QString &name)
 create a new XMLNode that has to be appended into de XMLDoc
 
QString read_attribute (const QString &attribute, const QString &default_value, bool inexistent_ok, bool empty_ok, bool bSilent=false)
 reads an attribute from the node
 
bool read_bool (const QString &node, bool default_value, bool *pFound, bool inexistent_ok=true, bool empty_ok=true, bool bSilent=false)
 reads a boolean stored into a child node
 
bool read_bool (const QString &node, bool default_value, bool inexistent_ok=true, bool empty_ok=true, bool bSilent=false)
 reads a boolean stored into a child node
 
QColor read_color (const QString &node, const QColor &defaultValue=QColor(97, 167, 251), bool inexistent_ok=true, bool empty_ok=true, bool bSilent=false)
 
float read_float (const QString &node, float default_value, bool *pFound, bool inexistent_ok=true, bool empty_ok=true, bool bSilent=false)
 
float read_float (const QString &node, float default_value, bool inexistent_ok=true, bool empty_ok=true, bool bSilent=false)
 reads a float stored into a child node
 
int read_int (const QString &node, int default_value, bool inexistent_ok=true, bool empty_ok=true, bool bSilent=false)
 reads an integer stored into a child node
 
QString read_string (const QString &node, const QString &default_value, bool inexistent_ok=true, bool empty_ok=true, bool bSilent=false)
 reads a string stored into a child node
 
QString read_text (bool empty_ok, bool bSilent=false)
 reads the text (content) from the node
 
void write_attribute (const QString &attribute, const QString &value)
 write a string as an attribute of the node
 
void write_bool (const QString &node, const bool value)
 write a boolean into a child node
 
void write_color (const QString &node, const QColor &color)
 
void write_float (const QString &node, const float value)
 write a float into a child node
 
void write_int (const QString &node, const int value)
 write an integer into a child node
 
void write_string (const QString &node, const QString &value)
 write a string into a child node
 
- Public Member Functions inherited from Object< XMLNode >
 Object ()
 
 Object (const Object< XMLNode > &other)
 
- Public Member Functions inherited from Base
 Base ()
 
 Base (const Base &other)
 
virtual const char * class_name () const
 
void logBacktrace () const
 Print the current stack at point into the debug log.
 
void Print (bool bShort=true) const
 Prints content of toQString() via DEBUGLOG.
 
virtual QString toQString (const QString &sPrefix="", bool bShort=true) const
 Formatted string version for debugging purposes.
 

Private Member Functions

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

Additional Inherited Members

- Static Public Member Functions inherited from Base
static const char * _class_name ()
 return the class name
 
static QString base_clock (const QString &sMsg)
 Measures the current time and stores it in __last_clock.
 
static QString base_clock_in (const QString &sMsg)
 
static int bootstrap (Logger *logger, bool count=false)
 must be called before any Object instantiation !
 
static bool count_active ()
 
static int getAliveObjectCount ()
 
static object_map_t getObjectMap ()
 
static Loggerlogger ()
 return the logger instance
 
static int objects_count ()
 
static void printObjectMapDiff (object_map_t map)
 Creates the difference between a snapshot of the object map and its current state and prints it to std::cout.
 
static void set_count (bool flag)
 enable/disable class instances counting
 
static void write_objects_map_to (std::ostream &out, object_map_t *map=nullptr)
 output the full objects map to a given ostream
 
static void write_objects_map_to_cerr ()
 output objects map to stderr
 
- Static Public Attributes inherited from Base
static QString sPrintIndention = " "
 String used to format the debugging string output of some core classes.
 
- Protected Member Functions inherited from Object< XMLNode >
 ~Object ()
 
- Protected Member Functions inherited from Base
 ~Base ()
 
- Static Protected Member Functions inherited from Base
static void registerClass (const char *name, const atomic_obj_cpt_t *counters)
 
- Static Protected Attributes inherited from Base
static bool __count = false
 should we count class instances
 
static timeval __last_clock = { 0, 0 }
 
static Logger__logger = nullptr
 
static bool bLogColors = true
 

Detailed Description

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

Definition at line 38 of file Xml.h.

Constructor & Destructor Documentation

◆ XMLNode() [1/2]

XMLNode ( )

basic constructor

Definition at line 41 of file Xml.cpp.

◆ XMLNode() [2/2]

XMLNode ( QDomNode node)

to wrap a QDomNode

Definition at line 42 of file Xml.cpp.

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

Definition at line 44 of file Xml.cpp.

◆ read_attribute()

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

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
bSilentWhether debug and info messages should be logged when anomalies are encountered while reading the XML nodes.

Definition at line 211 of file Xml.cpp.

◆ read_bool() [1/2]

bool read_bool ( const QString & node,
bool default_value,
bool * pFound,
bool inexistent_ok = true,
bool empty_ok = true,
bool bSilent = false )

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
pFoundIndicates whether the node was found.
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
bSilentWhether debug and info messages should be logged when anomalies are encountered while reading the XML nodes.

Definition at line 182 of file Xml.cpp.

◆ read_bool() [2/2]

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

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
bSilentWhether debug and info messages should be logged when anomalies are encountered while reading the XML nodes.

Definition at line 165 of file Xml.cpp.

◆ read_child_node()

QString read_child_node ( const QString & node,
bool inexistent_ok,
bool empty_ok,
bool bSilent = false )
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
bSilentWhether debug and info messages should be logged when anomalies are encountered while reading the XML nodes.

Definition at line 51 of file Xml.cpp.

◆ read_color()

QColor read_color ( const QString & node,
const QColor & defaultValue = QColor( 97, 167, 251 ),
bool inexistent_ok = true,
bool empty_ok = true,
bool bSilent = false )

Definition at line 88 of file Xml.cpp.

◆ read_float() [1/2]

float read_float ( const QString & node,
float default_value,
bool * pFound,
bool inexistent_ok = true,
bool empty_ok = true,
bool bSilent = false )

Definition at line 134 of file Xml.cpp.

◆ read_float() [2/2]

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

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
bSilentWhether debug and info messages should be logged when anomalies are encountered while reading the XML nodes.

Definition at line 120 of file Xml.cpp.

◆ read_int()

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

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
bSilentWhether debug and info messages should be logged when anomalies are encountered while reading the XML nodes.

Definition at line 151 of file Xml.cpp.

◆ read_string()

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

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
bSilentWhether debug and info messages should be logged when anomalies are encountered while reading the XML nodes.

Definition at line 76 of file Xml.cpp.

◆ read_text()

QString read_text ( bool empty_ok,
bool bSilent = false )

reads the text (content) from the node

Parameters
empty_okif set to false output a DEBUG log line if the node is empty
bSilentWhether debug and info messages should be logged when anomalies are encountered while reading the XML nodes.

Definition at line 202 of file Xml.cpp.

◆ 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

Definition at line 237 of file Xml.cpp.

◆ 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

Definition at line 269 of file Xml.cpp.

◆ 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

Definition at line 242 of file Xml.cpp.

◆ write_color()

void write_color ( const QString & node,
const QColor & color )

Definition at line 254 of file Xml.cpp.

◆ 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

Definition at line 261 of file Xml.cpp.

◆ 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

Definition at line 265 of file Xml.cpp.

◆ 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

Definition at line 250 of file Xml.cpp.