libexpatpp 0.1.8
xmlparser.hpp
Go to the documentation of this file.
1
6#ifndef xmlpp_parser_hpp
7#define xmlpp_parser_hpp
8
9#include <cstdint>
10#include "delegate.hpp"
11
12namespace xmlpp {
13
14
16class parser {
17public:
18 enum result : uint8_t {
19 OK,
20 NO_DELEGATE,
21 ERROR_OPEN_FILE,
22 INVALID_INPUT,
23 XML_BUFFER_ERROR,
24 READ_ERROR,
25 PARSE_ERROR
26 };
27 enum class status_t {
28 ERROR = 0,
29 OK = 1,
30 SUSPENDED = 2
31 };
32 enum class error_t {
33 NONE,
34 NO_MEMORY,
35 SYNTAX,
36 NO_ELEMENTS,
37 INVALID_TOKEN,
38 UNCLOSED_TOKEN,
39 PARTIAL_CHAR,
40 TAG_MISMATCH,
41 DUPLICATE_ATTRIBUTE,
42 JUNK_AFTER_DOC_ELEMENT,
43 PARAM_ENTITY_REF,
44 UNDEFINED_ENTITY,
45 RECURSIVE_ENTITY_REF,
46 ASYNC_ENTITY,
47 BAD_CHAR_REF,
48 BINARY_ENTITY_REF,
49 ATTRIBUTE_EXTERNAL_ENTITY_REF,
50 MISPLACED_XML_PI,
51 UNKNOWN_ENCODING,
52 INCORRECT_ENCODING,
53 UNCLOSED_CDATA_SECTION,
54 EXTERNAL_ENTITY_HANDLING,
55 NOT_STANDALONE,
56 UNEXPECTED_STATE,
57 ENTITY_DECLARED_IN_PE,
58 FEATURE_REQUIRES_XML_DTD,
59 CANT_CHANGE_FEATURE_ONCE_PARSING,
60 UNBOUND_PREFIX,
61 UNDECLARING_PREFIX,
62 INCOMPLETE_PE,
63 XML_DECL,
64 TEXT_DECL,
65 PUBLICID,
66 SUSPENDED,
67 NOT_SUSPENDED,
68 ABORTED,
69 FINISHED,
70 SUSPEND_PE,
71 RESERVED_PREFIX_XML,
72 RESERVED_PREFIX_XMLNS,
73 RESERVED_NAMESPACE_URI,
74 INVALID_ARGUMENT
75 };
76
77 explicit parser(delegate& delegate,char namespaceSeparator = ':');
78 virtual ~parser();
79
80 static result parseString(const char*pszString, delegate& delegate);
81 static result parseFile(const std::string& filename, delegate& delegate);
88 static const XML_Char* xmlGetAttrValue(const XML_Char** attrs,
89 const XML_Char* key);
90
91
92 status_t parse(const char* buffer, int len, bool isFinal);
93 error_t errorcode() const;
94 size_t current_line_number() const ;
95 size_t current_column_number() const ;
96private:
97 XML_Parser m_parser;
98};
99
101//result parseFile(const std::string& filename, delegate& pDelegate);
102
103class Attr {
104public:
105 explicit Attr(const XML_Char** attrs) : attrs_(attrs){};
106 std::string getValue(const char* key);
107private:
108 const XML_Char** attrs_{nullptr};
109};
110
111
112}
113#endif // #ifndef xmlpp_parser_hpp
the parser delegate handles the different parser events
Definition xmlparser.hpp:103
definition of the parser delegate interface.
Definition delegate.hpp:31
namespace for SAX2 xml Parser based on expat
Definition xmlparser.hpp:16
static const XML_Char * xmlGetAttrValue(const XML_Char **attrs, const XML_Char *key)
get value of xml attribute identifeid by key from attrs
Definition xmlparser.cpp:311
contains the xml parsers delegate interface