SectionPairIdentifierArgumentEvaluator.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  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-23
  7. *
  8. * */
  9. #include <ls-std/core/exception/IllegalArgumentException.hpp>
  10. #include <ls-std/io/section-pair/SectionPairMessageFormatter.hpp>
  11. #include <ls-std/io/section-pair/evaluator/SectionPairIdentifierArgumentEvaluator.hpp>
  12. #include <ls-std/io/section-pair/validator/SectionPairIdentifierValidator.hpp>
  13. #include <string>
  14. using ls::std::core::Class;
  15. using ls::std::core::IllegalArgumentException;
  16. using ls::std::io::section_pair_identifier;
  17. using ls::std::io::SectionPairIdentifierArgumentEvaluator;
  18. using ls::std::io::SectionPairIdentifierValidator;
  19. using ls::std::io::SectionPairMessageFormatter;
  20. using std::move;
  21. using std::string;
  22. SectionPairIdentifierArgumentEvaluator::SectionPairIdentifierArgumentEvaluator(section_pair_identifier _identifier) : Class("SectionPairIdentifierArgumentEvaluator"), identifier(::move(_identifier))
  23. {}
  24. SectionPairIdentifierArgumentEvaluator::~SectionPairIdentifierArgumentEvaluator() noexcept = default;
  25. void SectionPairIdentifierArgumentEvaluator::evaluate()
  26. {
  27. if (!SectionPairIdentifierValidator{this->identifier}.isValid())
  28. {
  29. string message = "\"" + this->identifier + "\" is not a valid identifier!";
  30. throw IllegalArgumentException{SectionPairMessageFormatter::getFormattedMessage(message)};
  31. }
  32. }