source: appstream-generator/build/girepo/gio/FileAttributeMatcher.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

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