SerializableSectionPairSection.hpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-02-14
  6. * Changed: 2023-02-15
  7. *
  8. * */
  9. #ifndef LS_STD_SERIALIZABLE_SECTION_PAIR_SECTION_HPP
  10. #define LS_STD_SERIALIZABLE_SECTION_PAIR_SECTION_HPP
  11. #include <ls-std/core/Class.hpp>
  12. #include <ls-std/core/interface/ISerializable.hpp>
  13. #include <ls-std/io/section-pair/SectionPairRowEnumType.hpp>
  14. #include <ls-std/os/dynamic-goal.hpp>
  15. namespace ls::std::io
  16. {
  17. class LS_STD_DYNAMIC_GOAL SerializableSectionPairSection : public ls::std::core::interface_type::ISerializable
  18. {
  19. public:
  20. explicit SerializableSectionPairSection(const ::std::shared_ptr<ls::std::core::Class> &_value);
  21. ~SerializableSectionPairSection() override;
  22. [[nodiscard]] ::std::shared_ptr<ls::std::core::Class> getValue();
  23. [[nodiscard]] ls::std::core::type::byte_field marshal() override;
  24. void unmarshal(const ls::std::core::type::byte_field &_data) override;
  25. private:
  26. ::std::shared_ptr<ls::std::core::Class> value{};
  27. static void _checkSectionHeader(const ls::std::core::type::byte_field &_sectionHeader);
  28. [[nodiscard]] static ls::std::core::type::byte_field _collectSectionRow(const ls::std::core::type::byte_field &_currentRows, ls::std::io::SectionPairRowEnumType &_type);
  29. [[nodiscard]] static core::type::byte_field _collectSectionListValueRow(const core::type::byte_field &_currentRows, SectionPairRowEnumType &_type);
  30. [[nodiscard]] static core::type::byte_field _collectSectionSingleValueRow(const ls::std::core::type::byte_field &_firstRow, SectionPairRowEnumType &type);
  31. [[nodiscard]] static size_t _getNthSubStringPosition(const ls::std::core::type::byte_field &_text, const ls::std::core::type::byte_field &_subText);
  32. [[nodiscard]] static ls::std::core::type::byte_field _getSectionHeader(const ls::std::core::type::byte_field &_data);
  33. [[nodiscard]] static ls::std::core::type::byte_field _getSectionId(const ls::std::core::type::byte_field &_sectionHeader);
  34. [[nodiscard]] static bool _isListValueRow(const ::std::string &_currentRow);
  35. [[nodiscard]] static bool _isStartingValueRow(const ::std::string &_currentRow);
  36. [[nodiscard]] static bool _isSingleValueRow(const ::std::string &_currentRow);
  37. [[nodiscard]] ls::std::core::type::byte_field _marshalRows();
  38. [[nodiscard]] ls::std::core::type::byte_field _marshalSectionId();
  39. void _setValue(const ::std::shared_ptr<ls::std::core::Class> &_value);
  40. void _unmarshalRow(const ::std::string &_sectionRow, ls::std::io::SectionPairRowEnumType _type);
  41. void _unmarshalRows(const ls::std::core::type::byte_field &_serializedRows);
  42. [[nodiscard]] size_t _unmarshalSectionHeader(const ls::std::core::type::byte_field &_data);
  43. };
  44. }
  45. #endif