Add g_key_file_load_from_dirs for looking through a search path for a
[platform/upstream/glib.git] / glib / gregex.h
1 /* GRegex -- regular expression API wrapper around PCRE.
2  *
3  * Copyright (C) 1999, 2000 Scott Wimer
4  * Copyright (C) 2004, Matthias Clasen <mclasen@redhat.com>
5  * Copyright (C) 2005 - 2006, Marco Barisione <marco@barisione.org>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  */
21
22 #ifndef __G_REGEX_H__
23 #define __G_REGEX_H__
24
25 #include <glib/gerror.h>
26 #include <glib/gstring.h>
27
28 G_BEGIN_DECLS
29
30 typedef enum
31 {
32   G_REGEX_ERROR_COMPILE,
33   G_REGEX_ERROR_OPTIMIZE,
34   G_REGEX_ERROR_REPLACE,
35   G_REGEX_ERROR_MATCH
36 } GRegexError;
37
38 #define G_REGEX_ERROR g_regex_error_quark ()
39
40 GQuark g_regex_error_quark (void);
41
42 /* Remember to update G_REGEX_COMPILE_MASK in gregex.c after
43  * adding a new flag. */
44 typedef enum
45 {
46   G_REGEX_CASELESS          = 1 << 0,
47   G_REGEX_MULTILINE         = 1 << 1,
48   G_REGEX_DOTALL            = 1 << 2,
49   G_REGEX_EXTENDED          = 1 << 3,
50   G_REGEX_ANCHORED          = 1 << 4,
51   G_REGEX_DOLLAR_ENDONLY    = 1 << 5,
52   G_REGEX_UNGREEDY          = 1 << 9,
53   G_REGEX_RAW               = 1 << 11,
54   G_REGEX_NO_AUTO_CAPTURE   = 1 << 12,
55   G_REGEX_DUPNAMES          = 1 << 19,
56   G_REGEX_NEWLINE_CR        = 1 << 20,
57   G_REGEX_NEWLINE_LF        = 1 << 21,
58   G_REGEX_NEWLINE_CRLF      = G_REGEX_NEWLINE_CR | G_REGEX_NEWLINE_LF
59 } GRegexCompileFlags;
60
61 /* Remember to update G_REGEX_MATCH_MASK in gregex.c after
62  * adding a new flag. */
63 typedef enum
64 {
65   G_REGEX_MATCH_ANCHORED      = 1 << 4,
66   G_REGEX_MATCH_NOTBOL        = 1 << 7,
67   G_REGEX_MATCH_NOTEOL        = 1 << 8,
68   G_REGEX_MATCH_NOTEMPTY      = 1 << 10,
69   G_REGEX_MATCH_PARTIAL       = 1 << 15,
70   G_REGEX_MATCH_NEWLINE_CR    = 1 << 20,
71   G_REGEX_MATCH_NEWLINE_LF    = 1 << 21,
72   G_REGEX_MATCH_NEWLINE_CRLF  = G_REGEX_MATCH_NEWLINE_CR | G_REGEX_MATCH_NEWLINE_LF,
73   G_REGEX_MATCH_NEWLINE_ANY   = 1 << 22,
74 } GRegexMatchFlags;
75
76 typedef struct _GRegex  GRegex;
77
78 typedef gboolean (*GRegexEvalCallback) (const GRegex*, const gchar*, GString*, gpointer);
79
80
81 GRegex           *g_regex_new                   (const gchar         *pattern,
82                                                  GRegexCompileFlags   compile_options,
83                                                  GRegexMatchFlags     match_options,
84                                                  GError             **error);
85 void              g_regex_free                  (GRegex              *regex);
86 gboolean          g_regex_optimize              (GRegex              *regex,
87                                                  GError             **error);
88 GRegex           *g_regex_copy                  (const GRegex        *regex);
89 const gchar      *g_regex_get_pattern           (const GRegex        *regex);
90 void              g_regex_clear                 (GRegex              *regex);
91 gboolean          g_regex_match_simple          (const gchar         *pattern,
92                                                  const gchar         *string,
93                                                  GRegexCompileFlags   compile_options,
94                                                  GRegexMatchFlags     match_options);
95 gboolean          g_regex_match                 (GRegex              *regex,
96                                                  const gchar         *string,
97                                                  GRegexMatchFlags     match_options);
98 gboolean          g_regex_match_full            (GRegex              *regex,
99                                                  const gchar         *string,
100                                                  gssize               string_len,
101                                                  gint                 start_position,
102                                                  GRegexMatchFlags     match_options,
103                                                  GError             **error);
104 gboolean          g_regex_match_next            (GRegex              *regex,
105                                                  const gchar         *string,
106                                                  GRegexMatchFlags     match_options);
107 gboolean          g_regex_match_next_full       (GRegex              *regex,
108                                                  const gchar         *string,
109                                                  gssize               string_len,
110                                                  gint                 start_position,
111                                                  GRegexMatchFlags     match_options,
112                                                  GError             **error);
113 gboolean          g_regex_match_all             (GRegex              *regex,
114                                                  const gchar         *string,
115                                                  GRegexMatchFlags     match_options);
116 gboolean          g_regex_match_all_full        (GRegex              *regex,
117                                                  const gchar         *string,
118                                                  gssize               string_len,
119                                                  gint                 start_position,
120                                                  GRegexMatchFlags     match_options,
121                                                  GError             **error);
122 gint              g_regex_get_match_count       (const GRegex        *regex);
123 gboolean          g_regex_is_partial_match      (const GRegex        *regex);
124 gchar            *g_regex_fetch                 (const GRegex        *regex,
125                                                  gint                 match_num,
126                                                  const gchar         *string);
127 gboolean          g_regex_fetch_pos             (const GRegex        *regex,
128                                                  gint                 match_num,
129                                                  gint                *start_pos,
130                                                  gint                *end_pos);
131 gchar            *g_regex_fetch_named           (const GRegex        *regex,
132                                                  const gchar         *name,
133                                                  const gchar         *string);
134 gboolean          g_regex_fetch_named_pos       (const GRegex        *regex,
135                                                  const gchar         *name,
136                                                  gint                *start_pos,
137                                                  gint                *end_pos);
138 gchar           **g_regex_fetch_all             (const GRegex        *regex,
139                                                  const gchar         *string);
140 gint              g_regex_get_string_number     (const GRegex        *regex, 
141                                                  const gchar         *name);
142 gchar           **g_regex_split_simple          (const gchar         *pattern,
143                                                  const gchar         *string,
144                                                  GRegexCompileFlags   compile_options,
145                                                  GRegexMatchFlags     match_options);
146 gchar           **g_regex_split                 (GRegex              *regex,
147                                                  const gchar         *string,
148                                                  GRegexMatchFlags     match_options);
149 gchar           **g_regex_split_full            (GRegex              *regex,
150                                                  const gchar         *string,
151                                                  gssize               string_len,
152                                                  gint                 start_position,
153                                                  GRegexMatchFlags     match_options,
154                                                  gint                 max_tokens,
155                                                  GError             **error);
156 gchar            *g_regex_split_next            (GRegex              *regex,
157                                                  const gchar         *string,
158                                                  GRegexMatchFlags     match_options);
159 gchar            *g_regex_split_next_full       (GRegex              *regex,
160                                                  const gchar         *string,
161                                                  gssize               string_len,
162                                                  gint                 start_position,
163                                                  GRegexMatchFlags     match_options,
164                                                  GError             **error);
165 gchar            *g_regex_expand_references     (GRegex              *regex,
166                                                  const gchar         *string,
167                                                  const gchar         *string_to_expand,
168                                                  GError             **error);
169 gchar            *g_regex_replace               (GRegex              *regex,
170                                                  const gchar         *string,
171                                                  gssize               string_len,
172                                                  gint                 start_position,
173                                                  const gchar         *replacement,
174                                                  GRegexMatchFlags     match_options,
175                                                  GError             **error);
176 gchar            *g_regex_replace_literal       (GRegex              *regex,
177                                                  const gchar         *string,
178                                                  gssize               string_len,
179                                                  gint                 start_position,
180                                                  const gchar         *replacement,
181                                                  GRegexMatchFlags     match_options,
182                                                  GError             **error);
183 gchar            *g_regex_replace_eval          (GRegex              *regex,
184                                                  const gchar         *string,
185                                                  gssize               string_len,
186                                                  gint                 start_position,
187                                                  GRegexMatchFlags     match_options,
188                                                  GRegexEvalCallback   eval,
189                                                  gpointer             user_data,
190                                                  GError             **error);
191 gchar            *g_regex_escape_string         (const gchar         *string,
192                                                  gint                 length);
193
194
195 G_END_DECLS
196
197
198 #endif  /*  __G_REGEX_H__ */