SectionPairDocument.hpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-02-15
  6. * Changed: 2023-02-16
  7. *
  8. * */
  9. #ifndef LS_STD_SECTION_PAIR_DOCUMENT_HPP
  10. #define LS_STD_SECTION_PAIR_DOCUMENT_HPP
  11. #include <ls-std/core/Class.hpp>
  12. #include <ls-std/core/interface/ISerializable.hpp>
  13. #include <ls-std/io/section-pair/SectionPairTypes.hpp>
  14. #include <ls-std/io/section-pair/type/SectionPairDocumentTypes.hpp>
  15. #include <ls-std/os/dynamic-goal.hpp>
  16. #include <memory>
  17. namespace ls::std::io
  18. {
  19. class LS_STD_DYNAMIC_GOAL SectionPairDocument : public ::std::enable_shared_from_this<SectionPairDocument>, public ls::std::core::Class, public ls::std::core::interface_type::ISerializable
  20. {
  21. public:
  22. SectionPairDocument();
  23. ~SectionPairDocument() override;
  24. void add(const section_pair_document_section_list_element &_section);
  25. [[nodiscard]] section_pair_document_section_list_element get(size_t _index);
  26. [[nodiscard]] size_t getAmountOfSections();
  27. [[nodiscard]] ::std::string getHeader();
  28. [[nodiscard]] section_pair_document_section_list getSectionList();
  29. [[nodiscard]] ls::std::core::type::byte_field marshal() override;
  30. void unmarshal(const ls::std::core::type::byte_field &_data) override;
  31. private:
  32. const ::std::string header = "# section-pair document";
  33. ls::std::io::section_pair_document_section_list sections{};
  34. ::std::shared_ptr<ls::std::core::interface_type::ISerializable> serializable{};
  35. void _checkSectionExistence(const ls::std::io::section_pair_identifier &_sectionId);
  36. void _createSerializable();
  37. [[nodiscard]] bool _hasSection(const ls::std::io::section_pair_identifier &_identifier);
  38. };
  39. }
  40. #endif