1 /*
2  * Copyright © 2015 Christian Persch
3  *
4  * This library is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published
6  * by the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library.  If not, see <https://www.gnu.org/licenses/>.
16  */
17 
18 #pragma once
19 
20 #if !defined (__VTE_VTE_H_INSIDE__) && !defined (VTE_COMPILATION)
21 #error "Only <vte/vte.h> can be included directly."
22 #endif
23 
24 #include <glib.h>
25 #include <glib-object.h>
26 
27 #include "vtemacros.h"
28 
29 G_BEGIN_DECLS
30 
31 typedef struct _VteRegex VteRegex;
32 
33 #define VTE_TYPE_REGEX (vte_regex_get_type())
34 
35 _VTE_PUBLIC
36 GType vte_regex_get_type (void);
37 
38 #define VTE_REGEX_ERROR (vte_regex_error_quark())
39 
40 _VTE_PUBLIC
41 GQuark vte_regex_error_quark (void);
42 
43 /* This is PCRE2_NO_UTF_CHECK | PCRE2_UTF | PCRE2_NEVER_BACKSLASH_C */
44 #define VTE_REGEX_FLAGS_DEFAULT (0x00080000u | 0x40000000u | 0x00100000u)
45 
46 _VTE_PUBLIC
47 VteRegex *vte_regex_ref      (VteRegex *regex) _VTE_CXX_NOEXCEPT _VTE_GNUC_NONNULL(1);
48 
49 _VTE_PUBLIC
50 VteRegex *vte_regex_unref    (VteRegex *regex) _VTE_CXX_NOEXCEPT _VTE_GNUC_NONNULL(1);
51 
52 _VTE_PUBLIC
53 VteRegex *vte_regex_new_for_match (const char *pattern,
54                                    gssize      pattern_length,
55                                    guint32     flags,
56                                    GError    **error) _VTE_CXX_NOEXCEPT _VTE_GNUC_NONNULL(1);
57 
58 _VTE_PUBLIC
59 VteRegex *vte_regex_new_for_search (const char *pattern,
60                                     gssize      pattern_length,
61                                     guint32     flags,
62                                     GError    **error) _VTE_CXX_NOEXCEPT _VTE_GNUC_NONNULL(1);
63 
64 _VTE_PUBLIC
65 gboolean  vte_regex_jit     (VteRegex *regex,
66                              guint32   flags,
67                              GError  **error) _VTE_CXX_NOEXCEPT _VTE_GNUC_NONNULL(1);
68 
69 _VTE_PUBLIC
70 char *vte_regex_substitute(VteRegex *regex,
71                            const char *subject,
72                            const char *replacement,
73                            guint32 flags,
74                            GError **error) _VTE_CXX_NOEXCEPT _VTE_GNUC_NONNULL(1) _VTE_GNUC_NONNULL(2) _VTE_GNUC_NONNULL(3) G_GNUC_MALLOC;
75 
76 G_DEFINE_AUTOPTR_CLEANUP_FUNC(VteRegex, vte_regex_unref)
77 
78 G_END_DECLS
79