diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/xml/CMakeLists.txt | 5 | ||||
-rw-r--r-- | src/xml/XmlNode.cpp | 14 | ||||
-rw-r--r-- | src/xml/XmlParser.cpp | 27 |
3 files changed, 46 insertions, 0 deletions
diff --git a/src/xml/CMakeLists.txt b/src/xml/CMakeLists.txt index e69de29b..20e889ec 100644 --- a/src/xml/CMakeLists.txt +++ b/src/xml/CMakeLists.txt @@ -0,0 +1,5 @@ +add_library(cru_xml SHARED + XmlNode.cpp + XmlParser.cpp +) +target_link_libraries(cru_xml PUBLIC cru_base) diff --git a/src/xml/XmlNode.cpp b/src/xml/XmlNode.cpp new file mode 100644 index 00000000..cfeb5cf9 --- /dev/null +++ b/src/xml/XmlNode.cpp @@ -0,0 +1,14 @@ +#include "cru/xml/XmlNode.hpp" + +namespace cru::xml { +bool operator==(const XmlNode& lhs, const XmlNode& rhs) { + return lhs.GetType() == rhs.GetType() && lhs.GetText() == rhs.GetText() && + lhs.GetTag() == rhs.GetTag() && + lhs.GetAttributes() == rhs.GetAttributes() && + lhs.GetChildren() == rhs.GetChildren(); +} + +bool operator!=(const XmlNode& lhs, const XmlNode& rhs) { + return !(lhs == rhs); +} +} // namespace cru::xml diff --git a/src/xml/XmlParser.cpp b/src/xml/XmlParser.cpp new file mode 100644 index 00000000..23407d11 --- /dev/null +++ b/src/xml/XmlParser.cpp @@ -0,0 +1,27 @@ +#include "cru/xml/XmlParser.hpp" + +namespace cru::xml { +XmlNode XmlParser::Parse() { + if (!root_node_) { + root_node_ = DoParse(); + } + return *root_node_; +} + +XmlNode XmlParser::DoParse() { + XmlNode root(XmlNode::Type::Element); + XmlNode* current = &root; + int current_position = 0; + + // TODO: Implement this. + while (current_position < xml_.size()) { + switch (xml_[current_position]) { + case '<': { + break; + } + } + } + + return root; +} +} // namespace cru::xml |