10 using std::string_view;
18 void start(string_view name);
19 void attribute(string_view name, string_view value);
20 void text(string_view txt);
24 [[nodiscard]] string_view
getSystemID()
const {
return systemID; }
29 std::vector<XMLElement*> current;
48 rapidsax::parse<0>(handler, buf.
data());
53 if (root.getName().empty()) {
55 ": Document doesn't contain mandatory root Element");
59 "You're probably using an old incompatible file format.");
63 "(expected ", systemID,
", got ", handler.
getSystemID(),
")\n"
64 "You're probably using an old incompatible file format.");
66 return std::move(root);
72 if (!current.empty()) {
73 return ¤t.back()->addChild(name);
79 current.push_back(newElem);
84 if (current.back()->hasAttribute(name)) {
86 "Found duplicate attribute \"", name,
"\" in <",
87 current.back()->getName(),
">.");
89 current.back()->addAttribute(name, value);
94 if (current.back()->hasChildren()) {
97 "Mixed text+subtags in <", current.back()->getName(),
100 current.back()->setData(txt);
110 auto pos1 = txt.find(
" SYSTEM ");
111 if (pos1 == string_view::npos)
return;
112 if ((pos1 + 8) >= txt.size())
return;
113 char q = txt[pos1 + 8];
114 if (q !=
one_of(
'"',
'\''))
return;
115 auto t = txt.substr(pos1 + 9);
116 auto pos2 =
t.find(q);
117 if (pos2 == string_view::npos)
return;
119 systemID =
t.substr(0, pos2);
void read(void *buffer, size_t num)
Read from file.
size_t getSize()
Returns the size of this file.
const std::string & getMessage() const &
const T * data() const
Returns pointer to the start of the memory buffer.
void resize(size_t size)
Grow or shrink the memory block.
void setName(String &&name_)
void text(string_view txt)
string_view getSystemID() const
void start(string_view name)
void attribute(string_view name, string_view value)
void doctype(string_view txt)
XMLElement load(const std::string &filename, string_view systemID)
constexpr const char *const filename
constexpr size_t EXTRA_BUFFER_SPACE
size_t size(std::string_view utf8)