-
Notifications
You must be signed in to change notification settings - Fork 192
/
Copy pathwrapper.hpp
135 lines (127 loc) · 5.57 KB
/
wrapper.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#ifndef CTRE__WRAPPER__HPP
#define CTRE__WRAPPER__HPP
#include "evaluation.hpp"
#include "utility.hpp"
#include <string_view>
#include <string>
namespace ctre {
struct zero_terminated_string_end_iterator {
constexpr inline zero_terminated_string_end_iterator() = default;
constexpr CTRE_FORCE_INLINE bool operator==(const char * ptr) const noexcept {
return *ptr == '\0';
}
constexpr CTRE_FORCE_INLINE bool operator==(const wchar_t * ptr) const noexcept {
return *ptr == 0;
}
constexpr CTRE_FORCE_INLINE bool operator!=(const char * ptr) const noexcept {
return *ptr != '\0';
}
constexpr CTRE_FORCE_INLINE bool operator!=(const wchar_t * ptr) const noexcept {
return *ptr != 0;
}
template<typename T>
friend constexpr CTRE_FORCE_INLINE bool operator==(T t, zero_terminated_string_end_iterator it) {
return it == t;
}
template<typename T>
friend constexpr CTRE_FORCE_INLINE bool operator!=(T t, zero_terminated_string_end_iterator it) {
return it != t;
}
};
template <typename RE> struct regular_expression {
template <typename IteratorBegin, typename IteratorEnd> constexpr CTRE_FORCE_INLINE static auto match_2(IteratorBegin begin, IteratorEnd end) noexcept {
return match_re(begin, end, RE());
}
template <typename IteratorBegin, typename IteratorEnd> constexpr CTRE_FORCE_INLINE static auto ordered_match_2(IteratorBegin begin, IteratorEnd end) noexcept {
return ordered_match_re(begin, end, RE());
}
template <typename IteratorBegin, typename IteratorEnd> constexpr CTRE_FORCE_INLINE static auto search_2(IteratorBegin begin, IteratorEnd end) noexcept {
return search_re(begin, end, RE());
}
constexpr CTRE_FORCE_INLINE regular_expression() noexcept { };
constexpr CTRE_FORCE_INLINE regular_expression(RE) noexcept { };
template <typename Iterator> constexpr CTRE_FORCE_INLINE static auto match(Iterator begin, Iterator end) noexcept {
return match_re(begin, end, RE());
}
static constexpr CTRE_FORCE_INLINE auto match(const char * s) noexcept {
return match_2(s, zero_terminated_string_end_iterator());
}
static constexpr CTRE_FORCE_INLINE auto match(const wchar_t * s) noexcept {
return match_2(s, zero_terminated_string_end_iterator());
}
static constexpr CTRE_FORCE_INLINE auto match(const std::string & s) noexcept {
return match_2(s.c_str(), zero_terminated_string_end_iterator());
}
static constexpr CTRE_FORCE_INLINE auto match(const std::wstring & s) noexcept {
return match_2(s.c_str(), zero_terminated_string_end_iterator());
}
static constexpr CTRE_FORCE_INLINE auto match(std::string_view sv) noexcept {
return match(sv.begin(), sv.end());
}
static constexpr CTRE_FORCE_INLINE auto match(std::wstring_view sv) noexcept {
return match(sv.begin(), sv.end());
}
static constexpr CTRE_FORCE_INLINE auto match(std::u16string_view sv) noexcept {
return match(sv.begin(), sv.end());
}
static constexpr CTRE_FORCE_INLINE auto match(std::u32string_view sv) noexcept {
return match(sv.begin(), sv.end());
}
template <typename Iterator> constexpr CTRE_FORCE_INLINE static auto ordered_match(Iterator begin, Iterator end) noexcept {
return ordered_match_re(begin, end, RE());
}
static constexpr CTRE_FORCE_INLINE auto ordered_match(const char * s) noexcept {
return ordered_match_2(s, zero_terminated_string_end_iterator());
}
static constexpr CTRE_FORCE_INLINE auto ordered_match(const wchar_t * s) noexcept {
return ordered_match_2(s, zero_terminated_string_end_iterator());
}
static constexpr CTRE_FORCE_INLINE auto ordered_match(const std::string & s) noexcept {
return ordered_match_2(s.c_str(), zero_terminated_string_end_iterator());
}
static constexpr CTRE_FORCE_INLINE auto ordered_match(const std::wstring & s) noexcept {
return ordered_match_2(s.c_str(), zero_terminated_string_end_iterator());
}
static constexpr CTRE_FORCE_INLINE auto ordered_match(std::string_view sv) noexcept {
return ordered_match(sv.begin(), sv.end());
}
static constexpr CTRE_FORCE_INLINE auto ordered_match(std::wstring_view sv) noexcept {
return ordered_match(sv.begin(), sv.end());
}
static constexpr CTRE_FORCE_INLINE auto ordered_match(std::u16string_view sv) noexcept {
return ordered_match(sv.begin(), sv.end());
}
static constexpr CTRE_FORCE_INLINE auto ordered_match(std::u32string_view sv) noexcept {
return ordered_match(sv.begin(), sv.end());
}
template <typename Iterator> constexpr CTRE_FORCE_INLINE static auto search(Iterator begin, Iterator end) noexcept {
return search_re(begin, end, RE());
}
constexpr CTRE_FORCE_INLINE static auto search(const char * s) noexcept {
return search_2(s, zero_terminated_string_end_iterator());
}
static constexpr CTRE_FORCE_INLINE auto search(const wchar_t * s) noexcept {
return search_2(s, zero_terminated_string_end_iterator());
}
static constexpr CTRE_FORCE_INLINE auto search(const std::string & s) noexcept {
return search_2(s.c_str(), zero_terminated_string_end_iterator());
}
static constexpr CTRE_FORCE_INLINE auto search(const std::wstring & s) noexcept {
return search_2(s.c_str(), zero_terminated_string_end_iterator());
}
static constexpr CTRE_FORCE_INLINE auto search(std::string_view sv) noexcept {
return search(sv.begin(), sv.end());
}
static constexpr CTRE_FORCE_INLINE auto search(std::wstring_view sv) noexcept {
return search(sv.begin(), sv.end());
}
static constexpr CTRE_FORCE_INLINE auto search(std::u16string_view sv) noexcept {
return search(sv.begin(), sv.end());
}
static constexpr CTRE_FORCE_INLINE auto search(std::u32string_view sv) noexcept {
return search(sv.begin(), sv.end());
}
};
template <typename RE> regular_expression(RE) -> regular_expression<RE>;
}
#endif