19 #ifndef __CONFIGURATION 21 #define __CONFIGURATION 40 void findNodes(
const char* name, std::vector<TiXmlElement*> &result, TiXmlElement* start,
unsigned int level);
47 void findNodes(
const char* name, std::vector<TiXmlElement*> &result);
48 void findNodes(
const char* name, std::vector<TiXmlElement*> &result, TiXmlElement* start);
49 TiXmlElement*
findNode(
const char* name);
50 TiXmlElement*
findNode(
const char* name, TiXmlElement* start);
53 bool load(
const char* cfgFile);
54 bool parse(
const char* str);
55 void save(
const char* cfgFile);
57 float getFloat(
const char* str,
float def = 0.0);
58 double getDouble(
const char* str,
double def = 0.0);
59 const char*
getString(
const char* str,
const char* def =
"");
62 bool getBoolean(
const char* str,
bool def =
false);
64 static std::string
getText(TiXmlElement* node);
66 float getFloat(
const char* str, TiXmlElement* start,
float def = 0.0);
67 double getDouble(
const char* str, TiXmlElement* start,
double def = 0.0);
68 const char*
getString(
const char* str, TiXmlElement* start,
const char* def =
"");
69 int getInteger(
const char* str, TiXmlElement* start,
int def = 0);
70 bool getBoolean(
const char* str, TiXmlElement* start,
bool def =
false);
72 void setFloat(
const char* str,
float value);
73 void setDouble(
const char* str,
double value);
74 void setString(
const char* str,
const char* value);
78 static float getAttributeFloat(TiXmlElement* node,
const char* str,
float def = 0.0);
80 static double getAttributeDouble(TiXmlElement* node,
const char* str,
double def = 0.0);
81 static const char*
getAttributeString(TiXmlElement* node,
const char* str,
const char* def =
"");
87 static void setAttributeString(TiXmlElement* node,
const char* str,
const char* value);
93 TiXmlElement*
getNode(
const char* name);
94 bool addNode(TiXmlElement* node);
95 bool addNode(TiXmlElement* node, TiXmlElement* parent);
96 bool insertNode(TiXmlElement* node, TiXmlElement* afterThis);
97 bool insertNode(TiXmlElement* node, TiXmlElement* afterThis, TiXmlElement* parent);
100 bool removeNode(TiXmlElement* element, TiXmlElement* parent);
104 #define XML_LOADER_INIT std::vector<std::string> xml_loader_strings; 105 #define XML_LOADER_ADD(Y,X) xml_loader_strings.push_back(robotLibPbD::printToString("<%s>%s</%s>", Y, X.c_str(), Y)); 106 #define XML_LOADER_ADD_STRING(Y,X) xml_loader_strings.push_back(robotLibPbD::printToString("<%s>%s</%s>", Y, X.c_str(), Y)); 107 #define XML_LOADER_ADD_INTEGER(Y,X) xml_loader_strings.push_back(robotLibPbD::printToString("<%s>%d</%s>", Y, X, Y)); 108 #define XML_LOADER_ADD_DOUBLE(Y,X) xml_loader_strings.push_back(robotLibPbD::printToString("<%s>%g</%s>", Y, X, Y)); 109 #define XML_LOADER_ADD_FLOAT(Y,X) xml_loader_strings.push_back(robotLibPbD::printToString("<%s>%g</%s>", Y, X, Y)); 110 #define XML_LOADER_ADD_BOOLEAN(Y,X) xml_loader_strings.push_back(robotLibPbD::printToString("<%s>%s</%s>", Y, X ? "true" : "false", Y)); 111 #define XML_LOADER_GET(Y) { \ 112 for (unsigned int i=0; i<xml_loader_strings.size(); i++) \ 114 Y += xml_loader_strings[i] + "\n"; \ 121 virtual bool writeAsXml(std::string &output,
bool addBracket =
true) {
return false; };
125 void tokenize(
const std::string& str,
126 std::vector<std::string>& tokens,
127 const std::string& delimiters);
TiXmlElement * getNode(const char *name)
void setString(const char *str, const char *value)
void setInteger(const char *str, int value)
static void setAttributeDouble(TiXmlElement *node, const char *str, double value)
static const char * getAttributeString(TiXmlElement *node, const char *str, const char *def="")
void tokenize(const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters)
bool insertNode(TiXmlElement *node, TiXmlElement *afterThis)
void setFloat(const char *str, float value)
bool removeAttribute(TiXmlElement *element, const char *name)
unsigned long getUnsignedLong(const char *str, unsigned long def=0)
static void setAttributeBoolean(TiXmlElement *node, const char *str, bool value)
bool addNode(TiXmlElement *node)
float getFloat(const char *str, float def=0.0)
bool removeNode(TiXmlElement *element)
static float getAttributeFloat(TiXmlElement *node, const char *str, float def=0.0)
static unsigned long getAttributeUnsignedLong(TiXmlElement *node, const char *str, unsigned long def=0)
TiXmlElement * findNode(const char *name)
static void setAttributeString(TiXmlElement *node, const char *str, const char *value)
bool load(const char *cfgFile)
static std::string getText(TiXmlElement *node)
void setDouble(const char *str, double value)
static void setAttributeInteger(TiXmlElement *node, const char *str, int value)
bool getBoolean(const char *str, bool def=false)
bool parse(const char *str)
static void setAttributeFloat(TiXmlElement *node, const char *str, float value)
virtual ~CConfiguration()
void save(const char *cfgFile)
int getInteger(const char *str, int def=0)
double getDouble(const char *str, double def=0.0)
virtual bool writeAsXml(std::string &output, bool addBracket=true)
TiXmlDocument & getDocument()
void findNodes(const char *name, std::vector< TiXmlElement * > &result, TiXmlElement *start, unsigned int level)
void setRootNode(const char *node)
static bool getAttributeBoolean(TiXmlElement *node, const char *str, bool def=false)
static int getAttributeInteger(TiXmlElement *node, const char *str, int def=0)
virtual bool readFromXml(CConfiguration &configuration, TiXmlElement *xmlNode)
Configuration file wrapper.
const char * getString(const char *str, const char *def="")
static double getAttributeDouble(TiXmlElement *node, const char *str, double def=0.0)
void setBoolean(const char *str, bool value)