2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD 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.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = glib-Glob-style-pattern-matching.html
28 * strct = GPatternSpec
47 * - GPatternSpec* -> Pattern
58 import tango
.io
.Stdout
; // use the tango loging?
62 private import gtkc
.glibtypes
;
64 private import gtkc
.glib
;
67 private import glib
.Str
;
74 * The g_pattern_match* functions match a string
75 * against a pattern containing '*' and '?' wildcards with similar semantics
76 * as the standard glob() function: '*' matches an arbitrary, possibly empty,
77 * string, '?' matches an arbitrary character.
78 * Note that in contrast to glob(), the '/' character
79 * can be matched by the wildcards, there are no
80 * '[...]' character ranges and '*' and '?' can not
81 * be escaped to include them literally in a pattern.
82 * When multiple strings must be matched against the same pattern, it
83 * is better to compile the pattern to a GPatternSpec using
84 * g_pattern_spec_new() and use g_pattern_match_string() instead of
85 * g_pattern_match_simple(). This avoids the overhead of repeated
86 * pattern compilation.
91 /** the main Gtk struct */
92 protected GPatternSpec
* gPatternSpec
;
95 public GPatternSpec
* getPatternStruct()
101 /** the main Gtk struct as a void* */
102 protected void* getStruct()
104 return cast(void*)gPatternSpec
;
108 * Sets our main struct and passes it to the parent class
110 public this (GPatternSpec
* gPatternSpec
)
114 if ( gPatternSpec
is null )
119 Stdout("struct gPatternSpec is null on constructor").newline
;
123 printf("struct gPatternSpec is null on constructor");
130 assert(gPatternSpec
!is null, "struct gPatternSpec is null on constructor");
132 this.gPatternSpec
= gPatternSpec
;
140 * Compiles a pattern to a GPatternSpec.
142 * a zero-terminated UTF-8 encoded string.
144 * a newly-allocated GPatternSpec.
146 public this (char[] pattern
)
148 // GPatternSpec* g_pattern_spec_new (const gchar *pattern);
149 this(cast(GPatternSpec
*)g_pattern_spec_new(Str
.toStringz(pattern
)) );
153 * Frees the memory allocated for the GPatternSpec.
159 // void g_pattern_spec_free (GPatternSpec *pspec);
160 g_pattern_spec_free(gPatternSpec
);
164 * Compares two compiled pattern specs and returns whether they
165 * will match the same set of strings.
169 * another GPatternSpec.
171 * Whether the compiled patterns are equal.
173 public int equal(Pattern pspec2
)
175 // gboolean g_pattern_spec_equal (GPatternSpec *pspec1, GPatternSpec *pspec2);
176 return g_pattern_spec_equal(gPatternSpec
, (pspec2
is null) ?
null : pspec2
.getPatternStruct());
180 * Matches a string against a compiled pattern. Passing the correct length of the
181 * string given is mandatory. The reversed string can be omitted by passing NULL,
182 * this is more efficient if the reversed version of the string to be matched is
183 * not at hand, as g_pattern_match() will only construct it if the compiled pattern
184 * requires reverse matches.
185 * Note that, if the user code will (possibly) match a string against a multitude
186 * of patterns containing wildcards, chances are high that some patterns will
187 * require a reversed string. In this case, it's more efficient to provide the
188 * reversed string to avoid multiple constructions thereof in the various calls to
190 * Note also that the reverse of a UTF-8 encoded string can in general
191 * not be obtained by g_strreverse().
192 * This works only if the string doesn't contain any multibyte characters.
193 * Glib offers the g_utf_strreverse() function to reverse UTF-8 encoded strings.
197 * the length of string.
199 * the UTF-8 encoded string to match.
201 * the reverse of string or NULL.
203 * TRUE if string matches pspec.
205 public int gPatternMatch(uint stringLength
, char[] string
, char[] stringReversed
)
207 // gboolean g_pattern_match (GPatternSpec *pspec, guint string_length, const gchar *string, const gchar *string_reversed);
208 return g_pattern_match(gPatternSpec
, stringLength
, Str
.toStringz(string
), Str
.toStringz(stringReversed
));
212 * Matches a string against a compiled pattern. If the string is to
213 * be matched against more than one pattern, consider using
214 * g_pattern_match() instead while supplying the reversed string.
218 * the UTF-8 encoded string to match.
220 * TRUE if string matches pspec.
222 public int string(char[] string
)
224 // gboolean g_pattern_match_string (GPatternSpec *pspec, const gchar *string);
225 return g_pattern_match_string(gPatternSpec
, Str
.toStringz(string
));
229 * Matches a string against a pattern given as a string.
230 * If this function is to be called in a loop, it's more efficient to compile
231 * the pattern once with g_pattern_spec_new() and call g_pattern_match_string()
234 * the UTF-8 encoded pattern.
236 * the UTF-8 encoded string to match.
238 * TRUE if string matches pspec.
240 public static int simple(char[] pattern
, char[] string
)
242 // gboolean g_pattern_match_simple (const gchar *pattern, const gchar *string);
243 return g_pattern_match_simple(Str
.toStringz(pattern
), Str
.toStringz(string
));