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+ #pragma once
15+ #ifndef _PCRE2CPP_MATCH_ERROR_CODES_HPP_
16+ #define _PCRE2CPP_MATCH_ERROR_CODES_HPP_
17+
18+ #include < pcre2cpp/config.hpp>
19+
20+ #if !_PCRE2CPP_HAS_CXX17
21+ _PCRE2CPP_ERROR (" This is only available for c++17 and greater!" );
22+ #else
23+
24+ #include < pcre2cpp/types.hpp>
25+
26+ namespace pcre2cpp {
27+ enum class match_error_codes : int32_t {
28+ None = 1 , // No error (default)
29+ NoMatch = PCRE2_ERROR_NOMATCH , // The subject string did not match the pattern.
30+ Partial = PCRE2_ERROR_PARTIAL , // The subject string did not match, but it did match partially.
31+ BadMagic = PCRE2_ERROR_BADMAGIC , /* PCRE2 stores a 4-byte "magic number" at the start of the compiled code,
32+ to catch the case when it is passed a junk pointer.
33+ This is the error that is returned when the magic number is not present
34+ */
35+ BadMode =
36+ PCRE2_ERROR_BADMODE , /* This error is given when a compiled pattern is passed
37+ to a function in a library of a different code unit width, for example,
38+ a pattern compiled by the 8-bit library is passed to a 16-bit or 32-bit library function.
39+ */
40+ BadOffset = PCRE2_ERROR_BADOFFSET , // The value of startoffset was greater than the length of the subject.
41+ BadOption = PCRE2_ERROR_BADOPTION , // An unrecognized bit was set in the options argument.
42+ BadUTFOffset = PCRE2_ERROR_BADUTFOFFSET , /* The UTF code unit sequence that was passed as a subject was checked
43+ and found to be valid (the match_option::NoUTFCheck option was not set),
44+ but the value of startoffset did not point to the beginning of a
45+ UTF character or the end of the subject.
46+ */
47+ Callout = PCRE2_ERROR_CALLOUT , /* This error is never generated by pcre2_match() itself.
48+ It is provided for use by callout functions that want to cause
49+ pcre2_match() or pcre2_callout_enumerate() to return a distinctive error code.
50+ */
51+ DepthLimit = PCRE2_ERROR_DEPTHLIMIT , // The nested backtracking depth limit was reached.
52+ HeapLimit = PCRE2_ERROR_HEAPLIMIT , // The heap limit was reached.
53+ Internal =
54+ PCRE2_ERROR_INTERNAL , /* An unexpected internal error has occurred.
55+ This error could be caused by a bug in PCRE2 or by overwriting of the compiled pattern.
56+ */
57+ JITStackLimit = PCRE2_ERROR_JIT_STACKLIMIT , /* This error is returned when a pattern that was successfully
58+ studied using JIT is being matched, but the memory available
59+ for the just-in-time processing stack is not large enough.
60+ */
61+ MatchLimit = PCRE2_ERROR_MATCHLIMIT , // The backtracking match limit was reached.
62+ NoMemory = PCRE2_ERROR_NOMEMORY , /* Heap memory is used to remember backtracking points.
63+ This error is given when the memory allocation function (default or custom) fails.
64+ Note that a different error, PCRE2_ERROR_HEAPLIMIT, is given if the amount of memory
65+ needed exceeds the heap limit. match_error_codes::NoMemory is also returned
66+ if match_options_bits::CopyMatchedSubject is set and memory allocation fails.
67+ */
68+ Null = PCRE2_ERROR_NULL , // Either the code, subject, or match_data argument was passed as nullptr.
69+ RecurseLoop =
70+ PCRE2_ERROR_RECURSELOOP /* This error is returned when pcre2_match() detects a recursion loop within the pattern.
71+ Specifically, it means that either the whole pattern or a capture group has been called
72+ recursively for the second time at the same position in the subject string.
73+ Some simple patterns that might do this are detected and faulted at compile time,
74+ but more complicated cases, in particular mutual recursions between two different groups,
75+ cannot be detected until matching is attempted.
76+ */
77+ };
78+ } // namespace pcre2cpp
79+ #endif
80+ #endif
0 commit comments