/* * Author: Patrick-Christopher Mattulat * Company: Lynar Studios * E-Mail: webmaster@lynarstudios.com * Created: 2020-09-24 * Changed: 2021-05-02 * * */ #ifndef LS_STD_XML_NODE_HPP #define LS_STD_XML_NODE_HPP #include #include #include #include "XmlAttribute.hpp" namespace ls_std { class XmlNode : public ls_std::Class { public: explicit XmlNode(std::string _name); ~XmlNode() override = default; bool addAttributeAfter(const std::shared_ptr &_attribute, const std::string &_name); bool addAttributeBefore(const std::shared_ptr &_attribute, const std::string &_name); bool addAttributeToBeginning(const std::shared_ptr &_attribute); bool addAttributeToEnd(const std::shared_ptr &_attribute); bool addChildAfter(const std::shared_ptr &_child, const std::shared_ptr &_search); bool addChildBefore(const std::shared_ptr &_child, const std::shared_ptr &_search); bool addChildToBeginning(const std::shared_ptr &_child); bool addChildToEnd(const std::shared_ptr &_child); void clearValue(); std::list> getAttributes(); std::list> getChildren(); std::list> getChildren(const std::string &_name); std::string getName(); std::string getValue(); bool hasAttribute(const std::string &_name); bool hasChild(const std::string &_name); bool hasChild(const std::shared_ptr &_child); void removeFirstAttribute(); void removeLastAttribute(); void removeFirstChild(); void removeLastChild(); void setName(std::string _name); void setValue(std::string _value); std::string toXml(); protected: std::string _toXml_(uint8_t _tabSize); private: std::list> attributes{}; std::list> children{}; std::string name{}; const static uint8_t TAB_SIZE{4}; std::string value{}; static std::string _getTab(uint8_t _tabSize); bool _hasAttribute(const std::string &_name); bool _hasChild(const std::shared_ptr &_child); bool _hasChild(const std::string &_name); std::string _toXmlAttributes(); std::string _toXmlChildren(uint8_t _tabSize); std::string _toXmlCloseTag(); std::string _toXmlOpenTag(); std::string _toXmlOpenTagClose(); std::string _toXmlValue(); }; } #endif