aboutsummaryrefslogtreecommitdiff
path: root/include/cru
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
parent96a93e17baaff2c2050eba2afada639e93001232 (diff)
downloadcru-18099ad8f5c24b1c2b1c92238dbc54912eab0406.tar.gz
cru-18099ad8f5c24b1c2b1c92238dbc54912eab0406.tar.bz2
cru-18099ad8f5c24b1c2b1c92238dbc54912eab0406.zip
...
Diffstat (limited to 'include/cru')
-rw-r--r--include/cru/common/String.hpp7
-rw-r--r--include/cru/common/StringUtil.hpp2
-rw-r--r--include/cru/xml/XmlNode.hpp3
-rw-r--r--include/cru/xml/XmlParser.hpp4
4 files changed, 14 insertions, 2 deletions
diff --git a/include/cru/common/String.hpp b/include/cru/common/String.hpp
index ade2d84b..bd079243 100644
--- a/include/cru/common/String.hpp
+++ b/include/cru/common/String.hpp
@@ -165,6 +165,10 @@ class CRU_BASE_API String {
}
inline void append(StringView str);
+ String substr(size_type start, size_type size) const {
+ return String(this->buffer_ + start, size);
+ }
+
public:
String& operator+=(value_type value) {
this->append(value);
@@ -177,6 +181,9 @@ class CRU_BASE_API String {
}
public:
+ String& TrimEnd();
+
+ public:
void AppendCodePoint(CodePoint code_point);
Utf16CodePointIterator CodePointIterator() const {
diff --git a/include/cru/common/StringUtil.hpp b/include/cru/common/StringUtil.hpp
index 6c6b47b8..a35da695 100644
--- a/include/cru/common/StringUtil.hpp
+++ b/include/cru/common/StringUtil.hpp
@@ -221,4 +221,6 @@ Index CRU_BASE_API Utf16NextWord(const char16_t* ptr, Index size,
char16_t CRU_BASE_API ToLower(char16_t c);
char16_t CRU_BASE_API ToUpper(char16_t c);
+
+char16_t CRU_BASE_API IsWhitespace(char16_t c);
} // namespace cru
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;