25namespace pcre2_details
33template <
typename Traits >
38 m_match_data = pcre2_match_data_create( Traits::max_capture_groups,
nullptr );
68 PCRE2_SIZE * submatches = pcre2_get_ovector_pointer(
m_match_data );
72 submatches[ 1 + 2 * i ] };
101 rw.m_route_regex =
nullptr;
109 rw.m_route_regex =
nullptr;
135 PCRE2_SIZE erroroffset;
139 reinterpret_cast< const unsigned char*
>( r.data() ),
141 static_cast<unsigned int>(options),
148 std::array< unsigned char, 256 > buffer;
149 (void)pcre2_get_error_message( errorcode, buffer.data(), buffer.size() );
152 "unable to compile regex \"{}\": {}",
154 reinterpret_cast< const char *
>( buffer.data() ) ) };
166template < std::
size_t Max_Capture_Groups = 20,
int Compile_Options = 0,
int Match_Options = 0 >
179template <
typename Traits = pcre2_traits_t<> >
187 static constexpr std::size_t
190 return Traits::max_capture_groups;
199 bool is_case_sensative )
201 int options = Traits::compile_options;
203 if( !is_case_sensative )
205 options |= PCRE2_CASELESS;
221 reinterpret_cast< const unsigned char*
>( target_path.data() ),
224 Traits::match_options,
230 match_results.
m_size =
static_cast<std::size_t
>(rc);
237 throw exception_t{
"unexpected: not enough submatch vector size" };
239 if( PCRE2_ERROR_NOMATCH != rc )
241 throw exception_t{ fmt::format(
"pcre2 error: {}", rc ) };
252 return static_cast< std::size_t
>( m.m_begin );
259 return static_cast< std::size_t
>( m.m_end );
Exception class for all exceptions thrown by RESTinio.
A wrapper for using pcre regexes in express_router.
regex_t(regex_t &&rw) noexcept
regex_t(const regex_t &)=delete
regex_t & operator=(const regex_t &)=delete
void compile(string_view_t r, int options)
regex_t(string_view_t r, int options)
pcre2_code * m_route_regex
const pcre2_code * pcre2_regex() const
A special wrapper around fmtlib include files.
nonstd::string_view string_view_t
matched_item_descriptor_t(PCRE2_SIZE begin, PCRE2_SIZE end)
A wrapper class for working with pcre match results.
match_results_t & operator=(const match_results_t &)=delete
pcre2_match_data * m_match_data
match_results_t(const match_results_t &)=delete
matched_item_descriptor_t operator[](std::size_t i) const
match_results_t(match_results_t &&)=delete
Regex engine implementation for PCRE2.
static auto submatch_end_pos(const matched_item_descriptor_t &m)
Get the end of a submatch.
static auto try_match(string_view_t target_path, const compiled_regex_t &r, match_results_t &match_results)
Wrapper function for matching logic invokation.
static auto compile_regex(string_view_t r, bool is_case_sensative)
Create compiled regex object for a given route.
typename match_results_t::matched_item_descriptor_t matched_item_descriptor_t
static auto submatch_begin_pos(const matched_item_descriptor_t &m)
Get the beginning of a submatch.
static constexpr std::size_t max_capture_groups()
static constexpr int match_options
static constexpr std::size_t max_capture_groups
static constexpr int compile_options