aboutsummaryrefslogtreecommitdiff
path: root/include/cru
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-03-04 20:07:50 +0800
committercrupest <crupest@outlook.com>2022-03-04 20:07:50 +0800
commit14e1b0f188d302b69816ddf12f5ac591fd76b91d (patch)
tree8481328cfa20a43b67abd5455c2e34fd42639e0b /include/cru
parent57353bd3acd97957cb5f970016fec52977cc6e95 (diff)
downloadcru-14e1b0f188d302b69816ddf12f5ac591fd76b91d.tar.gz
cru-14e1b0f188d302b69816ddf12f5ac591fd76b91d.tar.bz2
cru-14e1b0f188d302b69816ddf12f5ac591fd76b91d.zip
...
Diffstat (limited to 'include/cru')
-rw-r--r--include/cru/xml/XmlNode.h25
1 files changed, 24 insertions, 1 deletions
diff --git a/include/cru/xml/XmlNode.h b/include/cru/xml/XmlNode.h
index 737a2d87..2f46459a 100644
--- a/include/cru/xml/XmlNode.h
+++ b/include/cru/xml/XmlNode.h
@@ -12,12 +12,13 @@
namespace cru::xml {
class XmlElementNode;
class XmlTextNode;
+class XmlCommentNode;
class CRU_XML_API XmlNode {
friend XmlElementNode;
public:
- enum class Type { Text, Element };
+ enum class Type { Text, Element, Comment };
protected:
explicit XmlNode(Type type) : type_(type) {}
@@ -35,11 +36,14 @@ class CRU_XML_API XmlNode {
bool IsTextNode() const { return type_ == Type::Text; }
bool IsElementNode() const { return type_ == Type::Element; }
+ bool IsCommentNode() const { return type_ == Type::Comment; }
XmlElementNode* AsElement();
XmlTextNode* AsText();
+ XmlCommentNode* AsComment();
const XmlElementNode* AsElement() const;
const XmlTextNode* AsText() const;
+ const XmlCommentNode* AsComment() const;
private:
const Type type_;
@@ -132,4 +136,23 @@ class CRU_XML_API XmlElementNode : public XmlNode {
std::vector<XmlNode*> children_;
};
+class CRU_XML_API XmlCommentNode : public XmlNode {
+ public:
+ XmlCommentNode() : XmlNode(Type::Comment) {}
+ explicit XmlCommentNode(String text)
+ : XmlNode(Type::Comment), text_(std::move(text)) {}
+
+ CRU_DELETE_COPY(XmlCommentNode)
+ CRU_DELETE_MOVE(XmlCommentNode)
+
+ ~XmlCommentNode() override;
+
+ String GetText() const { return text_; }
+ void SetText(String text) { text_ = std::move(text); }
+
+ XmlNode* Clone() const override;
+
+ private:
+ String text_;
+};
} // namespace cru::xml