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  * Conversion parameters:
26  * inFile  = 
27  * outPack = gio
28  * outFile = FileAttributeMatcher
29  * strct   = GFileAttributeMatcher
30  * realStrct=
31  * ctorStrct=
32  * clss    = FileAttributeMatcher
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- g_file_attribute_matcher_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * structWrap:
48  * 	- GFileAttributeMatcher* -> FileAttributeMatcher
49  * module aliases:
50  * local aliases:
51  * overrides:
52  * 	- toString
53  */
54 
55 module gio.FileAttributeMatcher;
56 
57 public  import gtkc.giotypes;
58 
59 private import gtkc.gio;
60 private import glib.ConstructionException;
61 private import gobject.ObjectG;
62 
63 private import glib.Str;
64 
65 
66 private import gobject.Boxed;
67 
68 /**
69  * Functionality for manipulating basic metadata for files. GFileInfo
70  * implements methods for getting information that all files should
71  * contain, and allows for manipulation of extended attributes.
72  *
73  * See GFileAttribute for more
74  * information on how GIO handles file attributes.
75  *
76  * To obtain a GFileInfo for a GFile, use g_file_query_info() (or its
77  * async variant). To obtain a GFileInfo for a file input or output
78  * stream, use g_file_input_stream_query_info() or
79  * g_file_output_stream_query_info() (or their async variants).
80  *
81  * To change the actual attributes of a file, you should then set the
82  * attribute in the GFileInfo and call g_file_set_attributes_from_info()
83  * or g_file_set_attributes_async() on a GFile.
84  *
85  * However, not all attributes can be changed in the file. For instance,
86  * the actual size of a file cannot be changed via g_file_info_set_size().
87  * You may call g_file_query_settable_attributes() and
88  * g_file_query_writable_namespaces() to discover the settable attributes
89  * of a particular file at runtime.
90  *
91  * GFileAttributeMatcher allows for searching through a GFileInfo for
92  * attributes.
93  */
94 public class FileAttributeMatcher : Boxed
95 {
96 	
97 	/** the main Gtk struct */
98 	protected GFileAttributeMatcher* gFileAttributeMatcher;
99 	
100 	
101 	/** Get the main Gtk struct */
102 	public GFileAttributeMatcher* getFileAttributeMatcherStruct()
103 	{
104 		return gFileAttributeMatcher;
105 	}
106 	
107 	
108 	/** the main Gtk struct as a void* */
109 	protected void* getStruct()
110 	{
111 		return cast(void*)gFileAttributeMatcher;
112 	}
113 	
114 	/**
115 	 * Sets our main struct and passes it to the parent class
116 	 */
117 	public this (GFileAttributeMatcher* gFileAttributeMatcher)
118 	{
119 		this.gFileAttributeMatcher = gFileAttributeMatcher;
120 	}
121 	
122 	/**
123 	 */
124 	
125 	/**
126 	 * Creates a new file attribute matcher, which matches attributes
127 	 * against a given string. GFileAttributeMatchers are reference
128 	 * counted structures, and are created with a reference count of 1. If
129 	 * the number of references falls to 0, the GFileAttributeMatcher is
130 	 * automatically destroyed.
131 	 * The attribute string should be formatted with specific keys separated
132 	 * from namespaces with a double colon. Several "namespace::key" strings may be
133 	 * concatenated with a single comma (e.g. "standard::type,standard::is-hidden").
134 	 * The wildcard "*" may be used to match all keys and namespaces, or
135 	 * "namespace::*" will match all keys in a given namespace.
136 	 * Params:
137 	 * attributes = an attribute string to match.
138 	 * Throws: ConstructionException GTK+ fails to create the object.
139 	 */
140 	public this (string attributes)
141 	{
142 		// GFileAttributeMatcher * g_file_attribute_matcher_new (const char *attributes);
143 		auto p = g_file_attribute_matcher_new(Str.toStringz(attributes));
144 		if(p is null)
145 		{
146 			throw new ConstructionException("null returned by g_file_attribute_matcher_new(Str.toStringz(attributes))");
147 		}
148 		this(cast(GFileAttributeMatcher*) p);
149 	}
150 	
151 	/**
152 	 * References a file attribute matcher.
153 	 * Returns: a GFileAttributeMatcher.
154 	 */
155 	public FileAttributeMatcher doref()
156 	{
157 		// GFileAttributeMatcher * g_file_attribute_matcher_ref (GFileAttributeMatcher *matcher);
158 		auto p = g_file_attribute_matcher_ref(gFileAttributeMatcher);
159 		
160 		if(p is null)
161 		{
162 			return null;
163 		}
164 		
165 		return ObjectG.getDObject!(FileAttributeMatcher)(cast(GFileAttributeMatcher*) p);
166 	}
167 	
168 	/**
169 	 * Subtracts all attributes of subtract from matcher and returns
170 	 * a matcher that supports those attributes.
171 	 * Note that currently it is not possible to remove a single
172 	 * attribute when the matcher matches the whole namespace - or remove
173 	 * a namespace or attribute when the matcher matches everything. This
174 	 * is a limitation of the current implementation, but may be fixed
175 	 * in the future.
176 	 * Params:
177 	 * subtract = The matcher to subtract
178 	 * Returns: A file attribute matcher matching all attributes of matcher that are not matched by subtract
179 	 */
180 	public FileAttributeMatcher subtract(FileAttributeMatcher subtract)
181 	{
182 		// GFileAttributeMatcher * g_file_attribute_matcher_subtract  (GFileAttributeMatcher *matcher,  GFileAttributeMatcher *subtract);
183 		auto p = g_file_attribute_matcher_subtract(gFileAttributeMatcher, (subtract is null) ? null : subtract.getFileAttributeMatcherStruct());
184 		
185 		if(p is null)
186 		{
187 			return null;
188 		}
189 		
190 		return ObjectG.getDObject!(FileAttributeMatcher)(cast(GFileAttributeMatcher*) p);
191 	}
192 	
193 	/**
194 	 * Unreferences matcher. If the reference count falls below 1,
195 	 * the matcher is automatically freed.
196 	 */
197 	public void unref()
198 	{
199 		// void g_file_attribute_matcher_unref (GFileAttributeMatcher *matcher);
200 		g_file_attribute_matcher_unref(gFileAttributeMatcher);
201 	}
202 	
203 	/**
204 	 * Checks if an attribute will be matched by an attribute matcher. If
205 	 * the matcher was created with the "*" matching string, this function
206 	 * will always return TRUE.
207 	 * Params:
208 	 * attribute = a file attribute key.
209 	 * Returns: TRUE if attribute matches matcher. FALSE otherwise.
210 	 */
211 	public int matches(string attribute)
212 	{
213 		// gboolean g_file_attribute_matcher_matches (GFileAttributeMatcher *matcher,  const char *attribute);
214 		return g_file_attribute_matcher_matches(gFileAttributeMatcher, Str.toStringz(attribute));
215 	}
216 	
217 	/**
218 	 * Checks if a attribute matcher only matches a given attribute. Always
219 	 * returns FALSE if "*" was used when creating the matcher.
220 	 * Params:
221 	 * attribute = a file attribute key.
222 	 * Returns: TRUE if the matcher only matches attribute. FALSE otherwise.
223 	 */
224 	public int matchesOnly(string attribute)
225 	{
226 		// gboolean g_file_attribute_matcher_matches_only  (GFileAttributeMatcher *matcher,  const char *attribute);
227 		return g_file_attribute_matcher_matches_only(gFileAttributeMatcher, Str.toStringz(attribute));
228 	}
229 	
230 	/**
231 	 * Checks if the matcher will match all of the keys in a given namespace.
232 	 * This will always return TRUE if a wildcard character is in use (e.g. if
233 	 * matcher was created with "standard::*" and ns is "standard", or if matcher was created
234 	 * using "*" and namespace is anything.)
235 	 * TODO: this is awkwardly worded.
236 	 * Params:
237 	 * ns = a string containing a file attribute namespace.
238 	 * Returns: TRUE if the matcher matches all of the entries in the given ns, FALSE otherwise.
239 	 */
240 	public int enumerateNamespace(string ns)
241 	{
242 		// gboolean g_file_attribute_matcher_enumerate_namespace  (GFileAttributeMatcher *matcher,  const char *ns);
243 		return g_file_attribute_matcher_enumerate_namespace(gFileAttributeMatcher, Str.toStringz(ns));
244 	}
245 	
246 	/**
247 	 * Gets the next matched attribute from a GFileAttributeMatcher.
248 	 * Returns: a string containing the next attribute or NULL if no more attribute exist.
249 	 */
250 	public string enumerateNext()
251 	{
252 		// const char * g_file_attribute_matcher_enumerate_next  (GFileAttributeMatcher *matcher);
253 		return Str.toString(g_file_attribute_matcher_enumerate_next(gFileAttributeMatcher));
254 	}
255 	
256 	/**
257 	 * Prints what the matcher is matching against. The format will be
258 	 * equal to the format passed to g_file_attribute_matcher_new().
259 	 * The output however, might not be identical, as the matcher may
260 	 * decide to use a different order or omit needless parts.
261 	 * Since 2.32
262 	 * Returns: a string describing the attributes the matcher matches against or NULL if matcher was NULL.
263 	 */
264 	public override string toString()
265 	{
266 		// char * g_file_attribute_matcher_to_string (GFileAttributeMatcher *matcher);
267 		return Str.toString(g_file_attribute_matcher_to_string(gFileAttributeMatcher));
268 	}
269 }