2
3
4
5
6
7
8
9
10
11
12
13
16#ifndef _PCRE2CPP_MATCH_RESULT_HPP_
17 #define _PCRE2CPP_MATCH_RESULT_HPP_
19 #include <pcre2cpp/config.hpp>
22_PCRE2CPP_ERROR(
"This is only available for c++17 and greater!");
25 #include <pcre2cpp/exceptions/exceptions.hpp>
26 #include <pcre2cpp/match/match_error_codes.hpp>
27 #include <pcre2cpp/types.hpp>
28 #include <pcre2cpp/utils/pcre2_data.hpp>
31 #pragma region MATCH_VALUE
34
35
36
37
63 #pragma region SUB_MATCH_VALUE
66
67
68
79
80
81
82
127 return u"Subexpression index out of bounds or has no value";
133 return U"Subexpression index out of bounds or has no value";
146 return fmt::
format(
"Subexpression with provided name '{}' not found",
name);
152 return fmt::
format(u"Subexpression with provided name '{}' not found",
name);
158 return fmt::
format(U"Subexpression with provided name '{}' not found",
name);
204 #pragma region CONSTRUCTORS
213 const _code_ptr& regex_compiled_code)
noexcept
246 #pragma region ERRORS
271 #pragma endregion ERRORS
273 #pragma region RESULTS
301 #pragma region RESULT
334 #pragma endregion RESULT
336 #pragma region ALL_SUB_RESULTS
430 #pragma endregion ALL_SUB_RESULTS
432 #pragma region SUB_RESULTS_BY_IDX
480 #pragma region SUB_RESULTS_BY_NAME
514 #pragma endregion RESULTS
Basic container to result data of match function.
Definition match_result.hpp:84
_PCRE2CPP_CONSTEXPR17 bool has_result() const noexcept
returns true when result holds some result not error
Definition match_result.hpp:276
_PCRE2CPP_CONSTEXPR17 match_error_codes get_error_code() const noexcept
return error code
Definition match_result.hpp:252
_PCRE2CPP_CONSTEXPR17 basic_match_result(basic_match_result &&other) noexcept=default
default move constructor
typename _pcre2_data_t::string_type _string_type
Definition match_result.hpp:93
_PCRE2CPP_CONSTEXPR17 basic_match_result & operator=(const basic_match_result &other) noexcept=default
default copy assign operator
_PCRE2CPP_CONSTEXPR17 bool has_sub_value(const _string_view_type name) const noexcept
returns true when result has sub value with given name
Definition match_result.hpp:291
_PCRE2CPP_CONSTEXPR17 basic_match_result(const match_error_codes error_code) noexcept
constructor with error code
Definition match_result.hpp:209
_PCRE2CPP_CONSTEXPR17 size_t get_search_offset() const noexcept
returns search offset
Definition match_result.hpp:296
_PCRE2CPP_CONSTEXPR17 basic_match_result() noexcept=default
default constructor
typename _pcre2_data_t::named_sub_values_table _named_sub_values_table
Definition match_result.hpp:99
_PCRE2CPP_CONSTEXPR17 basic_match_result & operator=(basic_match_result &&other) noexcept=default
default move assign operator
_PCRE2CPP_CONSTEXPR17 size_t _get_named_sub_result_idx(const _string_view_type name) const _PCRE2CPP_NOEXCEPT
returns group index of group with given name
Definition match_result.hpp:184
std::variant< match_error_codes, _value_result_data > _data
Result data.
Definition match_result.hpp:117
_PCRE2CPP_CONSTEXPR17 basic_match_result(const basic_match_result &other) noexcept=default
default copy constructor
std::shared_ptr< _named_sub_values_table > _named_sub_values_table_ptr
Definition match_result.hpp:100
std::shared_ptr< _code_type > _code_ptr
Definition match_result.hpp:92
basic_match_value< utf > _match_value
Definition match_result.hpp:95
_PCRE2CPP_CONSTEXPR17 const sub_match_value & _get_sub_value(const size_t idx) const _PCRE2CPP_NOEXCEPT
returns sub value data of group with provided index
Definition match_result.hpp:194
static _PCRE2CPP_CONSTEXPR17 size_t bad_offset
error offset (returned when value doesn't exist or when error has occurred)
Definition match_result.hpp:87
typename _pcre2_data_t::code_type _code_type
Definition match_result.hpp:91
_PCRE2CPP_CONSTEXPR17 _string_type get_error_message() const noexcept
returns error message
Definition match_result.hpp:258
_PCRE2CPP_CONSTEXPR17 _match_value get_result() const noexcept
returns match result container
Definition match_result.hpp:304
_PCRE2CPP_CONSTEXPR17 size_t get_result_global_offset() const noexcept
returns offset of value from the beginning of searched string
Definition match_result.hpp:310
_PCRE2CPP_CONSTEXPR17 bool has_error() const noexcept
returns true if result holds error
Definition match_result.hpp:249
_PCRE2CPP_CONSTEXPR17 _string_type get_result_value() const noexcept
returns match string value
Definition match_result.hpp:329
static _PCRE2CPP_CONSTEXPR17 _string_view_type _get_out_of_bounds_string() noexcept
returns out of bounds error in correct utf format
Definition match_result.hpp:120
_PCRE2CPP_CONSTEXPR17 size_t get_result_size() const noexcept
returns size of match value
Definition match_result.hpp:323
_PCRE2CPP_CONSTEXPR17 size_t get_result_relative_offset() const noexcept
return offset relative to search offset
Definition match_result.hpp:317
_PCRE2CPP_CONSTEXPR20 ~basic_match_result() noexcept=default
default destructor
_PCRE2CPP_CONSTEXPR17 bool has_value() const noexcept
returns true when result has value
Definition match_result.hpp:279
_PCRE2CPP_CONSTEXPR17 basic_match_result(const size_t search_offset, const _named_sub_values_table_ptr &named_sub_values, const _code_ptr ®ex_compiled_code) noexcept
constructor with no value but also without error
Definition match_result.hpp:212
static _PCRE2CPP_CONSTEXPR17 _string_type _get_subexpression_not_found(const _string_view_type name) noexcept
returns subexpression not found error in correct utf format
Definition match_result.hpp:143
typename _pcre2_data_t::string_view_type _string_view_type
Definition match_result.hpp:94
_PCRE2CPP_CONSTEXPR17 bool has_sub_value(const size_t idx) const noexcept
returns true when result has sub value on given index
Definition match_result.hpp:285
_PCRE2CPP_CONSTEXPR17 basic_match_result(const size_t search_offset, const _match_value &result, const std::vector< std::optional< sub_match_value > > &sub_results, const _named_sub_values_table_ptr &named_sub_values, const _code_ptr ®ex_compiled_code) noexcept
constructor with good result
Definition match_result.hpp:221
utils::pcre2_data< utf > _pcre2_data_t
Definition match_result.hpp:90
_PCRE2CPP_CONSTEXPR17 bool _has_sub_value(const size_t idx) const noexcept
returns true if sub result has value and idx wasn't out of bounds
Definition match_result.hpp:178
_PCRE2CPP_CONSTEXPR17 bool _has_named_sub_result(const _string_view_type name) const noexcept
returns true if sub result group with given name exists in named groups table
Definition match_result.hpp:168
base pcre2cpp exception class
Definition exceptions.hpp:134
#define _PCRE2CPP_NOEXCEPT
Definition config.hpp:176
static constexpr auto default_utf_type
default utf type for types like regex etc...
Definition pcre2_data.hpp:50
match_error_codes
Error codes which can be returned when match fail (now not used but maybe in future).
Definition match_error_codes.hpp:31
utf_type
Enum with supported utf types.
Definition pcre2_data.hpp:31
@ UTF_16
value for UTF-16 support
Definition pcre2_data.hpp:38
@ UTF_32
value for UTF-32 support
Definition pcre2_data.hpp:42
@ UTF_8
value for UTF-8 support
Definition pcre2_data.hpp:34
#define _PCRE2CPP_CONSTEXPR17
constexpr for c++17 and higher
Definition config.hpp:236
#define _PCRE2CPP_CONSTEXPR20
constexpr keyword for c++20 and higher
Definition config.hpp:253
#define _PCRE2CPP_HAS_UTF32
check if support for UTF-32 is enabled
Definition config.hpp:215
#define _PCRE2CPP_HAS_CXX17
check if compiler has c++ version greater or equal to c++17
Definition config.hpp:133
#define _PCRE2CPP_HAS_UTF8
check if support for UTF-8 is enabled
Definition config.hpp:203
#define _PCRE2CPP_HAS_UTF16
check if support for UTF-16 is enabled
Definition config.hpp:209
#define _PCRE2CPP_HAS_CXX20
check if compiler has c++ version greater or equal to c++20 and if user enabled c++20 features using ...
Definition config.hpp:145
#define _PCRE2CPP_HAS_EXCEPTIONS
check if exceptions are enabled
Definition config.hpp:171
basic_match_result< utf_type::UTF_8 > u8match_result
Definition match_result.hpp:518
basic_match_result< utf_type::UTF_32 > u32match_result
Definition match_result.hpp:524
basic_match_result< utf_type::UTF_16 > u16match_result
Definition match_result.hpp:521
basic_match_value< default_utf_type > match_value
Definition match_result.hpp:60
basic_match_value< utf_type::UTF_16 > u16match_value
Definition match_result.hpp:54
basic_match_result< default_utf_type > match_result
Definition match_result.hpp:527
basic_match_value< utf_type::UTF_32 > u32match_value
Definition match_result.hpp:57
basic_match_value< utf_type::UTF_8 > u8match_value
Definition match_result.hpp:51
Result data container.
Definition match_result.hpp:103
size_t search_offset
keeps search offset
Definition match_result.hpp:105
_match_value result
keeps whole result
Definition match_result.hpp:107
_named_sub_values_table_ptr named_sub_values
keeps named sub values mapping
Definition match_result.hpp:111
_code_ptr code
keeps regex code data in case regex object was destroyed
Definition match_result.hpp:113
Match value container.
Definition match_result.hpp:39
typename utils::pcre2_data< utf >::string_type _string_type
Definition match_result.hpp:41
_string_type value
match value
Definition match_result.hpp:47
size_t relative_offset
offset relative to search offset
Definition match_result.hpp:45
Sub match value container.
Definition match_result.hpp:69
size_t size
size of value
Definition match_result.hpp:73
size_t relative_offset
offset relative to search offset
Definition match_result.hpp:71
Translation container from pcre2 library to pcre2cpp.
Definition pcre2_data.hpp:68