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

#include <ls-std/io/section-pair/validator/SectionPairRowListValueValidator.hpp>
#include <ls-std/io/section-pair/validator/SectionPairRowSingleValueValidator.hpp>
#include <ls-std/io/section-pair/validator/SectionPairRowValidator.hpp>
#include <regex>

using ls::standard::core::Class;
using ls::standard::io::SectionPairRowListValueValidator;
using ls::standard::io::SectionPairRowValidator;
using std::move;
using std::regex;
using std::regex_match;
using std::string;

SectionPairRowValidator::SectionPairRowValidator(string _row) : Class("SectionPairRowValidator"), row(::move(_row))
{}

SectionPairRowValidator::~SectionPairRowValidator() noexcept = default;

string SectionPairRowValidator::getValidationRegex()
{
  return _getValidationRegex();
}

bool SectionPairRowValidator::isValid()
{
  const string validationRegex = _getValidationRegex();
  static auto sectionPairRowRegex = regex{R"(^()" + validationRegex + R"())"};

  return regex_match(this->row, sectionPairRowRegex);
}

string SectionPairRowValidator::_getValidationRegex()
{
  const string listValueRowRegex = SectionPairRowListValueValidator::getValidationRegex();
  const string singleValueRowRegex = SectionPairRowSingleValueValidator::getValidationRegex();

  return R"(()" + singleValueRowRegex + R"()|()" + listValueRowRegex + R"())";
}
