SerializableSectionPairSection.hpp 2.8 KB

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