Qore Programming Language - C/C++ Library 2.1.1
Loading...
Searching...
No Matches
QoreRegexInterface.h
1/* -*- mode: c++; indent-tabs-mode: nil -*- */
2/*
3 QoreRegexInterface.h
4
5 Copyright (C) 2003 - 2024 Qore Technologies, s.r.o.
6
7 Permission is hereby granted, free of charge, to any person obtaining a
8 copy of this software and associated documentation files (the "Software"),
9 to deal in the Software without restriction, including without limitation
10 the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 and/or sell copies of the Software, and to permit persons to whom the
12 Software is furnished to do so, subject to the following conditions:
13
14 The above copyright notice and this permission notice shall be included in
15 all copies or substantial portions of the Software.
16
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 DEALINGS IN THE SOFTWARE.
24
25 Note that the Qore library is released under a choice of three open-source
26 licenses: MIT (as above), LGPL 2+, or GPL 2+; see README-LICENSE for more
27 information.
28*/
29
30#ifndef _QORE_REGEX_INTERFACE_H
31#define _QORE_REGEX_INTERFACE_H
32
33#include <memory>
34
35#define QRE_CASELESS 0x00000008u /* C */
36#define QRE_MULTILINE 0x00000400u /* C */
37#define QRE_DOTALL 0x00000020u /* C */
38#define QRE_EXTENDED 0x00000080u /* C */
39#define QRE_ANCHORED 0x80000000u
40#define QRE_DOLLAR_ENDONLY 0x00000010u /* J M D */
41#define QRE_NOTBOL 0x00000001u
42#define QRE_NOTEOL 0x00000002u
43#define QRE_UNGREEDY 0x00040000u /* C */
44#define QRE_NOTEMPTY 0x00000004u /* ) These two must be kept */
45#define QRE_UTF 0x00080000u /* C J M D */
46#define QRE_UCP 0x00020000u /* C J M D */
47
48#define QRE_UTF8 QRE_UTF
49
50
51// note that the following constant is > 32 bits
52#define QRE_GLOBAL 0x100000000LL
53
54class QoreRegexInterface {
55public:
56 DLLEXPORT QoreRegexInterface(ExceptionSink* xsink, const QoreString& pattern);
57 DLLEXPORT QoreRegexInterface(ExceptionSink* xsink, const QoreString& pattern, int64 opts);
58
59 DLLEXPORT QoreRegexInterface(ExceptionSink* xsink, const char* pattern);
60 DLLEXPORT QoreRegexInterface(ExceptionSink* xsink, const char* pattern, int64 opts);
61
62 DLLEXPORT ~QoreRegexInterface();
63
64 DLLEXPORT bool match(const QoreString& target, ExceptionSink* xsink) const;
65
66 DLLEXPORT QoreListNode* extractSubstrings(const QoreString& target, ExceptionSink* xsink) const;
67
68private:
69 class qore_regex_private* priv;
70};
71
72class QoreRegexSubstInterface {
73public:
74 DLLEXPORT QoreRegexSubstInterface(ExceptionSink* xsink, const QoreString& pattern);
75
76 DLLEXPORT QoreRegexSubstInterface(ExceptionSink* xsink, const QoreString& pattern, int64 opts);
77
78 DLLEXPORT QoreRegexSubstInterface(ExceptionSink* xsink, const char* pattern);
79
80 DLLEXPORT QoreRegexSubstInterface(ExceptionSink* xsink, const char* pattern, int64 opts);
81
82 DLLEXPORT ~QoreRegexSubstInterface();
83
84 DLLEXPORT QoreStringNode* subst(const QoreString& target, const QoreString& newstr, ExceptionSink* xsink) const;
85
86 // replaces with an empty string
87 DLLEXPORT QoreStringNode* subst(const QoreString& target, ExceptionSink* xsink) const;
88
89private:
90 class qore_regex_subst_private* priv;
91};
92
93#endif
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition ExceptionSink.h:50
This is the list container type in Qore, dynamically allocated only, reference counted.
Definition QoreListNode.h:52
Qore's string type supported by the QoreEncoding class.
Definition QoreString.h:93
Qore's string value type, reference counted, dynamically-allocated only.
Definition QoreStringNode.h:50
long long int64
64bit integer type, cannot use int64_t here since it breaks the API on some 64-bit systems due to equ...
Definition common.h:266