34 #include <libxml/parserInternals.h>
40 ctxt->userData = parser;
94 _garbage.push_back(_stackParser.top());
95 DEBTRACE(
"xmlParserBase::end_element " << _garbage.size());
97 XML_SetUserData(_xmlParser, _stackParser.top());
98 childParser->
onEnd(aName);
114 string data((
char*)ch,len);
123 const xmlChar* value)
134 const char* fmt, ...)
140 string format =
"%s";
144 parv = va_arg(
args,
char*);
147 else cerr << __FILE__ <<
" [" << __LINE__ <<
"] : "
148 <<
"error format not taken into account: " << fmt << endl;
157 const char* fmt, ...)
163 string format =
"%s";
167 parv = va_arg(
args,
char*);
172 else cerr << __FILE__ <<
" [" << __LINE__ <<
"] : "
173 <<
"error format not taken into account: " << fmt << endl;
182 const char* fmt, ...)
184 DEBTRACE(
"xmlParserBase::fatal_error");
188 string format =
"%s";
192 parv = va_arg(
args,
char*);
195 else cerr << __FILE__ <<
" [" << __LINE__ <<
"] : "
196 <<
"error format not taken into account: " << fmt << endl;
205 const xmlChar* value,
210 string data((
char*)value,len);
216 while (!_garbage.empty())
218 delete (_garbage.front());
219 _garbage.pop_front();
231 string attributeName = (
char*)*
p;
234 string attributeValue = (
char*)*
p;
237 _mapAttrib[attributeName] = attributeValue;
247 _mapAttrib[key] = value;
256 if (_mapAttrib.find(key) == _mapAttrib.end())
258 string what =
"Attribute does not exist: " + key;
261 return _mapAttrib[key];
309 if(counts.find(elem)==counts.end())
312 counts[elem]=counts[elem]+1;
327 xmlStopParser(_xmlParser);
349 xmlSAXHandler baseHandler =
383 saxContext = xmlCreateFileParserCtxt(xmlFile.c_str());
387 string what =
"problem while trying to open the file for parsing " + xmlFile;
base class for xml parsers, runtime independant
static void XML_SetUserData(_xmlParserCtxt *ctxt, xmlParserBase *parser)
virtual void onStart(const XML_Char *elem, const xmlChar **p)
static void XMLCALL start_element(void *userData, const xmlChar *name, const xmlChar **p)
static int getGarbageSize()
virtual void stopParse(std::string what)
static void XMLCALL end_element(void *userData, const xmlChar *name)
static void XMLCALL start_document(void *userData)
static void XMLCALL characters(void *userData, const xmlChar *ch, int len)
static _xmlParserCtxt * _xmlParser
static void XMLCALL error(void *userData, const char *fmt,...)
virtual void addData(std::string value)
static void XMLCALL fatal_error(void *userData, const char *fmt,...)
virtual void onEnd(const XML_Char *name)
static std::list< xmlParserBase * > _garbage
void setAttribute(std::string key, std::string value)
static void cleanGarbage()
static std::stack< xmlParserBase * > _stackParser
void getAttributes(const xmlChar **p)
static void XMLCALL comment(void *userData, const xmlChar *value)
static void XMLCALL cdata_block(void *userData, const xmlChar *value, int len)
virtual void init(const xmlChar **p, xmlParserBase *father=0)
std::string getAttribute(std::string key)
static void XMLCALL end_document(void *userData)
static void XMLCALL warning(void *userData, const char *fmt,...)
virtual void charData(std::string data)
virtual void incrCount(const XML_Char *elem)
virtual void parse(std::string xmlFile)
xmlParserBase * _rootParser
xmlReader(xmlParserBase *parser)
_xmlParserCtxt * saxContext
XML_Char * tochar(const xmlChar *c)