From 18099ad8f5c24b1c2b1c92238dbc54912eab0406 Mon Sep 17 00:00:00 2001 From: crupest Date: Sun, 2 Jan 2022 18:49:31 +0800 Subject: ... --- include/cru/xml/XmlNode.hpp | 3 ++- include/cru/xml/XmlParser.hpp | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'include/cru/xml') 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 attributes) { attributes_ = std::move(attributes); } + const std::vector 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; -- cgit v1.2.3