XMLNode.hpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-09-24
  6. * Changed: 2020-09-25
  7. *
  8. * */
  9. #ifndef LS_STD_XML_NODE_HPP
  10. #define LS_STD_XML_NODE_HPP
  11. #include <list>
  12. #include <memory>
  13. #include "../../base/Class.hpp"
  14. #include "XMLAttribute.hpp"
  15. namespace ls_std {
  16. class XMLNode : public Class {
  17. public:
  18. explicit XMLNode(std::string _name);
  19. ~XMLNode() = default;
  20. bool addAttributeAfter(const std::shared_ptr<ls_std::XMLAttribute>& _attribute, const std::string& _name);
  21. bool addAttributeBefore(const std::shared_ptr<ls_std::XMLAttribute>& _attribute, const std::string& _name);
  22. bool addAttributeToBeginning(const std::shared_ptr<ls_std::XMLAttribute>& _attribute);
  23. bool addAttributeToEnd(const std::shared_ptr<ls_std::XMLAttribute>& _attribute);
  24. bool addChildAfter(const std::shared_ptr<XMLNode>& _child, const std::shared_ptr<XMLNode>& _search);
  25. bool addChildBefore(const std::shared_ptr<XMLNode>& _child, const std::shared_ptr<XMLNode>& _search);
  26. bool addChildToBeginning(const std::shared_ptr<XMLNode>& _child);
  27. bool addChildToEnd(const std::shared_ptr<XMLNode>& _child);
  28. std::list<std::shared_ptr<XMLAttribute>> getAttributes();
  29. std::list<std::shared_ptr<XMLNode>> getChildren();
  30. std::list<std::shared_ptr<XMLNode>> getChildren(const std::string& _name);
  31. std::string getName();
  32. bool hasAttribute(const std::string& _name);
  33. bool hasChild(const std::string& _name);
  34. bool hasChild(const std::shared_ptr<XMLNode>& _child);
  35. void removeFirstAttribute();
  36. void removeLastAttribute();
  37. void removeFirstChild();
  38. void removeLastChild();
  39. void setName(std::string _name);
  40. std::string toXML();
  41. private:
  42. std::list<std::shared_ptr<XMLAttribute>> attributes {};
  43. std::list<std::shared_ptr<XMLNode>> children {};
  44. std::string name {};
  45. bool _hasAttribute(const std::string& _name);
  46. bool _hasChild(const std::shared_ptr<XMLNode>& _child);
  47. bool _hasChild(const std::string& _name);
  48. };
  49. }
  50. #endif