/* * Author: Patrick-Christopher Mattulat * Company: Lynar Studios * E-Mail: webmaster@lynarstudios.com * Created: 2023-02-19 * Changed: 2023-05-18 * * */ #include #include #include #include using ls::std::core::Class; using ls::std::io::SectionPairIdentifierValidator; using ls::std::io::SectionPairRowListValueValidator; using ls::std::io::SectionPairValueValidator; using std::move; using std::regex; using std::regex_match; using std::string; SectionPairRowListValueValidator::SectionPairRowListValueValidator(string _listValueRow) : Class("SectionPairRowListValueValidator"), listValueRow(::move(_listValueRow)) {} SectionPairRowListValueValidator::~SectionPairRowListValueValidator() noexcept = default; string SectionPairRowListValueValidator::getValidationRegex() { return SectionPairRowListValueValidator::_getValidationRegex(); } bool SectionPairRowListValueValidator::isValid() { string validationRegex = SectionPairRowListValueValidator::_getValidationRegex(); static auto listValueRowRegex = regex{"^" + validationRegex}; return regex_match(this->listValueRow, listValueRowRegex); } string SectionPairRowListValueValidator::_getValidationRegex() { string identifierRegex = SectionPairIdentifierValidator::getValidationRegex(); string valueRegex = SectionPairValueValidator::getValidationRegex(); string lineBreak = R"(((\n{1})|(\r{1}\n{1})))"; string firstLine = R"(((()" + identifierRegex + R"():{1}))" + lineBreak + R"())"; return R"((()" + firstLine + R"(( {2})" + valueRegex + R"()" + lineBreak + R"()){1}(( {2})" + valueRegex + R"()" + lineBreak + R"()*)))"; }