SectionPairSection.hpp 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-02-13
  6. * Changed: 2024-09-13
  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. #include <string_view>
  20. /*
  21. * @doc: class(name: 'SectionPairSection', package: 'io')
  22. * @doc: io.SectionPairSection.description('This class represents a Section Pair section.')
  23. * */
  24. namespace ls::std::io
  25. {
  26. 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
  27. {
  28. public:
  29. explicit SectionPairSection(const ls::std::io::section_pair_identifier &_sectionId);
  30. ~SectionPairSection() noexcept override;
  31. void add(const ls::std::io::section_pair_row_list_element &_row);
  32. void clear();
  33. [[nodiscard]] ls::std::io::section_pair_row_list_element get(size_t _index) const;
  34. [[nodiscard]] ls::std::io::section_pair_row_list_element get(const ls::std::io::section_pair_identifier &_key) const;
  35. [[nodiscard]] ls::std::io::section_pair_row_list getList() const;
  36. [[nodiscard]] size_t getRowAmount() const;
  37. [[nodiscard]] ls::std::io::section_pair_identifier getSectionId() const;
  38. [[nodiscard]] bool hasRow(const ls::std::io::section_pair_identifier &_key);
  39. [[nodiscard]] ls::std::core::type::byte_field marshal() override;
  40. void reserveNewLine(::std::string_view _reservedNewLine);
  41. void setSectionId(const ls::std::io::section_pair_identifier &_sectionId);
  42. void unmarshal(const ls::std::core::type::byte_field &_data) override;
  43. private:
  44. ::std::string reservedNewLine{};
  45. ls::std::io::section_pair_row_list rows{};
  46. ls::std::io::section_pair_identifier sectionId{};
  47. ::std::shared_ptr<ls::std::core::interface_type::ISerializable> serializable{};
  48. void _createSerializable();
  49. [[nodiscard]] ls::std::io::section_pair_row_list_element _get(const ls::std::io::section_pair_identifier &_key) const;
  50. [[nodiscard]] bool _hasRow(const ls::std::io::section_pair_identifier &_key);
  51. void _rowExistenceCheck(const ls::std::io::section_pair_identifier &_key);
  52. void _setSectionId(const ls::std::io::section_pair_identifier &_sectionId);
  53. };
  54. }
  55. #endif