SerializableSectionPairSection.hpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Co-Author: Claude Sonnet 4.6 (LLM)
  4. * Company: Lynar Studios
  5. * E-Mail: webmaster@lynarstudios.com
  6. * Created: 2023-02-14
  7. * Changed: 2026-06-23
  8. *
  9. * */
  10. #ifndef LS_STD_SERIALIZABLE_SECTION_PAIR_SECTION_HPP
  11. #define LS_STD_SERIALIZABLE_SECTION_PAIR_SECTION_HPP
  12. #include "SerializableSectionPairParameter.hpp"
  13. #include <ls-std/core/Class.hpp>
  14. #include <ls-std/core/interface/ISerializable.hpp>
  15. #include <ls-std/io/section-pair/SectionPairRowEnumType.hpp>
  16. #include <ls-std/os/dynamic-goal.hpp>
  17. #include <string_view>
  18. /*
  19. * @doc: class(name: 'SerializableSectionPairSection', package: 'io')
  20. * @doc: io.SerializableSectionPairSection.description('This class can serialize a Section Pair section for file persistence.')
  21. * */
  22. namespace ls::standard::io
  23. {
  24. class LS_STD_DYNAMIC_GOAL SerializableSectionPairSection : public ls::standard::core::interface_type::ISerializable, public ls::standard::core::Class
  25. {
  26. public:
  27. explicit SerializableSectionPairSection(const ls::standard::io::SerializableSectionPairParameter &_parameter);
  28. ~SerializableSectionPairSection() noexcept override;
  29. [[nodiscard]] ::std::shared_ptr<ls::standard::core::Class> getValue() const;
  30. [[nodiscard]] ls::standard::core::type::byte_field marshal() override;
  31. void unmarshal(const ls::standard::core::type::byte_field &_data) override;
  32. private:
  33. ls::standard::io::SerializableSectionPairParameter parameter{};
  34. [[nodiscard]] ls::standard::core::type::byte_field _collectSectionRow(const ls::standard::core::type::byte_field &_currentRows, ls::standard::io::SectionPairRowEnumType &_type) const;
  35. [[nodiscard]] ls::standard::core::type::byte_field _collectSectionListValueRow(const core::type::byte_field &_currentRows, ls::standard::io::SectionPairRowEnumType &_type) const;
  36. [[nodiscard]] static core::type::byte_field _collectSectionSingleValueRow(const ls::standard::core::type::byte_field &_firstRow, ls::standard::io::SectionPairRowEnumType &type);
  37. [[nodiscard]] static size_t _getNthSubStringPosition(::std::string_view _text, ::std::string_view _subText);
  38. [[nodiscard]] ls::standard::core::type::byte_field _getSectionHeader(const ls::standard::core::type::byte_field &_data) const;
  39. [[nodiscard]] static ls::standard::core::type::byte_field _getSectionId(::std::string_view _sectionHeader);
  40. [[nodiscard]] static bool _isListValueRow(::std::string_view _currentRow);
  41. [[nodiscard]] static bool _isStartingValueRow(const ::std::string &_currentRow);
  42. [[nodiscard]] static bool _isSingleValueRow(::std::string_view _currentRow);
  43. [[nodiscard]] ls::standard::core::type::byte_field _marshalRows() const;
  44. [[nodiscard]] ls::standard::core::type::byte_field _marshalSectionId() const;
  45. void _unmarshalRow(const ::std::string &_sectionRow, ls::standard::io::SectionPairRowEnumType _type) const;
  46. void _unmarshalRows(const ls::standard::core::type::byte_field &_serializedRows) const;
  47. [[nodiscard]] size_t _unmarshalSectionHeader(const ls::standard::core::type::byte_field &_data) const;
  48. };
  49. }
  50. #endif