tool-regex.h 761 B

123456789101112131415161718192021222324
  1. #ifndef AFUN_TOOL_REGEX
  2. #define AFUN_TOOL_REGEX
  3. #define PCRE2_CODE_UNIT_WIDTH 8
  4. #include "pcre2.h"
  5. namespace aFuntool {
  6. class AFUN_TOOL_EXPORT Regex { // 整个对象都是inline的, 不需要Export符号
  7. pcre2_code *re; // 正则表达式
  8. std::string pattern; // 正则表达式的字符串
  9. public:
  10. explicit Regex(std::string pattern_) noexcept(false);
  11. inline Regex(const Regex &regex) noexcept;
  12. inline Regex(Regex &&regex) noexcept;
  13. inline ~Regex() noexcept;
  14. Regex &operator=(const Regex &regex)=delete;
  15. Regex &operator=(Regex &&regex)=delete;
  16. [[nodiscard]] bool match(const std::string &subject) const;
  17. };
  18. }
  19. #include "tool-regex.inline.h"
  20. #endif //AFUN_TOOL_REGEX