iutest  1.17.99.14
iutest_regex.hpp
[詳解]
1 //======================================================================
2 //-----------------------------------------------------------------------
13 //-----------------------------------------------------------------------
14 //======================================================================
15 #ifndef INCG_IRIS_IUTEST_REGEX_HPP_1575CB44_189A_4248_B305_DB4882E3BFC2_
16 #define INCG_IRIS_IUTEST_REGEX_HPP_1575CB44_189A_4248_B305_DB4882E3BFC2_
17 
18 //======================================================================
19 // include
20 #if IUTEST_HAS_CXX_HDR_REGEX
21 # include <regex>
22 #endif
23 
24 namespace iutest {
25 namespace detail
26 {
27 
31 class iuFilterRegex
32 {
33  static bool match_impl(const char* begin, const char* end, const char* src);
34  static bool match_impl_list(const char* begin, const char* end, const char* src);
35 public:
36  static bool match(const char* regex, const char* src);
37 };
38 
39 #if IUTEST_HAS_CXX_HDR_REGEX
40 
44 class iuRegex
45 {
46 public:
47  iuRegex(const char* pattern) { Init(pattern); } // NOLINT
48  iuRegex(const ::std::string& pattern) { Init(pattern.c_str()); } // NOLINT
49  iuRegex(const iuRegex & rhs) : m_re(rhs.m_re), m_pattern(rhs.m_pattern) {}
50 public:
51  bool FullMatch(const char* str) const;
52  bool PartialMatch(const char* str) const;
53 
54  const char* pattern() const { return m_pattern.c_str(); }
55 
56 private:
57  void Init(const char* pattern);
58 
59 private:
60  ::std::regex m_re;
61  ::std::string m_pattern;
62 
64 };
65 
66 #endif
67 
68 } // end of namespace detail
69 
70 namespace internal
71 {
72 
73 #if IUTEST_HAS_CXX_HDR_REGEX
74 
75 class RE : public detail::iuRegex
76 {
77 public:
78  RE(const char* pattern) : detail::iuRegex(pattern) {} // NOLINT
79  RE(const ::std::string& pattern) : detail::iuRegex(pattern) {} // NOLINT
80 public:
81  static bool FullMatch(const ::std::string& str, const RE& re)
82  {
83  return FullMatch(str.c_str(), re);
84  }
85  static bool PartialMatch(const ::std::string& str, const RE& re)
86  {
87  return PartialMatch(str.c_str(), re);
88  }
89  static bool FullMatch(const char* str, const RE& re)
90  {
91  const detail::iuRegex& r = re;
92  return r.FullMatch(str);
93  }
94  static bool PartialMatch(const char* str, const RE& re)
95  {
96  const detail::iuRegex& r = re;
97  return r.PartialMatch(str);
98  }
99 };
100 
101 #endif
102 
103 } // end of namespace internal
104 } // end of namespace iutest
105 
106 #if !IUTEST_HAS_LIB
107 # include "../impl/iutest_regex.ipp" // IWYU pragma: export
108 #endif
109 
110 #endif // INCG_IRIS_IUTEST_REGEX_HPP_1575CB44_189A_4248_B305_DB4882E3BFC2_
#define IUTEST_PP_DISALLOW_ASSIGN(TypeName)
代入禁止定義
Definition: iutest_pp.hpp:38
iutest root namespace
Definition: iutest_charcode.hpp:33