/*
* 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-23
*
* */

#include <ls-std/io/section-pair/validator/SectionPairFileExtensionValidator.hpp>

using ls::standard::core::Class;
using ls::standard::io::SectionPairFileExtensionValidator;
using std::move;
using std::string;

SectionPairFileExtensionValidator::SectionPairFileExtensionValidator(string _fileName) : Class("SectionPairFileExtensionValidator"), fileName(::move(_fileName))
{}

SectionPairFileExtensionValidator::~SectionPairFileExtensionValidator() noexcept = default;

bool SectionPairFileExtensionValidator::isValid()
{
  const string textFileExtension = ".txt";
  const string sectionPairFileExtension = ".sp";
  const bool endsWithTextFileExtension = this->fileName.rfind(textFileExtension) == (this->fileName.size() - textFileExtension.size());
  const bool endsWithSectionPairFileExtension = this->fileName.rfind(sectionPairFileExtension) == (this->fileName.size() - sectionPairFileExtension.size());

  return endsWithTextFileExtension || endsWithSectionPairFileExtension;
}
