userver: userver/utils/regex.hpp Source File
Loading...
Searching...
No Matches
regex.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/utils/regex.hpp
4/// @brief @copybrief utils::regex
5
6#include <string>
7
8#include <userver/utils/fast_pimpl.hpp>
9
10USERVER_NAMESPACE_BEGIN
11
12namespace utils {
13
14/// @ingroup userver_universal userver_containers
15///
16/// @brief Small alias for boost::regex / std::regex without huge includes
17class regex final {
18 public:
19 regex();
20 explicit regex(std::string_view pattern);
21
22 ~regex();
23
24 regex(const regex&);
25 regex(regex&&) noexcept;
26
27 regex& operator=(const regex&);
28 regex& operator=(regex&&) noexcept;
29
30 private:
31 struct Impl;
32 utils::FastPimpl<Impl, 16, 8> impl_;
33
34 friend bool regex_match(std::string_view str, const regex& pattern);
35 friend bool regex_search(std::string_view str, const regex& pattern);
36};
37
38/// @brief Determines whether the regular expression matches the entire target
39/// character sequence
40bool regex_match(std::string_view str, const regex& pattern);
41
42/// @brief Determines whether the regular expression matches anywhere in the
43/// target character sequence
44bool regex_search(std::string_view str, const regex& pattern);
45
46} // namespace utils
47
48USERVER_NAMESPACE_END