ls1-MarDyn
ls1-MarDyn molecular dynamics code
Classes | Public Member Functions | Static Public Attributes | Friends | List of all members
XMLfile Class Reference

XML file abstraction. More...

#include <xmlfile.h>

Inheritance diagram for XMLfile:
XMLfileUnits

Classes

class  Node
 
class  Query
 

Public Member Functions

 XMLfile ()
 XMLfile default constructor.
 
virtual ~XMLfile ()
 XMLfile default destructor.
 
 XMLfile (const std::string &filepath)
 constructor for XML-file constructor calls initfile More...
 
bool initfile (const std::string &filepath)
 initialize with XML-file instantiating with XML file More...
 
void initstring (const char *xmlstring)
 initialize with XML-string instantiating with XML-string More...
 
const std::string getDir () const
 get XML file directory if instantiated with a XML-file, return the directory More...
 
const std::string getFilename () const
 get XML filename if instantiated with a XML-file, return the filename (without directory part of path) More...
 
long changecurrentnode (const std::string &nodepath=std::string("/"))
 set current node set a node, relative queries start with More...
 
bool changecurrentnode (const Query::const_iterator &pos)
 set current node set a node, relative queries start with More...
 
std::string getcurrentnodepath () const
 get current node path More...
 
template<typename T >
unsigned long getNodeValue (const std::string &nodepath, T &value) const
 get node value get the node content and convert it to a given type More...
 
template<typename T >
unsigned long getNodeValue (const char *nodepath, T &value) const
 get node value get the node content and convert it to a given type More...
 
std::string getNodeValue_string (const std::string &nodepath, const std::string defaultvalue=std::string()) const
 get node value as string get the node content More...
 
std::string getNodeValue_string (const char *nodepath, std::string defaultvalue=std::string()) const
 get node value as string get the node content More...
 
int getNodeValue_int (const std::string &nodepath, int defaultvalue=0) const
 get node value as int get the node content and convert it to an integer More...
 
int getNodeValue_int (const char *nodepath, int defaultvalue=0) const
 get node value as int get the node content and convert it to an integer More...
 
long getNodeValue_long (const std::string &nodepath, long defaultvalue=0) const
 get node value as long get the node content and convert it to a long More...
 
long getNodeValue_long (const char *nodepath, long defaultvalue=0) const
 get node value as long get the node content and convert it to a long More...
 
float getNodeValue_float (const std::string &nodepath, float defaultvalue=0.) const
 get node value as float get the node content and convert it to a float More...
 
float getNodeValue_float (const char *nodepath, float defaultvalue=0.) const
 get node value as float get the node content and convert it to a float More...
 
double getNodeValue_double (const std::string &nodepath, double defaultvalue=0.) const
 get node value as double get the node content and convert it to a double More...
 
double getNodeValue_double (const char *nodepath, double defaultvalue=0.) const
 get node value as double get the node content and convert it to a double More...
 
bool getNodeValue_bool (const std::string &nodepath, bool defaultvalue=false) const
 get node value as bool get the node content and convert it to a bool (an alternative of using <tag>true</tag> is to look for an occurance of an empty element like <tag>) More...
 
bool getNodeValue_bool (const char *nodepath, bool defaultvalue=false) const
 get node value as bool get the node content and convert it to a bool More...
 
void printXML (std::ostream &ostrm=std::cout) const
 print node content as XML print node content to stream using XML More...
 
void print (std::ostream &ostrm=std::cout) const
 print node content print node content and debug information to stream More...
 
void save (std::string filepath=std::string())
 save save node content as XML-file More...
 
Query query (const std::string &querystr) const
 perform a query return a query to a given query expression More...
 
 operator std::string () const
 std::string cast operator XMLfile will cast to a string with XML content
 
size_t numqueries () const
 number of registered queries return the number of active queries More...
 
void setMPIdefaults (int mpirootrank=0, MPI_Comm mpicomm=MPI_COMM_WORLD)
 

Static Public Attributes

static const char *const includeattrtag = "include"
 
static const char *const queryattrtag = "query"
 

Friends

void Query::xmlfile_register ()
 
void Query::xmlfile_unregister ()
 

Detailed Description

XML file abstraction.

DOM representation of an XML file

Constructor & Destructor Documentation

◆ XMLfile()

XMLfile::XMLfile ( const std::string &  filepath)

constructor for XML-file constructor calls initfile

Parameters
std::string&XML-file

Member Function Documentation

◆ changecurrentnode() [1/2]

bool XMLfile::changecurrentnode ( const Query::const_iterator pos)

set current node set a node, relative queries start with

Parameters
Query::const_iterator&query iterator pointing to a node
Returns
bool done?

◆ changecurrentnode() [2/2]

long XMLfile::changecurrentnode ( const std::string &  nodepath = std::string("/"))

set current node set a node, relative queries start with

Parameters
std::string&node path (default: "/")
Returns
long cardinality of the resulting query set; <=0 => no action

◆ getcurrentnodepath()

std::string XMLfile::getcurrentnodepath ( ) const
inline

get current node path

Returns
std::string node path

◆ getDir()

const std::string XMLfile::getDir ( ) const
inline

get XML file directory if instantiated with a XML-file, return the directory

Returns
std::string directory

◆ getFilename()

const std::string XMLfile::getFilename ( ) const
inline

get XML filename if instantiated with a XML-file, return the filename (without directory part of path)

Returns
std::string filename

◆ getNodeValue() [1/2]

template<typename T >
unsigned long XMLfile::getNodeValue ( const char *  nodepath,
T &  value 
) const
inline

get node value get the node content and convert it to a given type

Parameters
constchar* nodepath
T&variable to return value
Returns
unsigned long number of nodes matching the nodepath

◆ getNodeValue() [2/2]

template<typename T >
unsigned long XMLfile::getNodeValue ( const std::string &  nodepath,
T &  value 
) const
inline

get node value get the node content and convert it to a given type

Parameters
std::string&nodepath
T&variable to return value
Returns
unsigned long number of nodes matching the nodepath

◆ getNodeValue_bool() [1/2]

bool XMLfile::getNodeValue_bool ( const char *  nodepath,
bool  defaultvalue = false 
) const
inline

get node value as bool get the node content and convert it to a bool

Parameters
constchar* nodepath
bool&default value to return, if node is not found
Returns
bool node value

◆ getNodeValue_bool() [2/2]

bool XMLfile::getNodeValue_bool ( const std::string &  nodepath,
bool  defaultvalue = false 
) const
inline

get node value as bool get the node content and convert it to a bool (an alternative of using <tag>true</tag> is to look for an occurance of an empty element like <tag>)

Parameters
std::string&nodepath
bool&default value to return, if node is not found
Returns
bool node value

◆ getNodeValue_double() [1/2]

double XMLfile::getNodeValue_double ( const char *  nodepath,
double  defaultvalue = 0. 
) const
inline

get node value as double get the node content and convert it to a double

Parameters
constchar* nodepath
double&default value to return, if node is not found
Returns
double node value

◆ getNodeValue_double() [2/2]

double XMLfile::getNodeValue_double ( const std::string &  nodepath,
double  defaultvalue = 0. 
) const
inline

get node value as double get the node content and convert it to a double

Parameters
std::string&nodepath
double&default value to return, if node is not found
Returns
double node value

◆ getNodeValue_float() [1/2]

float XMLfile::getNodeValue_float ( const char *  nodepath,
float  defaultvalue = 0. 
) const
inline

get node value as float get the node content and convert it to a float

Parameters
constchar* nodepath
float&default value to return, if node is not found
Returns
float node value

◆ getNodeValue_float() [2/2]

float XMLfile::getNodeValue_float ( const std::string &  nodepath,
float  defaultvalue = 0. 
) const
inline

get node value as float get the node content and convert it to a float

Parameters
std::string&nodepath
float&default value to return, if node is not found
Returns
float node value

◆ getNodeValue_int() [1/2]

int XMLfile::getNodeValue_int ( const char *  nodepath,
int  defaultvalue = 0 
) const
inline

get node value as int get the node content and convert it to an integer

Parameters
constchar* nodepath
int&default value to return, if node is not found
Returns
int node value

◆ getNodeValue_int() [2/2]

int XMLfile::getNodeValue_int ( const std::string &  nodepath,
int  defaultvalue = 0 
) const
inline

get node value as int get the node content and convert it to an integer

Parameters
std::string&nodepath
int&default value to return, if node is not found
Returns
int node value

◆ getNodeValue_long() [1/2]

long XMLfile::getNodeValue_long ( const char *  nodepath,
long  defaultvalue = 0 
) const
inline

get node value as long get the node content and convert it to a long

Parameters
constchar* nodepath
long&default value to return, if node is not found
Returns
long node value

◆ getNodeValue_long() [2/2]

long XMLfile::getNodeValue_long ( const std::string &  nodepath,
long  defaultvalue = 0 
) const
inline

get node value as long get the node content and convert it to a long

Parameters
std::string&nodepath
long&default value to return, if node is not found
Returns
long node value

◆ getNodeValue_string() [1/2]

std::string XMLfile::getNodeValue_string ( const char *  nodepath,
std::string  defaultvalue = std::string() 
) const
inline

get node value as string get the node content

Parameters
constchar* nodepath
std::string&default value to return, if node is not found
Returns
std::string node value

◆ getNodeValue_string() [2/2]

std::string XMLfile::getNodeValue_string ( const std::string &  nodepath,
const std::string  defaultvalue = std::string() 
) const
inline

get node value as string get the node content

Parameters
std::string&nodepath
std::string&default value to return, if node is not found
Returns
std::string node value

◆ initfile()

bool XMLfile::initfile ( const std::string &  filepath)

initialize with XML-file instantiating with XML file

Parameters
std::string&XML-file

◆ initstring()

void XMLfile::initstring ( const char *  xmlstring)

initialize with XML-string instantiating with XML-string

Parameters
constchar* XML-string

◆ numqueries()

size_t XMLfile::numqueries ( ) const
inline

number of registered queries return the number of active queries

Returns
number of active queries

◆ print()

void XMLfile::print ( std::ostream &  ostrm = std::cout) const

print node content print node content and debug information to stream

Parameters
std::ostrm&output stream

◆ printXML()

void XMLfile::printXML ( std::ostream &  ostrm = std::cout) const

print node content as XML print node content to stream using XML

Parameters
std::ostrm&output stream

◆ query()

Query XMLfile::query ( const std::string &  querystr) const

perform a query return a query to a given query expression

Parameters
std::string&query string
Returns
XMLfile::Query query

◆ save()

void XMLfile::save ( std::string  filepath = std::string())

save save node content as XML-file

Parameters
std::string&output file

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