regex.h
Go to the documentation of this file.
1 #ifndef REGEX_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM
2 #define REGEX_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM
3 
4 #if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
5 #pragma once
6 #endif
7 
8 
9 #include <vector>
10 #include <string>
11 
12 namespace YAML_PM
13 {
14  class Stream;
15 
17 
18  // simplified regular expressions
19  // . Only straightforward matches (no repeated characters)
20  // . Only matches from start of string
21  class RegEx
22  {
23  public:
24  RegEx();
25  RegEx(char ch);
26  RegEx(char a, char z);
27  RegEx(const std::string& str, REGEX_OP op = REGEX_SEQ);
28  ~RegEx() {}
29 
30  friend RegEx operator ! (const RegEx& ex);
31  friend RegEx operator || (const RegEx& ex1, const RegEx& ex2);
32  friend RegEx operator && (const RegEx& ex1, const RegEx& ex2);
33  friend RegEx operator + (const RegEx& ex1, const RegEx& ex2);
34 
35  bool Matches(char ch) const;
36  bool Matches(const std::string& str) const;
37  bool Matches(const Stream& in) const;
38  template <typename Source> bool Matches(const Source& source) const;
39 
40  int Match(const std::string& str) const;
41  int Match(const Stream& in) const;
42  template <typename Source> int Match(const Source& source) const;
43 
44  private:
45  RegEx(REGEX_OP op);
46 
47  template <typename Source> bool IsValidSource(const Source& source) const;
48  template <typename Source> int MatchUnchecked(const Source& source) const;
49 
50  template <typename Source> int MatchOpEmpty(const Source& source) const;
51  template <typename Source> int MatchOpMatch(const Source& source) const;
52  template <typename Source> int MatchOpRange(const Source& source) const;
53  template <typename Source> int MatchOpOr(const Source& source) const;
54  template <typename Source> int MatchOpAnd(const Source& source) const;
55  template <typename Source> int MatchOpNot(const Source& source) const;
56  template <typename Source> int MatchOpSeq(const Source& source) const;
57 
58  private:
60  char m_a, m_z;
61  std::vector <RegEx> m_params;
62  };
63 }
64 
65 #include "regeximpl.h"
66 
67 #endif // REGEX_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM
int MatchOpRange(const Source &source) const
Definition: regeximpl.h:127
friend RegEx operator&&(const RegEx &ex1, const RegEx &ex2)
Definition: regex.cpp:44
::std::string string
Definition: gtest.h:1979
int MatchOpMatch(const Source &source) const
Definition: regeximpl.h:119
int MatchUnchecked(const Source &source) const
Definition: regeximpl.h:79
friend RegEx operator||(const RegEx &ex1, const RegEx &ex2)
Definition: regex.cpp:36
int MatchOpOr(const Source &source) const
Definition: regeximpl.h:135
REGEX_OP m_op
Definition: regex.h:59
char m_a
Definition: regex.h:60
int MatchOpNot(const Source &source) const
Definition: regeximpl.h:163
friend RegEx operator+(const RegEx &ex1, const RegEx &ex2)
Definition: regex.cpp:52
int Match(const std::string &str) const
Definition: regeximpl.h:42
friend RegEx operator!(const RegEx &ex)
Definition: regex.cpp:29
REGEX_OP
Definition: regex.h:16
char m_z
Definition: regex.h:60
int MatchOpSeq(const Source &source) const
Definition: regeximpl.h:173
std::vector< RegEx > m_params
Definition: regex.h:61
bool IsValidSource(const Source &source) const
Definition: regeximpl.h:55
int MatchOpAnd(const Source &source) const
Definition: regeximpl.h:149
bool Matches(char ch) const
Definition: regeximpl.h:16
int MatchOpEmpty(const Source &source) const
Definition: regeximpl.h:108


libpointmatcher
Author(s):
autogenerated on Sat May 27 2023 02:38:03