userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
regex.hpp
Go to the documentation of this file.
1
#pragma once
2
5
6
#include <cstddef>
7
#include <exception>
8
#include <string_view>
9
10
#include <userver/compiler/impl/lifetime.hpp>
11
#include <
userver/utils/fast_pimpl.hpp
>
12
13
USERVER_NAMESPACE_BEGIN
14
15
namespace
utils
{
16
17
// NOLINTBEGIN(readability-identifier-naming)
18
19
class
match_results
;
20
struct
Re2Replacement
;
21
23
class
RegexError
:
public
std::exception {};
24
47
class
regex
final {
48
public
:
50
regex
();
51
54
explicit
regex
(std::string_view pattern);
55
56
regex
(
const
regex
&);
57
regex
(
regex
&&) noexcept;
58
regex
& operator=(const
regex
&);
59
regex
& operator=(
regex
&&) noexcept;
60
~
regex
();
61
64
bool
operator==(const
regex
&) const;
65
67
std
::string_view
GetPatternView
() const USERVER_IMPL_LIFETIME_BOUND;
68
70
std
::
string
str
() const;
71
72
private:
73
class Impl;
74
utils
::
FastPimpl
<Impl, 16, 8> impl_;
75
76
friend class match_results;
77
friend
bool
regex_match
(
std
::string_view
str
, const
regex
& pattern);
78
friend
bool
regex_match
(
std
::string_view
str
, match_results& m, const
regex
& pattern);
79
friend
bool
regex_search
(
std
::string_view
str
, const
regex
& pattern);
80
friend
bool
regex_search
(
std
::string_view
str
, match_results& m, const
regex
& pattern);
81
friend
std
::
string
regex_replace
(
std
::string_view
str
, const
regex
& pattern,
std
::string_view repl);
82
friend
std
::
string
regex_replace
(
std
::string_view
str
, const
regex
& pattern,
Re2Replacement
repl);
83
};
84
100
class
match_results
final {
101
public
:
104
match_results
();
105
106
match_results
(
const
match_results
&);
107
match_results
& operator=(
const
match_results
&);
108
~match_results
();
109
111
std::size_t
size
()
const
;
112
115
std::string_view
operator[]
(std::size_t sub)
const
;
116
120
std::size_t
position
(std::size_t sub)
const
;
121
124
std::size_t
length
(std::size_t sub)
const
;
125
127
std::string_view
prefix
()
const
;
128
130
std::string_view
suffix
()
const
;
131
132
private
:
133
struct
Impl;
134
utils::FastPimpl<Impl, 120, 8>
impl_;
135
136
friend
bool
regex_match
(std::string_view
str
,
const
regex
& pattern);
137
friend
bool
regex_match
(std::string_view
str
,
match_results
& m,
const
regex
& pattern);
138
friend
bool
regex_search
(std::string_view
str
,
const
regex
& pattern);
139
friend
bool
regex_search
(std::string_view
str
,
match_results
& m,
const
regex
& pattern);
140
friend
std::string
regex_replace
(std::string_view
str
,
const
regex
& pattern, std::string_view repl);
141
friend
std::string
regex_replace
(std::string_view
str
,
const
regex
& pattern,
Re2Replacement
repl);
142
};
143
146
bool
regex_match
(std::string_view
str
,
const
regex
& pattern);
147
151
bool
regex_match
(std::string_view
str
,
match_results
& m,
const
regex
& pattern);
152
155
bool
regex_search
(std::string_view
str
,
const
regex
& pattern);
156
160
bool
regex_search
(std::string_view
str
,
match_results
& m,
const
regex
& pattern);
161
168
std::string
regex_replace
(std::string_view
str
,
const
regex
& pattern, std::string_view repl);
169
187
struct
Re2Replacement
final {
188
std::string_view replacement;
189
};
190
193
std::string
regex_replace
(std::string_view
str
,
const
regex
& pattern,
Re2Replacement
repl);
194
195
// NOLINTEND(readability-identifier-naming)
196
197
}
// namespace utils
198
199
USERVER_NAMESPACE_END
userver
utils
regex.hpp
Generated on
for userver by
Doxygen
1.17.0