24 #ifdef ENABLE_TINYXML2
48 static void showErrorStatus(tinyxml2::XMLDocument &doc)
50 #ifdef USE_TINYXML_OLD
51 logger->
log(
"xml error: %s, in lines: %s\n%s",
57 logger->
log(
"xml error: %s, in lines: %s",
72 if (Fuzzer::conditionTerminate(filename.c_str()))
89 file.open(filename.c_str(), std::ios::in);
94 file.seekg(0, std::ios::end);
103 file.seekg(0, std::ios::beg);
118 tinyxml2::XMLError result = mDoc.Parse(
data,
120 if (result != tinyxml2::XML_SUCCESS)
122 showErrorStatus(mDoc);
138 Document::Document(
const char *
const data,
const int size) :
147 char *buf =
new char[
size + 1];
151 tinyxml2::XMLError result = mDoc.Parse(buf,
153 if (result != tinyxml2::XML_SUCCESS)
155 showErrorStatus(mDoc);
164 Document::~Document()
170 XmlNodeConstPtr Document::rootNode()
172 return mDoc.FirstChildElement();
176 const char *
const name,
183 const char *attr = node->Attribute(name);
191 const char *
const name,
200 const char *attr = node->Attribute(name);
212 const char *
const name,
219 const char *attr = node->Attribute(name);
227 const char *
const name,
234 const char *attr = node->Attribute(name);
242 const char *
const name,
243 const std::string &def)
247 const char *attr = node->Attribute(name);
255 const char *
const name,
256 const std::string &def)
266 const char *
const name,
271 const char *attr = node->Attribute(name);
274 std::string val = attr;
285 const char *
const name)
287 if (!parent || !name)
289 return parent->FirstChildElement(name);
302 bool Document::validateXml(
const std::string &
fileName)
304 tinyxml2::XMLDocument doc;
305 tinyxml2::XMLError result = doc.LoadFile(
fileName.c_str());
307 if (result != tinyxml2::XML_SUCCESS)
309 showErrorStatus(doc);
314 file.open(
fileName.c_str(), std::ios::in);
321 if (!file.getline(line, 100))
325 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)
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