49 static void showErrorStatus(pugi::xml_parse_result &result)
61 logger->
log(
"xml error: %s", result.description());
73 if (Fuzzer::conditionTerminate(filename.c_str()))
90 file.open(filename.c_str(), std::ios::in);
95 file.seekg(0, std::ios::end);
104 file.seekg(0, std::ios::beg);
120 pugi::xml_parse_result result = mDoc.load_buffer_inplace(
data,
123 pugi::encoding_utf8);
124 if (result.status != pugi::status_ok)
126 showErrorStatus(result);
145 Document::Document(
const char *
const data,
const int size) :
153 char *buf =
new char[
size + 1];
156 pugi::xml_parse_result result = mDoc.load_buffer_inplace(buf,
159 pugi::encoding_utf8);
160 if (result.status != pugi::status_ok)
162 showErrorStatus(result);
171 Document::~Document()
177 XmlNodePtr Document::rootNode()
179 return mDoc.first_child();
183 const char *
const name,
190 const pugi::xml_attribute &attr = node.attribute(name);
192 ret = atoi(attr.value());
198 const char *
const name,
207 const pugi::xml_attribute &attr = node.attribute(name);
209 ret = atoi(attr.value());
219 const char *
const name,
226 const pugi::xml_attribute &attr = node.attribute(name);
228 ret = atof(attr.value());
234 const char *
const name,
241 const pugi::xml_attribute &attr = node.attribute(name);
243 ret = atof(attr.value());
249 const char *
const name,
250 const std::string &def)
254 const pugi::xml_attribute &attr = node.attribute(name);
262 const char *
const name,
263 const std::string &def)
273 const char *
const name,
278 const pugi::xml_attribute &attr = node.attribute(name);
281 std::string val = attr.value();
292 const char *
const name)
294 if (!parent || !name)
295 return pugi::xml_node();
298 if (!strcmp(child.name(), name))
302 return pugi::xml_node();
322 bool Document::validateXml(
const std::string &
fileName)
324 pugi::xml_document doc;
325 pugi::xml_parse_result result = doc.load_file(
fileName.c_str(),
327 pugi::encoding_utf8);
329 if (result.status != pugi::status_ok)
331 showErrorStatus(result);
336 file.open(
fileName.c_str(), std::ios::in);
343 if (!file.getline(line, 100))
347 const std::string str = line;
#define reportAlways(...)
void log(const char *const log_text,...)
const std::string getStr(const std::string &str)
Document(const std::string &filename, const UseVirtFs useResman, const SkipError skipError)
#define for_each_xml_child_node(var, parent)
const char * loadFile(std::string filename, int &fileSize)
std::string langProperty(const xmlNodePtr node, const char *const name, const std::string &def)
float getFloatProperty(const xmlNodePtr node, const char *const name, float def)
bool getBoolProperty(const xmlNodePtr node, const char *const name, const bool def)
int getProperty(const xmlNodePtr node, const char *const name, int def)
int getIntProperty(const xmlNodePtr node, const char *const name, int def, const int min, const int max)
xmlNodePtr findFirstChildByName(const xmlNode *const parent, const char *const name)
double getDoubleProperty(const xmlNodePtr node, const char *const name, double def)
#define BLOCK_START(name)
const bool SkipError_false
bool strStartWith(const std::string &str1, const std::string &str2)
const bool UseVirtFs_true