/usr/include/d/gtkd-3/glib/Pattern.d is in libgtkd-3-dev 3.7.5-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | /*
* This file is part of gtkD.
*
* gtkD is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version, with
* some exceptions, please read the COPYING file.
*
* gtkD is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with gtkD; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
*/
// generated automatically - do not change
// find conversion definition on APILookup.txt
// implement new conversion functionalities on the wrap.utils pakage
module glib.Pattern;
private import glib.ConstructionException;
private import glib.Str;
private import glib.c.functions;
public import glib.c.types;
public import gtkc.glibtypes;
private import gtkd.Loader;
/**
* A GPatternSpec struct is the 'compiled' form of a pattern. This
* structure is opaque and its fields cannot be accessed directly.
*/
public class Pattern
{
/** the main Gtk struct */
protected GPatternSpec* gPatternSpec;
protected bool ownedRef;
/** Get the main Gtk struct */
public GPatternSpec* getPatternStruct(bool transferOwnership = false)
{
if (transferOwnership)
ownedRef = false;
return gPatternSpec;
}
/** the main Gtk struct as a void* */
protected void* getStruct()
{
return cast(void*)gPatternSpec;
}
/**
* Sets our main struct and passes it to the parent class.
*/
public this (GPatternSpec* gPatternSpec, bool ownedRef = false)
{
this.gPatternSpec = gPatternSpec;
this.ownedRef = ownedRef;
}
~this ()
{
if ( Linker.isLoaded(LIBRARY_GLIB) && ownedRef )
g_pattern_spec_free(gPatternSpec);
}
/**
* Compares two compiled pattern specs and returns whether they will
* match the same set of strings.
*
* Params:
* pspec2 = another #GPatternSpec
*
* Returns: Whether the compiled patterns are equal
*/
public bool equal(Pattern pspec2)
{
return g_pattern_spec_equal(gPatternSpec, (pspec2 is null) ? null : pspec2.getPatternStruct()) != 0;
}
/**
* Frees the memory allocated for the #GPatternSpec.
*/
public void free()
{
g_pattern_spec_free(gPatternSpec);
ownedRef = false;
}
/**
* Compiles a pattern to a #GPatternSpec.
*
* Params:
* pattern = a zero-terminated UTF-8 encoded string
*
* Returns: a newly-allocated #GPatternSpec
*
* Throws: ConstructionException GTK+ fails to create the object.
*/
public this(string pattern)
{
auto p = g_pattern_spec_new(Str.toStringz(pattern));
if(p is null)
{
throw new ConstructionException("null returned by new");
}
this(cast(GPatternSpec*) p);
}
/**
* Matches a string against a compiled pattern. Passing the correct
* length of the string given is mandatory. The reversed string can be
* omitted by passing %NULL, this is more efficient if the reversed
* version of the string to be matched is not at hand, as
* g_pattern_match() will only construct it if the compiled pattern
* requires reverse matches.
*
* Note that, if the user code will (possibly) match a string against a
* multitude of patterns containing wildcards, chances are high that
* some patterns will require a reversed string. In this case, it's
* more efficient to provide the reversed string to avoid multiple
* constructions thereof in the various calls to g_pattern_match().
*
* Note also that the reverse of a UTF-8 encoded string can in general
* not be obtained by g_strreverse(). This works only if the string
* does not contain any multibyte characters. GLib offers the
* g_utf8_strreverse() function to reverse UTF-8 encoded strings.
*
* Params:
* pspec = a #GPatternSpec
* stringLength = the length of @string (in bytes, i.e. strlen(),
* not g_utf8_strlen())
* str = the UTF-8 encoded string to match
* stringReversed = the reverse of @string or %NULL
*
* Returns: %TRUE if @string matches @pspec
*/
public static bool patternMatch(Pattern pspec, uint stringLength, string str, string stringReversed)
{
return g_pattern_match((pspec is null) ? null : pspec.getPatternStruct(), stringLength, Str.toStringz(str), Str.toStringz(stringReversed)) != 0;
}
/**
* Matches a string against a pattern given as a string. If this
* function is to be called in a loop, it's more efficient to compile
* the pattern once with g_pattern_spec_new() and call
* g_pattern_match_string() repeatedly.
*
* Params:
* pattern = the UTF-8 encoded pattern
* str = the UTF-8 encoded string to match
*
* Returns: %TRUE if @string matches @pspec
*/
public static bool patternMatchSimple(string pattern, string str)
{
return g_pattern_match_simple(Str.toStringz(pattern), Str.toStringz(str)) != 0;
}
/**
* Matches a string against a compiled pattern. If the string is to be
* matched against more than one pattern, consider using
* g_pattern_match() instead while supplying the reversed string.
*
* Params:
* pspec = a #GPatternSpec
* str = the UTF-8 encoded string to match
*
* Returns: %TRUE if @string matches @pspec
*/
public static bool patternMatchString(Pattern pspec, string str)
{
return g_pattern_match_string((pspec is null) ? null : pspec.getPatternStruct(), Str.toStringz(str)) != 0;
}
}
|