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

#ifndef LS_STD_SECTION_PAIR_FILE_READER_HPP
#define LS_STD_SECTION_PAIR_FILE_READER_HPP

#include "SectionPairFileReaderParameter.hpp"
#include <ls-std/core/Class.hpp>
#include <ls-std/core/interface/IReader.hpp>
#include <ls-std/os/dynamic-goal.hpp>
#include <memory>

/*
 * @doc: class(name: 'SectionPairFileReader', package: 'io')
 * @doc: io.SectionPairFileReader.description('This class reads a Section Pair file and writes it to a Section Pair document instance.')
 * */

namespace ls::standard::io
{
  class LS_STD_DYNAMIC_GOAL SectionPairFileReader : public ls::standard::core::Class, public ls::standard::core::interface_type::IReader
  {
    public:

      explicit SectionPairFileReader(const ls::standard::io::SectionPairFileReaderParameter &_parameter);
      ~SectionPairFileReader() noexcept override;

      [[nodiscard]] ::std::shared_ptr<ls::standard::io::SectionPairDocument> getDocument() const;
      ls::standard::core::type::byte_field read() override; // nodiscard is optional here

    private:

      ls::standard::io::SectionPairFileReaderParameter parameter{};

      void _checkFileExtension() const;
      void _createDocument();
      void _createFileExistenceEvaluator();
      void _createReader();
      [[nodiscard]] static ::std::string _detectNewLine(const ls::standard::core::type::byte_field &_data);
  };
}

#endif
