|
1 | 1 | # pcre2cpp |
2 | 2 |
|
3 | | -**pcre2cpp** is a C++ wrapper for the PCRE2 (Perl Compatible Regular Expressions) library written in C. It provides an object-oriented interface for the original PCRE2 library, while maintaining the same functionality and behavior. [DOCS](https://maipa01.github.io/pcre2cpp/html) |
| 3 | +**pcre2cpp** is a C++ wrapper for the PCRE2 (Perl Compatible Regular Expressions) library written in C. It provides an |
| 4 | +object-oriented interface for the original PCRE2 library, while maintaining the same functionality and |
| 5 | +behavior. [DOCS](https://maipa01.github.io/pcre2cpp/html "Documentation") |
4 | 6 |
|
5 | 7 | ## Features |
6 | 8 |
|
7 | 9 | - Object-oriented interface to PCRE2 10.47. |
8 | | -- Compatible with C++17 and C++20. |
| 10 | +- Compatible with C++17 and newer. |
9 | 11 | - Easy to use regular expression matching with built-in result capturing. |
10 | 12 |
|
11 | 13 | ## Requirements |
|
15 | 17 |
|
16 | 18 | ## Options |
17 | 19 |
|
18 | | -| CMAKE Option / #define | Description | Default | |
19 | | -|:------------------------------------------|:-----------------------------------------------|:-------:| |
20 | | -| **PCRE2CPP_ENABLE_CXX20** | Enables C++20 features | OFF | |
21 | | -| **PCRE2CPP_DISABLE_ASSERT_ON_RELEASE** | Disables assert on release builds | OFF | |
22 | | -| **PCRE2CPP_CHANGE_ASSERTS_TO_EXCEPTIONS** | Changes every assert to exceptions in pcre2cpp | OFF | |
23 | | -| **PCRE2CPP_DISABLE_UTF8** | Disables UTF-8 support | OFF | |
24 | | -| **PCRE2CPP_DISABLE_UTF16** | Disables UTF-16 support | OFF | |
25 | | -| **PCRE2CPP_DISABLE_UTF32** | Disables UTF-32 support | OFF | |
| 20 | +### Compilation defines options |
| 21 | + |
| 22 | +You can enable option using `#define option_name` or use cmake `set(option_name ON CACHE BOOL)` |
| 23 | + |
| 24 | +| Cmake option/C++ define Name | Description | Default | |
| 25 | +|:----------------------------------------|:-----------------------------------------------|:-------:| |
| 26 | +| `PCRE2CPP_ENABLE_CXX20` | Enables C++20 features | OFF | |
| 27 | +| `PCRE2CPP_DISABLE_ASSERT_ON_RELEASE` | Disables assert on release builds | OFF | |
| 28 | +| `PCRE2CPP_CHANGE_ASSERTS_TO_EXCEPTIONS` | Changes every assert to exceptions in pcre2cpp | OFF | |
| 29 | +| `PCRE2CPP_DISABLE_UTF8` | Disables UTF-8 support | OFF | |
| 30 | +| `PCRE2CPP_DISABLE_UTF16` | Disables UTF-16 support | OFF | |
| 31 | +| `PCRE2CPP_DISABLE_UTF32` | Disables UTF-32 support | OFF | |
| 32 | + |
| 33 | +### External libraries options |
| 34 | + |
| 35 | +If you want to use external libraries not installed by project using CPM |
| 36 | + |
| 37 | +| Cmake option Name | Description | Default | |
| 38 | +|:--------------------------|:-----------------------------------------------------------------|:-------:| |
| 39 | +| `PCRE2CPP_MSTD_EXTERNAL` | Uses users own mstd library (tested and compatible with: 1.5.2) | OFF | |
| 40 | +| `PCRE2CPP_PCRE2_EXTERNAL` | Uses users own pcre2 library (tested and compatible with: 10.47) | OFF | |
| 41 | + |
| 42 | +### Project developing options |
| 43 | + |
| 44 | +These options are used while testing or changing code in project |
| 45 | + |
| 46 | +| Cmake option Name | Description | Default | |
| 47 | +|:-------------------------------|:-------------------------------------------------------|:-------------------------:| |
| 48 | +| `PCRE2CPP_BUILD_TESTS` | Build tests | `${PROJECT_IS_TOP_LEVEL}` | |
| 49 | +| `PCRE2CPP_BUILD_BENCHMARK` | Build benchmark | `${PROJECT_IS_TOP_LEVEL}` | |
| 50 | +| `PCRE2CPP_BUILD_COVERAGE` | Enable coverage reporting | `${PROJECT_IS_TOP_LEVEL}` | |
| 51 | +| `PCRE2CPP_BUILD_DOCUMENTATION` | Build documentation | `${PROJECT_IS_TOP_LEVEL}` | |
| 52 | +| `PCRE2CPP_ENABLE_CLANG_TIDY` | Enables clang-tidy checks | `${PROJECT_IS_TOP_LEVEL}` | |
| 53 | +| `PCRE2CPP_INSTALL` | Enables installation of this project | `${PROJECT_IS_TOP_LEVEL}` | |
| 54 | +| `PCRE2CPP_INSTALL_TEST` | This is only to test if installation of pcre2cpp works | OFF | |
26 | 55 |
|
27 | 56 | ## Benchmarks |
28 | 57 |
|
29 | 58 | ### Compilation (10,000 iterations) |
| 59 | + |
30 | 60 | | No. | std::regex (ms) | PCRE2 (ms) | pcre2cpp (ms) | |
31 | 61 | |:--------|:---------------:|:-----------:|:-------------:| |
32 | 62 | | **1.** | 72,9598 | **16,1092** | 18,5241 | |
|
47 | 77 | | **pcre2cpp** | 18,3117 | - | 0,0018 | - | |
48 | 78 |
|
49 | 79 | ### Match (10,000 iterations) |
| 80 | + |
50 | 81 | | No. | std::regex (ms) | PCRE2 (ms) | pcre2cpp (ms) | |
51 | 82 | |:--------|:---------------:|:----------:|:-------------:| |
52 | 83 | | **1.** | 200,0510 | **7,6231** | 7,6295 | |
|
67 | 98 | | **pcre2cpp** | 7,9713 | - | **0,0008** | - | |
68 | 99 |
|
69 | 100 | ### Match with all results (10,000 iterations) |
| 101 | + |
70 | 102 | | No. | std::regex (ms) | PCRE2 (ms) | pcre2cpp (ms) | |
71 | 103 | |:--------|:---------------:|:-----------:|:-------------:| |
72 | 104 | | **1.** | 200,0060 | **9,7453** | 11,9927 | |
|
88 | 120 |
|
89 | 121 | ## Installation |
90 | 122 |
|
91 | | -To use **pcre2cpp**, simply download the latest release. There are no additional dependencies required. |
| 123 | +After installing, you can use `find_package(pcre2cpp)`. |
92 | 124 |
|
93 | | -1. Download the latest release of **pcre2cpp**. |
94 | | -2. Link the `pcre2cpp` library statically in your build system (e.g., `CMake` or `Make`). |
| 125 | +### Components |
95 | 126 |
|
96 | | -Example for linking in `CMake`: |
97 | | -```cmake |
98 | | -find_package(pcre2cpp REQUIRED) |
99 | | -target_link_libraries(your_project_name PRIVATE pcre2cpp) |
100 | | -``` |
| 127 | +You can also include components `find_pcakage(pcre2cpp COMPONENTS comp)`. They work the same way |
| 128 | +as [Compilation defines options](#compilation-defines-options), but |
| 129 | +they provide separate components you need to include. |
| 130 | + |
| 131 | +| Component Name | Option | Target Name | |
| 132 | +|:---------------------|:----------------------------------------|:-------------------------------| |
| 133 | +| CXX20 | `PCRE2CPP_ENABLE_CXX20` | pcre2cpp::CXX20 | |
| 134 | +| NO_ASSERT_ON_RELEASE | `PCRE2CPP_DISABLE_ASSERT_ON_RELEASE` | pcre2cpp::NO_ASSERT_ON_RELEASE | |
| 135 | +| EXCEPTIONS | `PCRE2CPP_CHANGE_ASSERTS_TO_EXCEPTIONS` | pcre2cpp::EXCEPTIONS | |
| 136 | +| NO_UTF8 | `PCRE2CPP_DISABLE_UTF8` | pcre2cpp::NO_UTF8 | |
| 137 | +| NO_UTF16 | `PCRE2CPP_DISABLE_UTF16` | pcre2cpp::NO_UTF16 | |
| 138 | +| NO_UTF32 | `PCRE2CPP_DISABLE_UTF32` | pcre2cpp::NO_UTF32 | |
101 | 139 |
|
102 | 140 | ## Example Usage |
103 | 141 |
|
@@ -293,12 +331,15 @@ int main() { |
293 | 331 | ``` |
294 | 332 |
|
295 | 333 | ## Offsets Graph |
296 | | - |
| 334 | + |
| 335 | + |
297 | 336 |
|
298 | 337 | ## License |
299 | 338 |
|
300 | | -This project is licensed under the **BSD 3-Clause License with Attribution Requirement**. For more details, check the [LICENSE](./LICENSE) file. |
| 339 | +This project is licensed under the **BSD 3-Clause License with Attribution Requirement**. For more details, check |
| 340 | +the [LICENSE](./LICENSE "License") file. |
301 | 341 |
|
302 | 342 | ## Acknowledgments |
303 | 343 |
|
304 | | -This project includes code from the [PCRE2 library](https://github.com/PhilipHazel/pcre2), distributed under the BSD License. |
| 344 | +This project includes code from the [PCRE2 library](https://github.com/PhilipHazel/pcre2 "PCRE2 github repo"), distributed under the BSD |
| 345 | +License. |
0 commit comments