/*
* Author:          Patrick-Christopher Mattulat
* Co-Author:       Claude Sonnet 4.6 (LLM)
* Company:         Lynar Studios
* E-Mail:          webmaster@lynarstudios.com
* Created:         2023-02-08
* Changed:         2026-06-23
*
* */

#ifndef LS_STD_SECTION_PAIR_ROW_HPP
#define LS_STD_SECTION_PAIR_ROW_HPP

#include <ls-std/core/Class.hpp>
#include <ls-std/core/interface/ISerializable.hpp>
#include <ls-std/io/section-pair/SectionPairRowEnumType.hpp>
#include <ls-std/io/section-pair/SectionPairTypes.hpp>
#include <ls-std/io/section-pair/model/SectionPairRowValue.hpp>
#include <ls-std/os/dynamic-goal.hpp>
#include <memory>
#include <string>
#include <string_view>

/*
 * @doc: class(name: 'SectionPairRow', package: 'io')
 * @doc: io.SectionPairRow.description('This class represents a Section Pair row.')
 * */

namespace ls::standard::io
{
  class LS_STD_DYNAMIC_GOAL SectionPairRow : public ::std::enable_shared_from_this<SectionPairRow>, public ls::standard::core::Class, public ls::standard::core::interface_type::ISerializable
  {
    public:

      explicit SectionPairRow(const ls::standard::io::section_pair_identifier &_key, const ls::standard::io::SectionPairRowEnumType &_type);
      ~SectionPairRow() noexcept override;

      [[nodiscard]] ls::standard::io::section_pair_identifier getKey() const;
      [[nodiscard]] ::std::shared_ptr<ls::standard::io::SectionPairRowValue> getValue() const;
      [[nodiscard]] bool isList() const;
      [[nodiscard]] bool isSingleValue() const;
      [[nodiscard]] ls::standard::core::type::byte_field marshal() override;
      void reserveNewLine(::std::string_view _reservedNewLine);
      void setKey(const ls::standard::io::section_pair_identifier &_key);
      void unmarshal(const ls::standard::core::type::byte_field &_data) override;

    private:

      ls::standard::io::section_pair_identifier key{};
      ::std::string reservedNewLine{};
      ::std::shared_ptr<ls::standard::core::interface_type::ISerializable> serializable{};
      ::std::shared_ptr<ls::standard::io::SectionPairRowValue> value{};

      void _createSerializable();
      void _initValue(const ls::standard::io::SectionPairRowEnumType &_type);
      void _setKey(const ls::standard::io::section_pair_identifier &_key);
  };
}

#endif
