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 public static GType getType() 65 { 66 return g_file_attribute_matcher_get_type(); 67 } 68 69 /** 70 * Creates a new file attribute matcher, which matches attributes 71 * against a given string. #GFileAttributeMatchers are reference 72 * counted structures, and are created with a reference count of 1. If 73 * the number of references falls to 0, the #GFileAttributeMatcher is 74 * automatically destroyed. 75 * 76 * The @attribute string should be formatted with specific keys separated 77 * from namespaces with a double colon. Several "namespace::key" strings may be 78 * concatenated with a single comma (e.g. "standard::type,standard::is-hidden"). 79 * The wildcard "*" may be used to match all keys and namespaces, or 80 * "namespace::*" will match all keys in a given namespace. 81 * 82 * ## Examples of file attribute matcher strings and results 83 * 84 * - `"*"`: matches all attributes. 85 * - `"standard::is-hidden"`: matches only the key is-hidden in the 86 * standard namespace. 87 * - `"standard::type,unix::*"`: matches the type key in the standard 88 * namespace and all keys in the unix namespace. 89 * 90 * Params: 91 * attributes = an attribute string to match. 92 * 93 * Return: a #GFileAttributeMatcher 94 * 95 * Throws: ConstructionException GTK+ fails to create the object. 96 */ 97 public this(string attributes) 98 { 99 auto p = g_file_attribute_matcher_new(Str.toStringz(attributes)); 100 101 if(p is null) 102 { 103 throw new ConstructionException("null returned by new"); 104 } 105 106 this(cast(GFileAttributeMatcher*) p); 107 } 108 109 /** 110 * Checks if the matcher will match all of the keys in a given namespace. 111 * This will always return %TRUE if a wildcard character is in use (e.g. if 112 * matcher was created with "standard::*" and @ns is "standard", or if matcher was created 113 * using "*" and namespace is anything.) 114 * 115 * TODO: this is awkwardly worded. 116 * 117 * Params: 118 * ns = a string containing a file attribute namespace. 119 * 120 * Return: %TRUE if the matcher matches all of the entries 121 * in the given @ns, %FALSE otherwise. 122 */ 123 public bool enumerateNamespace(string ns) 124 { 125 return g_file_attribute_matcher_enumerate_namespace(gFileAttributeMatcher, Str.toStringz(ns)) != 0; 126 } 127 128 /** 129 * Gets the next matched attribute from a #GFileAttributeMatcher. 130 * 131 * Return: a string containing the next attribute or %NULL if 132 * no more attribute exist. 133 */ 134 public string enumerateNext() 135 { 136 return Str.toString(g_file_attribute_matcher_enumerate_next(gFileAttributeMatcher)); 137 } 138 139 /** 140 * Checks if an attribute will be matched by an attribute matcher. If 141 * the matcher was created with the "*" matching string, this function 142 * will always return %TRUE. 143 * 144 * Params: 145 * attribute = a file attribute key. 146 * 147 * Return: %TRUE if @attribute matches @matcher. %FALSE otherwise. 148 */ 149 public bool matches(string attribute) 150 { 151 return g_file_attribute_matcher_matches(gFileAttributeMatcher, Str.toStringz(attribute)) != 0; 152 } 153 154 /** 155 * Checks if a attribute matcher only matches a given attribute. Always 156 * returns %FALSE if "*" was used when creating the matcher. 157 * 158 * Params: 159 * attribute = a file attribute key. 160 * 161 * Return: %TRUE if the matcher only matches @attribute. %FALSE otherwise. 162 */ 163 public bool matchesOnly(string attribute) 164 { 165 return g_file_attribute_matcher_matches_only(gFileAttributeMatcher, Str.toStringz(attribute)) != 0; 166 } 167 168 /** 169 * References a file attribute matcher. 170 * 171 * Return: a #GFileAttributeMatcher. 172 */ 173 public FileAttributeMatcher doref() 174 { 175 auto p = g_file_attribute_matcher_ref(gFileAttributeMatcher); 176 177 if(p is null) 178 { 179 return null; 180 } 181 182 return ObjectG.getDObject!(FileAttributeMatcher)(cast(GFileAttributeMatcher*) p); 183 } 184 185 /** 186 * Subtracts all attributes of @subtract from @matcher and returns 187 * a matcher that supports those attributes. 188 * 189 * Note that currently it is not possible to remove a single 190 * attribute when the @matcher matches the whole namespace - or remove 191 * a namespace or attribute when the matcher matches everything. This 192 * is a limitation of the current implementation, but may be fixed 193 * in the future. 194 * 195 * Params: 196 * subtract = The matcher to subtract 197 * 198 * Return: A file attribute matcher matching all attributes of 199 * @matcher that are not matched by @subtract 200 */ 201 public FileAttributeMatcher subtract(FileAttributeMatcher subtract) 202 { 203 auto p = g_file_attribute_matcher_subtract(gFileAttributeMatcher, (subtract is null) ? null : subtract.getFileAttributeMatcherStruct()); 204 205 if(p is null) 206 { 207 return null; 208 } 209 210 return ObjectG.getDObject!(FileAttributeMatcher)(cast(GFileAttributeMatcher*) p); 211 } 212 213 /** 214 * Prints what the matcher is matching against. The format will be 215 * equal to the format passed to g_file_attribute_matcher_new(). 216 * The output however, might not be identical, as the matcher may 217 * decide to use a different order or omit needless parts. 218 * 219 * Return: a string describing the attributes the matcher matches 220 * against or %NULL if @matcher was %NULL. 221 * 222 * Since: 2.32 223 */ 224 public override string toString() 225 { 226 return Str.toString(g_file_attribute_matcher_to_string(gFileAttributeMatcher)); 227 } 228 229 /** 230 * Unreferences @matcher. If the reference count falls below 1, 231 * the @matcher is automatically freed. 232 */ 233 public void unref() 234 { 235 g_file_attribute_matcher_unref(gFileAttributeMatcher); 236 } 237 }