SectionPairSection.hpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-02-13
  6. * Changed: 2023-02-23
  7. *
  8. * */
  9. #ifndef LS_STD_SECTION_PAIR_SECTION_HPP
  10. #define LS_STD_SECTION_PAIR_SECTION_HPP
  11. #include <list>
  12. #include <ls-std/core/Class.hpp>
  13. #include <ls-std/core/interface/ISerializable.hpp>
  14. #include <ls-std/io/section-pair/SectionPairTypes.hpp>
  15. #include <ls-std/io/section-pair/type/SectionPairSectionTypes.hpp>
  16. #include <ls-std/os/dynamic-goal.hpp>
  17. #include <memory>
  18. #include <string>
  19. namespace ls::std::io
  20. {
  21. class LS_STD_DYNAMIC_GOAL SectionPairSection : public ::std::enable_shared_from_this<SectionPairSection>, public ls::std::core::Class, public ls::std::core::interface_type::ISerializable
  22. {
  23. public:
  24. explicit SectionPairSection(const ls::std::io::section_pair_identifier &_sectionId);
  25. ~SectionPairSection() noexcept override;
  26. void add(const ls::std::io::section_pair_row_list_element &_row);
  27. void clear();
  28. [[nodiscard]] ls::std::io::section_pair_row_list_element get(size_t _index);
  29. [[nodiscard]] ls::std::io::section_pair_row_list_element get(const ls::std::io::section_pair_identifier &_key);
  30. [[nodiscard]] ls::std::io::section_pair_row_list getList();
  31. [[nodiscard]] size_t getRowAmount();
  32. [[nodiscard]] ls::std::io::section_pair_identifier getSectionId();
  33. [[nodiscard]] bool hasRow(const ls::std::io::section_pair_identifier &_key);
  34. [[nodiscard]] ls::std::core::type::byte_field marshal() override;
  35. void reserveNewLine(const ::std::string &_reservedNewLine);
  36. void setSectionId(const ls::std::io::section_pair_identifier &_sectionId);
  37. void unmarshal(const ls::std::core::type::byte_field &_data) override;
  38. private:
  39. ::std::string reservedNewLine{};
  40. ls::std::io::section_pair_row_list rows{};
  41. ls::std::io::section_pair_identifier sectionId{};
  42. ::std::shared_ptr<ls::std::core::interface_type::ISerializable> serializable{};
  43. void _createSerializable();
  44. [[nodiscard]] ls::std::io::section_pair_row_list_element _get(const ls::std::io::section_pair_identifier &_key);
  45. [[nodiscard]] bool _hasRow(const ls::std::io::section_pair_identifier &_key);
  46. void _rowExistenceCheck(const ls::std::io::section_pair_identifier &_key);
  47. void _setSectionId(const ls::std::io::section_pair_identifier &_sectionId);
  48. };
  49. }
  50. #endif