SectionPairRowValueValidator.cpp 1.2 KB

12345678910111213141516171819202122232425262728
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-02-09
  6. * Changed: 2023-02-18
  7. *
  8. * */
  9. #include <ls-std/io/NewLine.hpp>
  10. #include <ls-std/io/section-pair/validator/SectionPairRowValueValidator.hpp>
  11. #include <regex>
  12. ls::std::io::SectionPairRowValueValidator::SectionPairRowValueValidator(ls::std::io::section_pair_row_value _value) : ls::std::core::Class("SectionPairRowValueValidator"), value(::std::move(_value))
  13. {}
  14. ls::std::io::SectionPairRowValueValidator::~SectionPairRowValueValidator() = default;
  15. bool ls::std::io::SectionPairRowValueValidator::isValid()
  16. {
  17. static ::std::regex windowsLineBreakRegex{ls::std::io::NewLine::getWindowsNewLine()};
  18. static ::std::regex unixLineBreakRegex{ls::std::io::NewLine::getUnixNewLine()};
  19. this->value = ::std::regex_replace(this->value, windowsLineBreakRegex, "");
  20. this->value = ::std::regex_replace(this->value, unixLineBreakRegex, "");
  21. size_t foundPosition = this->value.find_first_not_of("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789_#![]{}()/$ۤ%?<>+:;., *\"");
  22. return foundPosition == ls::std::io::section_pair_row_value::npos;
  23. }