regex.h 751 B

123456789101112131415161718192021222324252627282930
  1. #ifndef AFUN_REGEX
  2. #define AFUN_REGEX
  3. #define PCRE2_CODE_UNIT_WIDTH 8
  4. #include "pcre2.h"
  5. #include "aFunToolExport.h"
  6. namespace aFuntool {
  7. const int REGEX_ERROR_SIZE = 512;
  8. class AFUN_TOOL_EXPORT Regex {
  9. pcre2_code *re; // 正则表达式
  10. const std::string pattern; // 正则表达式的字符串
  11. public:
  12. explicit Regex(std::string pattern_);
  13. Regex(const Regex &regex);
  14. inline Regex(Regex &&regex) noexcept;
  15. Regex &operator=(const Regex &regex)=delete;
  16. Regex &operator=(Regex &&regex)=delete;
  17. ~Regex();
  18. int match(const char *subject) const;
  19. inline int match(const std::string &subject) const;
  20. };
  21. }
  22. #include "regex.inline.h"
  23. #endif //AFUN_REGEX