SectionPairRow.hpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-02-08
  6. * Changed: 2023-05-18
  7. *
  8. * */
  9. #ifndef LS_STD_SECTION_PAIR_ROW_HPP
  10. #define LS_STD_SECTION_PAIR_ROW_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/io/section-pair/SectionPairTypes.hpp>
  15. #include <ls-std/io/section-pair/model/SectionPairRowValue.hpp>
  16. #include <ls-std/os/dynamic-goal.hpp>
  17. #include <memory>
  18. #include <string>
  19. #include <string_view>
  20. namespace ls::std::io
  21. {
  22. class LS_STD_DYNAMIC_GOAL SectionPairRow : public ::std::enable_shared_from_this<SectionPairRow>, public ls::std::core::Class, public ls::std::core::interface_type::ISerializable
  23. {
  24. public:
  25. explicit SectionPairRow(const ls::std::io::section_pair_identifier &_key, const ls::std::io::SectionPairRowEnumType &_type);
  26. ~SectionPairRow() noexcept override;
  27. [[nodiscard]] ls::std::io::section_pair_identifier getKey() const;
  28. [[nodiscard]] ::std::shared_ptr<ls::std::io::SectionPairRowValue> getValue() const;
  29. [[nodiscard]] bool isList() const;
  30. [[nodiscard]] bool isSingleValue() const;
  31. [[nodiscard]] ls::std::core::type::byte_field marshal() override;
  32. void reserveNewLine(::std::string_view _reservedNewLine);
  33. void setKey(const ls::std::io::section_pair_identifier &_key);
  34. void unmarshal(const ls::std::core::type::byte_field &_data) override;
  35. private:
  36. ls::std::io::section_pair_identifier key{};
  37. ::std::string reservedNewLine{};
  38. ::std::shared_ptr<ls::std::core::interface_type::ISerializable> serializable{};
  39. ::std::shared_ptr<ls::std::io::SectionPairRowValue> value{};
  40. void _createSerializable();
  41. void _initValue(const ls::std::io::SectionPairRowEnumType &_type);
  42. void _setKey(const ls::std::io::section_pair_identifier &_key);
  43. };
  44. }
  45. #endif