aboutsummaryrefslogtreecommitdiff
path: root/include/cru/xml
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-01-02 18:49:31 +0800
committercrupest <crupest@outlook.com>2022-01-02 18:49:31 +0800
commit18099ad8f5c24b1c2b1c92238dbc54912eab0406 (patch)
tree514207d630a2100262aedaea276ea259bbc108b7 /include/cru/xml
parent96a93e17baaff2c2050eba2afada639e93001232 (diff)
downloadcru-18099ad8f5c24b1c2b1c92238dbc54912eab0406.tar.gz
cru-18099ad8f5c24b1c2b1c92238dbc54912eab0406.tar.bz2
cru-18099ad8f5c24b1c2b1c92238dbc54912eab0406.zip
...
Diffstat (limited to 'include/cru/xml')
-rw-r--r--include/cru/xml/XmlNode.hpp3
-rw-r--r--include/cru/xml/XmlParser.hpp4
2 files changed, 5 insertions, 2 deletions
diff --git a/include/cru/xml/XmlNode.hpp b/include/cru/xml/XmlNode.hpp
index 0cbb6756..186f395c 100644
--- a/include/cru/xml/XmlNode.hpp
+++ b/include/cru/xml/XmlNode.hpp
@@ -67,7 +67,7 @@ class XmlElementNode : public XmlNode {
CRU_DELETE_COPY(XmlElementNode)
CRU_DELETE_MOVE(XmlElementNode)
- ~XmlElementNode() override = default;
+ ~XmlElementNode() override;
public:
String GetTag() const { return tag_; }
@@ -78,6 +78,7 @@ class XmlElementNode : public XmlNode {
void SetAttributes(std::unordered_map<String, String> attributes) {
attributes_ = std::move(attributes);
}
+ const std::vector<XmlNode*> GetChildren() const { return children_; }
void AddAttribute(String key, String value);
void AddChild(XmlNode* child);
diff --git a/include/cru/xml/XmlParser.hpp b/include/cru/xml/XmlParser.hpp
index 1d44c46f..188a08f2 100644
--- a/include/cru/xml/XmlParser.hpp
+++ b/include/cru/xml/XmlParser.hpp
@@ -28,6 +28,7 @@ class XmlParser {
XmlElementNode* DoParse();
char16_t Read1();
+ String ReadWithoutAdvance(int count = 1);
void ReadSpacesAndDiscard();
String ReadSpaces();
String ReadIdenitifier();
@@ -36,8 +37,9 @@ class XmlParser {
private:
String xml_;
- XmlElementNode* cache_;
+ XmlElementNode* cache_ = nullptr;
+ // Consider the while file enclosed by a single tag called $root.
XmlElementNode* pseudo_root_node_ = new XmlElementNode(u"$root");
XmlElementNode* current_ = pseudo_root_node_;
int current_position_ = 0;