#include <xml_document.h>
Public Member Functions | |
bool | Load (const std::string &nomfich) |
bool | IsOk () const |
xmlpp::Element * | GetRoot () const |
Static Public Member Functions | |
static bool | ReadString (const xmlpp::Node *father, const std::string &name, std::string &output) |
static bool | ReadDouble (const xmlpp::Node *father, const std::string &name, double &output) |
static bool | ReadInt (const xmlpp::Node *father, const std::string &name, int &output) |
static bool | ReadUint (const xmlpp::Node *father, const std::string &name, unsigned int &output) |
static bool | ReadBool (const xmlpp::Node *father, const std::string &name, bool &output) |
static bool | ReadStringList (const xmlpp::Node *x, const std::string &name, std::list< std::string > &output) |
static bool | ReadMarkerValue (const xmlpp::Node *marker, std::string &output) |
static xmlpp::Element * | GetMarker (const xmlpp::Node *x, const std::string &name) |
static xmlpp::Element * | Access (const xmlpp::Node *x, const std::string &name, const std::string &attr_name) |
static bool | ReadStringAttr (const xmlpp::Element *x, const std::string &name, std::string &output) |
static bool | ReadDoubleAttr (const xmlpp::Element *x, const std::string &name, double &output) |
static bool | ReadIntAttr (const xmlpp::Element *x, const std::string &name, int &output) |
static bool | ReadUintAttr (const xmlpp::Element *x, const std::string &name, unsigned int &output) |
static bool | ReadBoolAttr (const xmlpp::Element *x, const std::string &name, bool &output) |
Public Attributes | |
xmlpp::DomParser | parser |
Definition at line 12 of file xml_document.h.
xmlpp::Element * XmlReader::Access | ( | const xmlpp::Node * | x, | |
const std::string & | name, | |||
const std::string & | attr_name | |||
) | [static] |
Definition at line 52 of file xml_document.cpp.
00055 { 00056 xmlpp::Node::NodeList nodes = x -> get_children(name); 00057 xmlpp::Node::NodeList::iterator 00058 it = nodes.begin(), 00059 end = nodes.end(); 00060 for (; it != end; ++it) { 00061 00062 xmlpp::Element *elem = dynamic_cast<xmlpp::Element*>(*it); 00063 assert (elem != NULL); 00064 const xmlpp::Attribute *attr = elem->get_attribute("name"); 00065 if (attr != NULL) { 00066 if (attr -> get_value() == attr_name) return elem; 00067 } 00068 } 00069 return NULL; 00070 }
Here is the caller graph for this function:
xmlpp::Element * XmlReader::GetMarker | ( | const xmlpp::Node * | x, | |
const std::string & | name | |||
) | [static] |
Definition at line 41 of file xml_document.cpp.
00043 { 00044 xmlpp::Node::NodeList nodes = x -> get_children(name); 00045 if (nodes.size() != 1) return NULL; 00046 00047 xmlpp::Element *elem = dynamic_cast<xmlpp::Element*> (nodes.front()); 00048 assert (elem != NULL); 00049 return elem; 00050 }
Here is the caller graph for this function:
xmlpp::Element * XmlReader::GetRoot | ( | ) | const |
bool XmlReader::IsOk | ( | ) | const |
Definition at line 219 of file xml_document.cpp.
00220 { 00221 return parser; 00222 }
Here is the caller graph for this function:
bool XmlReader::Load | ( | const std::string & | nomfich | ) |
Definition at line 28 of file xml_document.cpp.
00029 { 00030 if( !IsFileExist(filename) ) 00031 return false; 00032 00033 // Activate DTD validation parser 00034 // parser.set_validate (true); 00035 00036 // Read file 00037 parser.parse_file(filename); 00038 return IsOk(); 00039 }
Here is the call graph for this function:
Here is the caller graph for this function:
bool XmlReader::ReadBool | ( | const xmlpp::Node * | father, | |
const std::string & | name, | |||
bool & | output | |||
) | [static] |
Definition at line 113 of file xml_document.cpp.
00116 { 00117 std::string val; 00118 if (!ReadString(x, name, val)) return false; 00119 return str2bool (val, output); 00120 }
Here is the call graph for this function:
Here is the caller graph for this function:
bool XmlReader::ReadBoolAttr | ( | const xmlpp::Element * | x, | |
const std::string & | name, | |||
bool & | output | |||
) | [static] |
Definition at line 200 of file xml_document.cpp.
00203 { 00204 std::string val; 00205 if (!ReadStringAttr(x, name, val)) return false; 00206 return str2bool(val, output); 00207 }
Here is the call graph for this function:
Here is the caller graph for this function:
bool XmlReader::ReadDouble | ( | const xmlpp::Node * | father, | |
const std::string & | name, | |||
double & | output | |||
) | [static] |
Definition at line 81 of file xml_document.cpp.
00084 { 00085 std::string val; 00086 if (!ReadString(x, name, val)) return false; 00087 return str2double (val, output); 00088 }
Here is the call graph for this function:
Here is the caller graph for this function:
bool XmlReader::ReadDoubleAttr | ( | const xmlpp::Element * | x, | |
const std::string & | name, | |||
double & | output | |||
) | [static] |
Definition at line 210 of file xml_document.cpp.
00213 { 00214 std::string val; 00215 if (!ReadStringAttr(x, name, val)) return false; 00216 return str2double(val, output); 00217 }
Here is the call graph for this function:
Here is the caller graph for this function:
bool XmlReader::ReadInt | ( | const xmlpp::Node * | father, | |
const std::string & | name, | |||
int & | output | |||
) | [static] |
Definition at line 90 of file xml_document.cpp.
00093 { 00094 std::string val; 00095 if (!ReadString(x, name, val)) return false; 00096 return str2int (val, output); 00097 }
Here is the call graph for this function:
Here is the caller graph for this function:
bool XmlReader::ReadIntAttr | ( | const xmlpp::Element * | x, | |
const std::string & | name, | |||
int & | output | |||
) | [static] |
Definition at line 177 of file xml_document.cpp.
00180 { 00181 std::string val; 00182 if (!ReadStringAttr(x, name, val)) return false; 00183 return str2int (val, output); 00184 }
Here is the call graph for this function:
Here is the caller graph for this function:
bool XmlReader::ReadMarkerValue | ( | const xmlpp::Node * | marker, | |
std::string & | output | |||
) | [static] |
Definition at line 122 of file xml_document.cpp.
00124 { 00125 if(marker->get_children().size() == 0) 00126 { 00127 output = ""; 00128 return true; 00129 } 00130 00131 // Read node value 00132 assert(marker->get_children().size() == 1); 00133 assert(marker->get_children().front()->get_name() == "text"); 00134 const xmlpp::TextNode *text = dynamic_cast<const xmlpp::TextNode*>(marker->get_children().front()); 00135 assert(text != NULL); 00136 output = text->get_content(); 00137 return true; 00138 }
Here is the caller graph for this function:
bool XmlReader::ReadString | ( | const xmlpp::Node * | father, | |
const std::string & | name, | |||
std::string & | output | |||
) | [static] |
Definition at line 72 of file xml_document.cpp.
00075 { 00076 xmlpp::Element *elem = GetMarker(x, name); 00077 if (elem == NULL) return false; 00078 return ReadMarkerValue(elem, output); 00079 }
Here is the call graph for this function:
Here is the caller graph for this function:
bool XmlReader::ReadStringAttr | ( | const xmlpp::Element * | x, | |
const std::string & | name, | |||
std::string & | output | |||
) | [static] |
Definition at line 166 of file xml_document.cpp.
00169 { 00170 assert (x != NULL); 00171 const xmlpp::Attribute *attr = x -> get_attribute(name); 00172 if (attr == NULL) return false; 00173 output = attr->get_value(); 00174 return true; 00175 }
Here is the caller graph for this function:
bool XmlReader::ReadStringList | ( | const xmlpp::Node * | x, | |
const std::string & | name, | |||
std::list< std::string > & | output | |||
) | [static] |
Definition at line 140 of file xml_document.cpp.
00143 { 00144 xmlpp::Node::NodeList nodes = x -> get_children(name); 00145 xmlpp::Node::NodeList::iterator 00146 it=nodes.begin(), 00147 end=nodes.end(); 00148 00149 output.clear(); 00150 for (; it != end; ++it) 00151 { 00152 std::string txt; 00153 00154 xmlpp::Element *elem = dynamic_cast<xmlpp::Element*> (*it); 00155 assert (elem != NULL); 00156 if (!ReadMarkerValue(elem, txt)) 00157 { 00158 output.clear(); 00159 return false; 00160 } 00161 output.push_back (txt); 00162 } 00163 return true; 00164 }
Here is the call graph for this function:
bool XmlReader::ReadUint | ( | const xmlpp::Node * | father, | |
const std::string & | name, | |||
unsigned int & | output | |||
) | [static] |
Definition at line 99 of file xml_document.cpp.
00102 { 00103 int val; 00104 if (!ReadInt(x, name, val)) return false; 00105 if (0 <= val) { 00106 output = static_cast<unsigned int>(val); 00107 return true; 00108 } else { 00109 return false; 00110 } 00111 }
Here is the call graph for this function:
Here is the caller graph for this function:
bool XmlReader::ReadUintAttr | ( | const xmlpp::Element * | x, | |
const std::string & | name, | |||
unsigned int & | output | |||
) | [static] |
Definition at line 186 of file xml_document.cpp.
00189 { 00190 int val; 00191 if (!ReadIntAttr(x, name, val)) return false; 00192 if (0 <= val) { 00193 output = static_cast<unsigned int> (val); 00194 return true; 00195 } else { 00196 return false; 00197 } 00198 }
Here is the call graph for this function:
Here is the caller graph for this function:
xmlpp::DomParser XmlReader::parser |
Definition at line 15 of file xml_document.h.