gz-cpp-util 1.3
A c++20 library containing various utilities
regex.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <regex>
4#include <string_view>
5
6namespace gz::re {
7 struct types {
9 static const std::regex intT;
11 static const std::regex uintT;
13 static const std::regex floatT;
14 };
15
16
21 using svmatch = std::match_results<std::string_view::const_iterator>;
22 using svsub_match = std::sub_match<std::string_view::const_iterator>;
23
24 inline std::string_view get_sv(const svsub_match& m) {
25 return std::string_view(m.first, m.length());
26 }
28 inline bool regex_match(std::string_view sv, svmatch& m, const std::regex& e, std::regex_constants::match_flag_type flags=std::regex_constants::match_default) {
29 return std::regex_match(sv.begin(), sv.end(), m, e, flags);
30 }
32 inline bool regex_match(std::string_view sv, const std::regex& e, std::regex_constants::match_flag_type flags = std::regex_constants::match_default) {
33 return std::regex_match(sv.begin(), sv.end(), e, flags);
34 }
35
36 inline bool regex_search(std::string_view sv, svmatch& m, const std::regex& e, std::regex_constants::match_flag_type flags=std::regex_constants::match_default) {
37 return std::regex_search(sv.begin(), sv.end(), m, e, flags);
38 }
39 inline bool regex_search(std::string_view sv, const std::regex& e, std::regex_constants::match_flag_type flags = std::regex_constants::match_default) {
40 return std::regex_search(sv.begin(), sv.end(), e, flags);
41 }
43}
44
45
bool regex_match(std::string_view sv, svmatch &m, const std::regex &e, std::regex_constants::match_flag_type flags=std::regex_constants::match_default)
Definition: regex.hpp:28
Definition: regex.hpp:7
static const std::regex floatT
convertible with std::stof
Definition: regex.hpp:13
static const std::regex intT
convertible with std::stoi
Definition: regex.hpp:9
static const std::regex uintT
convertible with std::stoul
Definition: regex.hpp:11