tool-regex.h 795 B

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