1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gio.FileAttributeMatcher; 26 27 private import glib.ConstructionException; 28 private import glib.Str; 29 private import gobject.ObjectG; 30 private import gtkc.gio; 31 public import gtkc.giotypes; 32 33 34 /** 35 * Determines if a string matches a file attribute. 36 */ 37 public class FileAttributeMatcher 38 { 39 /** the main Gtk struct */ 40 protected GFileAttributeMatcher* gFileAttributeMatcher; 41 42 /** Get the main Gtk struct */ 43 public GFileAttributeMatcher* getFileAttributeMatcherStruct() 44 { 45 return gFileAttributeMatcher; 46 } 47 48 /** the main Gtk struct as a void* */ 49 protected void* getStruct() 50 { 51 return cast(void*)gFileAttributeMatcher; 52 } 53 54 /** 55 * Sets our main struct and passes it to the parent class. 56 */ 57 public this (GFileAttributeMatcher* gFileAttributeMatcher) 58 { 59 this.gFileAttributeMatcher = gFileAttributeMatcher; 60 } 61 62 /** 63 */ 64 65 public static GType getType() 66 { 67 return g_file_attribute_matcher_get_type(); 68 } 69 70 /** 71 * Creates a new file attribute matcher, which matches attributes 72 * against a given string. #GFileAttributeMatchers are reference 73 * counted structures, and are created with a reference count of 1. If 74 * the number of references falls to 0, the #GFileAttributeMatcher is 75 * automatically destroyed. 76 * 77 * The @attribute string should be formatted with specific keys separated 78 * from namespaces with a double colon. Several "namespace::key" strings may be 79 * concatenated with a single comma (e.g. "standard::type,standard::is-hidden"). 80 * The wildcard "*" may be used to match all keys and namespaces, or 81 * "namespace::*" will match all keys in a given namespace. 82 * 83 * ## Examples of file attribute matcher strings and results 84 * 85 * - `"*"`: matches all attributes. 86 * - `"standard::is-hidden"`: matches only the key is-hidden in the 87 * standard namespace. 88 * - `"standard::type,unix::*"`: matches the type key in the standard 89 * namespace and all keys in the unix namespace. 90 * 91 * Params: 92 * attributes = an attribute string to match. 93 * 94 * Return: a #GFileAttributeMatcher 95 * 96 * Throws: ConstructionException GTK+ fails to create the object. 97 */ 98 public this(string attributes) 99 { 100 auto p = g_file_attribute_matcher_new(Str.toStringz(attributes)); 101 102 if(p is null) 103 { 104 throw new ConstructionException("null returned by new"); 105 } 106 107 this(cast(GFileAttributeMatcher*) p); 108 } 109 110 /** 111 * Checks if the matcher will match all of the keys in a given namespace. 112 * This will always return %TRUE if a wildcard character is in use (e.g. if 113 * matcher was created with "standard::*" and @ns is "standard", or if matcher was created 114 * using "*" and namespace is anything.) 115 * 116 * TODO: this is awkwardly worded. 117 * 118 * Params: 119 * ns = a string containing a file attribute namespace. 120 * 121 * Return: %TRUE if the matcher matches all of the entries 122 * in the given @ns, %FALSE otherwise. 123 */ 124 public bool enumerateNamespace(string ns) 125 { 126 return g_file_attribute_matcher_enumerate_namespace(gFileAttributeMatcher, Str.toStringz(ns)) != 0; 127 } 128 129 /** 130 * Gets the next matched attribute from a #GFileAttributeMatcher. 131 * 132 * Return: a string containing the next attribute or %NULL if 133 * no more attribute exist. 134 */ 135 public string enumerateNext() 136 { 137 return Str.toString(g_file_attribute_matcher_enumerate_next(gFileAttributeMatcher)); 138 } 139 140 /** 141 * Checks if an attribute will be matched by an attribute matcher. If 142 * the matcher was created with the "*" matching string, this function 143 * will always return %TRUE. 144 * 145 * Params: 146 * attribute = a file attribute key. 147 * 148 * Return: %TRUE if @attribute matches @matcher. %FALSE otherwise. 149 */ 150 public bool matches(string attribute) 151 { 152 return g_file_attribute_matcher_matches(gFileAttributeMatcher, Str.toStringz(attribute)) != 0; 153 } 154 155 /** 156 * Checks if a attribute matcher only matches a given attribute. Always 157 * returns %FALSE if "*" was used when creating the matcher. 158 * 159 * Params: 160 * attribute = a file attribute key. 161 * 162 * Return: %TRUE if the matcher only matches @attribute. %FALSE otherwise. 163 */ 164 public bool matchesOnly(string attribute) 165 { 166 return g_file_attribute_matcher_matches_only(gFileAttributeMatcher, Str.toStringz(attribute)) != 0; 167 } 168 169 /** 170 * References a file attribute matcher. 171 * 172 * Return: a #GFileAttributeMatcher. 173 */ 174 public FileAttributeMatcher doref() 175 { 176 auto p = g_file_attribute_matcher_ref(gFileAttributeMatcher); 177 178 if(p is null) 179 { 180 return null; 181 } 182 183 return ObjectG.getDObject!(FileAttributeMatcher)(cast(GFileAttributeMatcher*) p); 184 } 185 186 /** 187 * Subtracts all attributes of @subtract from @matcher and returns 188 * a matcher that supports those attributes. 189 * 190 * Note that currently it is not possible to remove a single 191 * attribute when the @matcher matches the whole namespace - or remove 192 * a namespace or attribute when the matcher matches everything. This 193 * is a limitation of the current implementation, but may be fixed 194 * in the future. 195 * 196 * Params: 197 * subtract = The matcher to subtract 198 * 199 * Return: A file attribute matcher matching all attributes of 200 * @matcher that are not matched by @subtract 201 */ 202 public FileAttributeMatcher subtract(FileAttributeMatcher subtract) 203 { 204 auto p = g_file_attribute_matcher_subtract(gFileAttributeMatcher, (subtract is null) ? null : subtract.getFileAttributeMatcherStruct()); 205 206 if(p is null) 207 { 208 return null; 209 } 210 211 return ObjectG.getDObject!(FileAttributeMatcher)(cast(GFileAttributeMatcher*) p); 212 } 213 214 /** 215 * Prints what the matcher is matching against. The format will be 216 * equal to the format passed to g_file_attribute_matcher_new(). 217 * The output however, might not be identical, as the matcher may 218 * decide to use a different order or omit needless parts. 219 * 220 * Return: a string describing the attributes the matcher matches 221 * against or %NULL if @matcher was %NULL. 222 * 223 * Since: 2.32 224 */ 225 public override string toString() 226 { 227 return Str.toString(g_file_attribute_matcher_to_string(gFileAttributeMatcher)); 228 } 229 230 /** 231 * Unreferences @matcher. If the reference count falls below 1, 232 * the @matcher is automatically freed. 233 */ 234 public void unref() 235 { 236 g_file_attribute_matcher_unref(gFileAttributeMatcher); 237 } 238 }