SectionPairRowValidator.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-02-20
  6. * Changed: 2023-02-20
  7. *
  8. * */
  9. #include <ls-std/io/section-pair/validator/SectionPairRowListValueValidator.hpp>
  10. #include <ls-std/io/section-pair/validator/SectionPairRowSingleValueValidator.hpp>
  11. #include <ls-std/io/section-pair/validator/SectionPairRowValidator.hpp>
  12. #include <regex>
  13. ls::std::io::SectionPairRowValidator::SectionPairRowValidator(::std::string _row) : ls::std::core::Class("SectionPairRowValidator"), row(::std::move(_row))
  14. {}
  15. ls::std::io::SectionPairRowValidator::~SectionPairRowValidator() = default;
  16. ::std::string ls::std::io::SectionPairRowValidator::getValidationRegex()
  17. {
  18. return ls::std::io::SectionPairRowValidator::_getValidationRegex();
  19. }
  20. bool ls::std::io::SectionPairRowValidator::isValid()
  21. {
  22. ::std::string validationRegex = ls::std::io::SectionPairRowValidator::_getValidationRegex();
  23. static ::std::regex sectionPairRowRegex = ::std::regex{R"(^()" + validationRegex + R"())"};
  24. return ::std::regex_match(this->row, sectionPairRowRegex);
  25. }
  26. ::std::string ls::std::io::SectionPairRowValidator::_getValidationRegex()
  27. {
  28. ::std::string listValueRowRegex = ls::std::io::SectionPairRowListValueValidator::getValidationRegex();
  29. ::std::string singleValueRowRegex = ls::std::io::SectionPairRowSingleValueValidator::getValidationRegex();
  30. return R"(()" + singleValueRowRegex + R"()|()" + listValueRowRegex + R"())";
  31. }