tool-regex.inline.h 795 B

1234567891011121314151617181920212223242526272829
  1. #ifndef AFUN_TOOL_REGEX_INLINE_H
  2. #define AFUN_TOOL_REGEX_INLINE_H
  3. #include "tool-regex.h"
  4. namespace aFuntool {
  5. inline Regex::Regex(std::string pattern_) : re{pattern_}, pattern{std::move(pattern_)} {
  6. if (!isCharUTF8(pattern))
  7. throw RegexException("Pattern not utf-8");
  8. }
  9. inline Regex::Regex(const Regex &regex) noexcept: re{regex.pattern}, pattern{regex.pattern}{
  10. }
  11. inline Regex::Regex(Regex &&regex) noexcept : pattern {std::move(regex.pattern)}, re {std::move(regex.re)} {
  12. }
  13. inline bool Regex::match(const char *subject) const{
  14. return std::regex_match(subject, re);
  15. }
  16. inline bool Regex::match(const std::string &subject) const {
  17. return std::regex_match(subject, re);
  18. }
  19. }
  20. #endif //AFUN_TOOL_REGEX_INLINE_H