PCRE2 C++ Wrapper 1.3.0
pcre2cpp
Loading...
Searching...
No Matches
pcre2_data.hpp
1/*
2 * pcre2cpp - PCRE2 cpp wrapper
3 *
4 * Licensed under the BSD 3-Clause License with Attribution Requirement.
5 * See the LICENSE file for details: https://github.com/MAIPA01/pcre2cpp/blob/main/LICENSE
6 *
7 * Copyright (c) 2025, Patryk Antosik (MAIPA01)
8 *
9 * PCRE2 library included in this project:
10 * Copyright (c) 2016-2024, University of Cambridge.
11 *
12 * See the LICENSE_PCRE2 file for details: https://github.com/MAIPA01/pcre2cpp/blob/main/LICENSE_PCRE2
13 */
14
15#pragma once
16#ifndef _PCRE2CPP_PCRE2_DATA_HPP_
17 #define _PCRE2CPP_PCRE2_DATA_HPP_
18
19 #include <pcre2cpp/config.hpp>
20
22_PCRE2CPP_ERROR("This is only available for c++17 and greater!");
23 #else
24 #include <pcre2cpp/types.hpp>
25
26namespace pcre2cpp {
27 /**
28 * @brief Enum with supported utf types
29 * @ingroup pcre2cpp
30 */
31 enum class utf_type : uint8_t {
33 /// @brief value for UTF-8 support
34 UTF_8 = 8,
35 #endif
37 /// @brief value for UTF-16 support
38 UTF_16 = 16,
39 #endif
41 /// @brief value for UTF-32 support
42 UTF_32 = 32
43 #endif
44 };
45
46 /**
47 * @brief default utf type for types like regex etc...
48 * @ingroup pcre2cpp
49 */
50 static constexpr auto default_utf_type =
53 #elif _PCRE2CPP_HAS_UTF16
55 #elif _PCRE2CPP_HAS_UTF32
57 #endif
58 ;
59} // namespace pcre2cpp
60
61namespace pcre2cpp::utils {
62 /**
63 * @brief Translation container from pcre2 library to pcre2cpp
64 * @ingroup utils
65 * @tparam utf utf coding type (UTF-8 -> utf_type::UTF_8, UTF-16 -> utf_type::UTF_16, UTF-32 -> utf_type::UTF_32)
66 */
67 template<utf_type utf>
68 struct pcre2_data {};
69
70 #pragma region UTF_8
72 /**
73 * @brief Specialization of Translation container from pcre2 library to pcre2cpp for UTF-8
74 * @ingroup utils
75 */
76 template<>
78 #pragma region CODE
79 /// @brief pcre2 code structure type for utf-8
81 /// @brief pcre2 compile context structure type for utf-8
83 /// @brief pcre2 general context structure type for utf-8
85 #pragma endregion
86
87 #pragma region MATCH
88 /// @brief pcre2 match data structure type for utf-8
90 /// @brief pcre2 match context structure type for utf-8
92 #pragma endregion
93
94 #pragma region PCRE2_STRING
95 /// @brief pcre2 string pointer type for utf-8
97 /// @brief pcre2 unsigned char type for utf-8
99 #pragma endregion
100
101 #pragma region CPP_STRING
102 // #if _PCRE2CPP_HAS_CXX20
103 // using string_type = std::u8string;
104 // using string_view_type = std::u8string_view;
105 // #else
106 // using string_type = std::string;
107 // using string_view_type = std::string_view;
108 // #endif
109 /// @brief cpp string type for utf-8
110 using string_type = std::string;
111 /// @brief cpp string view type for utf-8
113 /// @brief cpp string char type for utf-8
115 #pragma endregion
116
117 #pragma region SUB_MATCHES
118 /// @brief mapping from subgroup name to subgroup index minus one
120 #pragma endregion
121
122 #pragma region UTF_INFO
123 /// @brief utf enum value for utf-8
125 /// @brief utf byte size for utf-8
127 #pragma endregion
128
129 #pragma region CODE_FUNCTIONS
130 /// @brief pointer to pcre2_compile function for utf-8
134 /// @brief pointer to pcre2_code_free function for utf-8
136 #pragma endregion
137
138 #pragma region MATCH_DATA_FUNCTIONS
139 /// @brief pointer to pcre2_match_data_create_from_pattern function for utf-8
142 /// @brief pointer to pcre2_match_data_free function for utf-8
144 #pragma endregion
145
146 #pragma region MATCH_FUNCTIONS
147 /// @brief pointer to pcre2_match function for utf-8
151 #pragma endregion
152
153 #pragma region OVECTOR_FUNCTIONS
154 /// @brief pointer to pcre2_get_ovector_pointer function for utf-8
157 /// @brief pointer to pcre2_get_ovector_count function for utf-8
160 #pragma endregion
161
162 #pragma region ERROR_FUNCTIONS
163 /// @brief pointer to pcre2_get_error_message function for utf-8
166 #pragma endregion
167
168 #pragma region PATTERN_INFO_FUNCTIONS
169 /// @brief pointer to pcre2_pattern_info function for utf-8
172 #pragma endregion
173
174 #pragma region SUBSTRING_FUNCTIONS
175 /// @brief pointer to pcre2_substring_number_from_name function for utf-8
178 #pragma endregion
179 };
180 #endif
181
182 #pragma endregion
183
184 #pragma region UTF_16
185
187 /**
188 * @brief Specialization of Translation container from pcre2 library to pcre2cpp for UTF-16
189 * @ingroup utils
190 */
191 template<>
193 #pragma region CODE
194 /// @brief pcre2 code structure type for utf-16
196 /// @brief pcre2 compile context structure type for utf-16
198 /// @brief pcre2 general context structure type for utf-16
200 #pragma endregion
201
202 #pragma region MATCH
203 /// @brief pcre2 match data structure type for utf-16
205 /// @brief pcre2 match context structure type for utf-16
207 #pragma endregion
208
209 #pragma region PCRE2_STRING
210 /// @brief pcre2 string pointer type for utf-16
212 /// @brief pcre2 unsigned char type for utf-16
214 #pragma endregion
215
216 #pragma region CPP_STRING
217 /// @brief cpp string type for utf-16
218 using string_type = std::u16string;
219 /// @brief cpp string view type for utf-16
221 /// @brief cpp string char type for utf-16
223 #pragma endregion
224
225 #pragma region SUB_MATCHES
226 /// @brief mapping from subgroup name to subgroup index minus one
228 #pragma endregion
229
230 #pragma region UTF_INFO
231 /// @brief utf enum value for utf-16
233 /// @brief utf byte size for utf-16
234 static _PCRE2CPP_CONSTEXPR17 size_t utf_size = 16;
235 #pragma endregion
236
237 #pragma region CODE_FUNCTIONS
238 /// @brief pointer to pcre2_compile function for utf-16
242 /// @brief pointer to pcre2_code_free function for utf-16
244 #pragma endregion
245
246 #pragma region MATCH_DATA_FUNCTIONS
247 /// @brief pointer to pcre2_match_data_create_from_pattern function for utf-16
250 /// @brief pointer to pcre2_match_data_free function for utf-16
252 #pragma endregion
253
254 #pragma region MATCH_FUNCTIONS
255 /// @brief pointer to pcre2_match function for utf-16
259 #pragma endregion
260
261 #pragma region OVECTOR_FUNCTIONS
262 /// @brief pointer to pcre2_get_ovector_pointer function for utf-16
265 /// @brief pointer to pcre2_get_ovector_count function for utf-16
268 #pragma endregion
269
270 #pragma region ERROR_FUNCTIONS
271 /// @brief pointer to pcre2_get_error_message function for utf-16
274 #pragma endregion
275
276 #pragma region PATTERN_INFO_FUNCTIONS
277 /// @brief pointer to pcre2_pattern_info function for utf-16
280 #pragma endregion
281
282 #pragma region SUBSTRING_FUNCTIONS
283 /// @brief pointer to pcre2_substring_number_from_name function for utf-16
286 #pragma endregion
287 };
288 #endif
289
290 #pragma endregion
291
292 #pragma region UTF_32
293
295 /**
296 * @brief Specialization of Translation container from pcre2 library to pcre2cpp for UTF-32
297 * @ingroup utils
298 */
299 template<>
301 #pragma region CODE
302 /// @brief pcre2 code structure type for utf-32
304 /// @brief pcre2 compile context structure type for utf-32
306 /// @brief pcre2 general context structure type for utf-32
308 #pragma endregion
309
310 #pragma region MATCH
311 /// @brief pcre2 match data structure type for utf-32
313 /// @brief pcre2 match context structure type for utf-32
315 #pragma endregion
316
317 #pragma region PCRE2_STRING
318 /// @brief pcre2 string pointer type for utf-32
320 /// @brief pcre2 unsigned char type for utf-32
322 #pragma endregion
323
324 #pragma region CPP_STRING
325 /// @brief cpp string type for utf-32
326 using string_type = std::u32string;
327 /// @brief cpp string view type for utf-32
329 /// @brief cpp string char type for utf-32
331 #pragma endregion
332
333 #pragma region SUB_MATCHES
334 /// @brief mapping from subgroup name to subgroup index minus one
336 #pragma endregion
337
338 #pragma region UTF_INFO
339 /// @brief utf enum value for utf-32
341 /// @brief utf byte size for utf-32
342 static _PCRE2CPP_CONSTEXPR17 size_t utf_size = 32;
343 #pragma endregion
344
345 #pragma region CODE_FUNCTIONS
346 /// @brief pointer to pcre2_compile function for utf-32
350 /// @brief pointer to pcre2_code_free function for utf-32
352 #pragma endregion
353
354 #pragma region MATCH_DATA_FUNCTIONS
355 /// @brief pointer to pcre2_match_data_create_from_pattern function for utf-32
358 /// @brief pointer to pcre2_match_data_free function for utf-32
360 #pragma endregion
361
362 #pragma region MATCH_FUNCTIONS
363 /// @brief pointer to pcre2_match function for utf-32
367 #pragma endregion
368
369 #pragma region OVECTOR_FUNCTIONS
370 /// @brief pointer to pcre2_get_ovector_pointer function for utf-32
373 /// @brief pointer to pcre2_get_ovector_count function for utf-32
376 #pragma endregion
377
378 #pragma region ERROR_FUNCTIONS
379 /// @brief pointer to pcre2_get_error_message function for utf-32
382 #pragma endregion
383
384 #pragma region PATTERN_INFO_FUNCTIONS
385 /// @brief pointer to pcre2_pattern_info function for utf-32
388 #pragma endregion
389
390 #pragma region SUBSTRING_FUNCTIONS
391 /// @brief pointer to pcre2_substring_number_from_name function for utf-32
394 #pragma endregion
395 };
396 #endif
397
398 #pragma endregion
399
402 #endif
405 #endif
408 #endif
409} // namespace pcre2cpp::utils
410 #endif
411#endif
base pcre2cpp exception class
Definition exceptions.hpp:134
static constexpr auto default_utf_type
default utf type for types like regex etc...
Definition pcre2_data.hpp:50
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_PCRE2_FUNC_CONSTEXPR17
adds constexpr to pcre2 function pointers only if pcre2 is static library
Definition config.hpp:270
#define _PCRE2CPP_CONSTEXPR17
constexpr for c++17 and higher
Definition config.hpp:236
#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
Definition types.hpp:30
pcre2_data< utf_type::UTF_8 > u8pcre2_data
Definition pcre2_data.hpp:401
pcre2_data< utf_type::UTF_32 > u32pcre2_data
Definition pcre2_data.hpp:407
pcre2_data< utf_type::UTF_16 > u16pcre2_data
Definition pcre2_data.hpp:404
Specialization of Translation container from pcre2 library to pcre2cpp for UTF-16.
Definition pcre2_data.hpp:192
static _PCRE2CPP_PCRE2_FUNC_CONSTEXPR17 mstd::c_func_t< code_type *(sptr_type, size_t, uint32_t, int *, size_t *, compile_ctx_type *)> compile
pointer to pcre2_compile function for utf-16
Definition pcre2_data.hpp:241
static _PCRE2CPP_PCRE2_FUNC_CONSTEXPR17 mstd::c_func_t< int(int, uchar_type *, size_t)> get_error_message
pointer to pcre2_get_error_message function for utf-16
Definition pcre2_data.hpp:272
static _PCRE2CPP_PCRE2_FUNC_CONSTEXPR17 mstd::c_func_t< uint32_t(match_data_type *)> get_ovector_count
pointer to pcre2_get_ovector_count function for utf-16
Definition pcre2_data.hpp:266
static _PCRE2CPP_PCRE2_FUNC_CONSTEXPR17 mstd::c_func_t< int(const code_type *, uint32_t, void *)> get_info
pointer to pcre2_pattern_info function for utf-16
Definition pcre2_data.hpp:278
static _PCRE2CPP_PCRE2_FUNC_CONSTEXPR17 mstd::c_func_t< match_data_type *(const code_type *, general_ctx_type *)> match_data_from_pattern
pointer to pcre2_match_data_create_from_pattern function for utf-16
Definition pcre2_data.hpp:249
static _PCRE2CPP_CONSTEXPR17 utf_type uft
utf enum value for utf-16
Definition pcre2_data.hpp:232
static _PCRE2CPP_CONSTEXPR17 size_t utf_size
utf byte size for utf-16
Definition pcre2_data.hpp:234
static _PCRE2CPP_PCRE2_FUNC_CONSTEXPR17 mstd::c_func_t< size_t *(match_data_type *)> get_ovector_ptr
pointer to pcre2_get_ovector_pointer function for utf-16
Definition pcre2_data.hpp:263
static _PCRE2CPP_PCRE2_FUNC_CONSTEXPR17 mstd::c_func_t< void(match_data_type *)> match_data_free
pointer to pcre2_match_data_free function for utf-16
Definition pcre2_data.hpp:251
static _PCRE2CPP_PCRE2_FUNC_CONSTEXPR17 mstd::c_func_t< void(code_type *)> code_free
pointer to pcre2_code_free function for utf-16
Definition pcre2_data.hpp:243
static _PCRE2CPP_PCRE2_FUNC_CONSTEXPR17 mstd::c_func_t< int(const code_type *, sptr_type)> substring_number_from_name
pointer to pcre2_substring_number_from_name function for utf-16
Definition pcre2_data.hpp:284
std::u16string string_type
cpp string type for utf-16
Definition pcre2_data.hpp:218
static _PCRE2CPP_PCRE2_FUNC_CONSTEXPR17 mstd::c_func_t< int(const code_type *, sptr_type, size_t, size_t, uint32_t, match_data_type *, match_ctx_type *)> match
pointer to pcre2_match function for utf-16
Definition pcre2_data.hpp:258
Specialization of Translation container from pcre2 library to pcre2cpp for UTF-32.
Definition pcre2_data.hpp:300
static _PCRE2CPP_CONSTEXPR17 utf_type uft
utf enum value for utf-32
Definition pcre2_data.hpp:340
static _PCRE2CPP_PCRE2_FUNC_CONSTEXPR17 mstd::c_func_t< match_data_type *(const code_type *, general_ctx_type *)> match_data_from_pattern
pointer to pcre2_match_data_create_from_pattern function for utf-32
Definition pcre2_data.hpp:357
static _PCRE2CPP_CONSTEXPR17 size_t utf_size
utf byte size for utf-32
Definition pcre2_data.hpp:342
static _PCRE2CPP_PCRE2_FUNC_CONSTEXPR17 mstd::c_func_t< int(const code_type *, sptr_type)> substring_number_from_name
pointer to pcre2_substring_number_from_name function for utf-32
Definition pcre2_data.hpp:392
static _PCRE2CPP_PCRE2_FUNC_CONSTEXPR17 mstd::c_func_t< void(match_data_type *)> match_data_free
pointer to pcre2_match_data_free function for utf-32
Definition pcre2_data.hpp:359
static _PCRE2CPP_PCRE2_FUNC_CONSTEXPR17 mstd::c_func_t< void(code_type *)> code_free
pointer to pcre2_code_free function for utf-32
Definition pcre2_data.hpp:351
static _PCRE2CPP_PCRE2_FUNC_CONSTEXPR17 mstd::c_func_t< int(const code_type *, uint32_t, void *)> get_info
pointer to pcre2_pattern_info function for utf-32
Definition pcre2_data.hpp:386
static _PCRE2CPP_PCRE2_FUNC_CONSTEXPR17 mstd::c_func_t< size_t *(match_data_type *)> get_ovector_ptr
pointer to pcre2_get_ovector_pointer function for utf-32
Definition pcre2_data.hpp:371
static _PCRE2CPP_PCRE2_FUNC_CONSTEXPR17 mstd::c_func_t< int(int, uchar_type *, size_t)> get_error_message
pointer to pcre2_get_error_message function for utf-32
Definition pcre2_data.hpp:380
static _PCRE2CPP_PCRE2_FUNC_CONSTEXPR17 mstd::c_func_t< int(const code_type *, sptr_type, size_t, size_t, uint32_t, match_data_type *, match_ctx_type *)> match
pointer to pcre2_match function for utf-32
Definition pcre2_data.hpp:366
static _PCRE2CPP_PCRE2_FUNC_CONSTEXPR17 mstd::c_func_t< uint32_t(match_data_type *)> get_ovector_count
pointer to pcre2_get_ovector_count function for utf-32
Definition pcre2_data.hpp:374
std::u32string string_type
cpp string type for utf-32
Definition pcre2_data.hpp:326
static _PCRE2CPP_PCRE2_FUNC_CONSTEXPR17 mstd::c_func_t< code_type *(sptr_type, size_t, uint32_t, int *, size_t *, compile_ctx_type *)> compile
pointer to pcre2_compile function for utf-32
Definition pcre2_data.hpp:349
Specialization of Translation container from pcre2 library to pcre2cpp for UTF-8.
Definition pcre2_data.hpp:77
static _PCRE2CPP_PCRE2_FUNC_CONSTEXPR17 mstd::c_func_t< match_data_type *(const code_type *, general_ctx_type *)> match_data_from_pattern
pointer to pcre2_match_data_create_from_pattern function for utf-8
Definition pcre2_data.hpp:141
static _PCRE2CPP_CONSTEXPR17 size_t utf_size
utf byte size for utf-8
Definition pcre2_data.hpp:126
static _PCRE2CPP_PCRE2_FUNC_CONSTEXPR17 mstd::c_func_t< size_t *(match_data_type *)> get_ovector_ptr
pointer to pcre2_get_ovector_pointer function for utf-8
Definition pcre2_data.hpp:155
static _PCRE2CPP_PCRE2_FUNC_CONSTEXPR17 mstd::c_func_t< int(int, uchar_type *, size_t)> get_error_message
pointer to pcre2_get_error_message function for utf-8
Definition pcre2_data.hpp:164
static _PCRE2CPP_CONSTEXPR17 utf_type uft
utf enum value for utf-8
Definition pcre2_data.hpp:124
static _PCRE2CPP_PCRE2_FUNC_CONSTEXPR17 mstd::c_func_t< uint32_t(match_data_type *)> get_ovector_count
pointer to pcre2_get_ovector_count function for utf-8
Definition pcre2_data.hpp:158
static _PCRE2CPP_PCRE2_FUNC_CONSTEXPR17 mstd::c_func_t< code_type *(sptr_type, size_t, uint32_t, int *, size_t *, compile_ctx_type *)> compile
pointer to pcre2_compile function for utf-8
Definition pcre2_data.hpp:133
static _PCRE2CPP_PCRE2_FUNC_CONSTEXPR17 mstd::c_func_t< int(const code_type *, sptr_type)> substring_number_from_name
pointer to pcre2_substring_number_from_name function for utf-8
Definition pcre2_data.hpp:176
static _PCRE2CPP_PCRE2_FUNC_CONSTEXPR17 mstd::c_func_t< void(code_type *)> code_free
pointer to pcre2_code_free function for utf-8
Definition pcre2_data.hpp:135
std::string string_type
cpp string type for utf-8
Definition pcre2_data.hpp:110
static _PCRE2CPP_PCRE2_FUNC_CONSTEXPR17 mstd::c_func_t< int(const code_type *, sptr_type, size_t, size_t, uint32_t, match_data_type *, match_ctx_type *)> match
pointer to pcre2_match function for utf-8
Definition pcre2_data.hpp:150
static _PCRE2CPP_PCRE2_FUNC_CONSTEXPR17 mstd::c_func_t< void(match_data_type *)> match_data_free
pointer to pcre2_match_data_free function for utf-8
Definition pcre2_data.hpp:143
static _PCRE2CPP_PCRE2_FUNC_CONSTEXPR17 mstd::c_func_t< int(const code_type *, uint32_t, void *)> get_info
pointer to pcre2_pattern_info function for utf-8
Definition pcre2_data.hpp:170
Translation container from pcre2 library to pcre2cpp.
Definition pcre2_data.hpp:68