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
YAML_PM::REGEX_SEQ
@ REGEX_SEQ
Definition: regex.h:16
YAML_PM::RegEx::MatchOpEmpty
int MatchOpEmpty(const Source &source) const
Definition: regeximpl.h:108
YAML_PM::REGEX_RANGE
@ REGEX_RANGE
Definition: regex.h:16
YAML_PM
Definition: aliasmanager.h:11
YAML_PM::REGEX_EMPTY
@ REGEX_EMPTY
Definition: regex.h:16
YAML_PM::RegEx::RegEx
RegEx()
Definition: regex.cpp:6
YAML_PM::RegEx::MatchOpRange
int MatchOpRange(const Source &source) const
Definition: regeximpl.h:127
YAML_PM::RegEx::MatchUnchecked
int MatchUnchecked(const Source &source) const
Definition: regeximpl.h:79
YAML_PM::RegEx::MatchOpMatch
int MatchOpMatch(const Source &source) const
Definition: regeximpl.h:119
YAML_PM::REGEX_NOT
@ REGEX_NOT
Definition: regex.h:16
YAML_PM::RegEx::operator&&
friend RegEx operator&&(const RegEx &ex1, const RegEx &ex2)
Definition: regex.cpp:44
testing::internal::string
::std::string string
Definition: gtest.h:1979
YAML_PM::RegEx::operator||
friend RegEx operator||(const RegEx &ex1, const RegEx &ex2)
Definition: regex.cpp:36
YAML_PM::RegEx::MatchOpOr
int MatchOpOr(const Source &source) const
Definition: regeximpl.h:135
YAML_PM::RegEx::m_op
REGEX_OP m_op
Definition: regex.h:59
YAML_PM::REGEX_AND
@ REGEX_AND
Definition: regex.h:16
YAML_PM::RegEx::~RegEx
~RegEx()
Definition: regex.h:28
YAML_PM::RegEx::m_a
char m_a
Definition: regex.h:60
YAML_PM::RegEx::MatchOpNot
int MatchOpNot(const Source &source) const
Definition: regeximpl.h:163
YAML_PM::REGEX_MATCH
@ REGEX_MATCH
Definition: regex.h:16
regeximpl.h
YAML_PM::RegEx::operator+
friend RegEx operator+(const RegEx &ex1, const RegEx &ex2)
Definition: regex.cpp:52
YAML_PM::RegEx::MatchOpSeq
int MatchOpSeq(const Source &source) const
Definition: regeximpl.h:173
YAML_PM::RegEx::m_z
char m_z
Definition: regex.h:60
YAML_PM::RegEx::Match
int Match(const std::string &str) const
Definition: regeximpl.h:42
YAML_PM::RegEx::m_params
std::vector< RegEx > m_params
Definition: regex.h:61
YAML_PM::RegEx
Definition: regex.h:21
YAML_PM::REGEX_OP
REGEX_OP
Definition: regex.h:16
YAML_PM::RegEx::Matches
bool Matches(char ch) const
Definition: regeximpl.h:16
YAML_PM::RegEx::operator!
friend RegEx operator!(const RegEx &ex)
Definition: regex.cpp:29
YAML_PM::RegEx::MatchOpAnd
int MatchOpAnd(const Source &source) const
Definition: regeximpl.h:149
YAML_PM::Stream
Definition: stream.h:20
YAML_PM::REGEX_OR
@ REGEX_OR
Definition: regex.h:16
YAML_PM::RegEx::IsValidSource
bool IsValidSource(const Source &source) const
Definition: regeximpl.h:55


mp2p_icp
Author(s):
autogenerated on Wed Oct 23 2024 02:45:41