24 #ifndef INC_XMLPARSER_HPP_2D5675B8_341A_487A_9504_5A2CAB588986
25 #define INC_XMLPARSER_HPP_2D5675B8_341A_487A_9504_5A2CAB588986
63 virtual std::
string what() const noexcept;
66 virtual std::
string getMessage() const noexcept;
69 virtual
void setMessage(const std::
string& msg) noexcept;
90 static constexpr
int Not_Found = -1;
102 void addAttribute(
const std::string& name,
const std::string& value);
111 int getIndex(
const std::string& name)
const;
114 size_t getCount()
const;
117 bool getName(
size_t index, std::string& name)
const;
120 bool getValue(
size_t index, std::string& value)
const;
123 bool getValue(
const std::string& name, std::string& value)
const;
154 virtual void startElement(
const std::string& name,
const XMLParserAttributes& atts) noexcept(
false);
157 virtual void endElement(
const std::string& name) noexcept(
false);
160 virtual void characters(
const std::string& chars) noexcept(
false);
163 virtual void fatalError(XML_Error errorCode,
const std::string& errorMessage,
int line,
int column) noexcept;
168 static void XMLCALL startElementHandler(
void* userData,
const XML_Char* name,
const XML_Char** atts) noexcept(
false);
171 static void XMLCALL endElementHandler(
void* userData,
const XML_Char* name) noexcept(
false);
174 static void XMLCALL characterDataHandler(
void* userData,
const XML_Char* s,
int len) noexcept(
false);
178 void setDepth(
int depth);
182 int getDepth()
const;
186 bool parse(
const std::string& filename);
189 bool parse(std::istream& is);
229 virtual void endElement(
const std::string& name) noexcept(
false) {}
238 virtual void characters(
const std::string& chars) noexcept(
false) {}
250 virtual void fatalError(XML_Error errorCode,
const std::string& errorMessage,
int line,
int column) noexcept {}
Manages elements' attributes.
std::vector< XMLParserAttribute > attributes
Attributes.
XMLParserAttributes & operator=(const XMLParserAttributes &)=delete
Deleted copy assignment operator.
XMLParserAttributes()
Default constructor.
XMLParserAttributes(const XMLParserAttributes &)=delete
Deleted copy constructor.
Default XML parser handler.
XMLParserDefaultHandler()
Default constructor.
virtual void endElement(const std::string &name) noexcept(false)
Receives notification of the end of an element.
virtual void characters(const std::string &chars) noexcept(false)
Receives notification of character data.
XMLParserDefaultHandler(const XMLParserDefaultHandler &)=delete
Deleted copy constructor.
virtual ~XMLParserDefaultHandler()
Destructor.
virtual void startElement(const std::string &name, const XMLParserAttributes &atts) noexcept(false)
Receives notification of the beginning of an element.
virtual void fatalError(XML_Error errorCode, const std::string &errorMessage, int line, int column) noexcept
Receive notification of a non-recoverable error.
XMLParserDefaultHandler & operator=(const XMLParserDefaultHandler &)=delete
Deleted copy assignment operator.
An exception class for the XML parser.
XMLParserException() noexcept
Default constructor.
virtual void setMessage(const std::string &msg) noexcept
Sets the message.
virtual std::string getMessage() const noexcept
Returns the message.
virtual std::string what() const noexcept
Returns the explanatory string.
std::string message
The message of the exception.
A very simple XML parser.
std::pair< std::string, std::string > XMLParserAttribute
An attribute and its value.