source: appstream-generator/build/girepo/glib/ScannerG.d @ 4841

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

Initial release

File size: 9.6 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 glib.ScannerG;
22
23private import gi.glib;
24public  import gi.glibtypes;
25private import glib.ConstructionException;
26private import glib.Str;
27
28
29/**
30 * The data structure representing a lexical scanner.
31 *
32 * You should set @input_name after creating the scanner, since
33 * it is used by the default message handler when displaying
34 * warnings and errors. If you are scanning a file, the filename
35 * would be a good choice.
36 *
37 * The @user_data and @max_parse_errors fields are not used.
38 * If you need to associate extra data with the scanner you
39 * can place them here.
40 *
41 * If you want to use your own message handler you can set the
42 * @msg_handler field. The type of the message handler function
43 * is declared by #GScannerMsgFunc.
44 */
45public class ScannerG
46{
47        /** the main Gtk struct */
48        protected GScanner* gScanner;
49        protected bool ownedRef;
50
51        /** Get the main Gtk struct */
52        public GScanner* getScannerGStruct()
53        {
54                return gScanner;
55        }
56
57        /** the main Gtk struct as a void* */
58        protected void* getStruct()
59        {
60                return cast(void*)gScanner;
61        }
62
63        /**
64         * Sets our main struct and passes it to the parent class.
65         */
66        public this (GScanner* gScanner, bool ownedRef = false)
67        {
68                this.gScanner = gScanner;
69                this.ownedRef = ownedRef;
70        }
71
72
73        /**
74         * Returns the current line in the input stream (counting
75         * from 1). This is the line of the last token parsed via
76         * g_scanner_get_next_token().
77         *
78         * Returns: the current line
79         */
80        public uint curLine()
81        {
82                return g_scanner_cur_line(gScanner);
83        }
84
85        /**
86         * Returns the current position in the current line (counting
87         * from 0). This is the position of the last token parsed via
88         * g_scanner_get_next_token().
89         *
90         * Returns: the current position on the line
91         */
92        public uint curPosition()
93        {
94                return g_scanner_cur_position(gScanner);
95        }
96
97        /**
98         * Gets the current token type. This is simply the @token
99         * field in the #GScanner structure.
100         *
101         * Returns: the current token type
102         */
103        public GTokenType curToken()
104        {
105                return g_scanner_cur_token(gScanner);
106        }
107
108        /**
109         * Gets the current token value. This is simply the @value
110         * field in the #GScanner structure.
111         *
112         * Returns: the current token value
113         */
114        public GTokenValue curValue()
115        {
116                return g_scanner_cur_value(gScanner);
117        }
118
119        /**
120         * Frees all memory used by the #GScanner.
121         */
122        public void destroy()
123        {
124                g_scanner_destroy(gScanner);
125        }
126
127        /**
128         * Returns %TRUE if the scanner has reached the end of
129         * the file or text buffer.
130         *
131         * Returns: %TRUE if the scanner has reached the end of
132         *     the file or text buffer
133         */
134        public bool eof()
135        {
136                return g_scanner_eof(gScanner) != 0;
137        }
138
139        /**
140         * Parses the next token just like g_scanner_peek_next_token()
141         * and also removes it from the input stream. The token data is
142         * placed in the @token, @value, @line, and @position fields of
143         * the #GScanner structure.
144         *
145         * Returns: the type of the token
146         */
147        public GTokenType getNextToken()
148        {
149                return g_scanner_get_next_token(gScanner);
150        }
151
152        /**
153         * Prepares to scan a file.
154         *
155         * Params:
156         *     inputFd = a file descriptor
157         */
158        public void inputFile(int inputFd)
159        {
160                g_scanner_input_file(gScanner, inputFd);
161        }
162
163        /**
164         * Prepares to scan a text buffer.
165         *
166         * Params:
167         *     text = the text buffer to scan
168         *     textLen = the length of the text buffer
169         */
170        public void inputText(string text, uint textLen)
171        {
172                g_scanner_input_text(gScanner, Str.toStringz(text), textLen);
173        }
174
175        /**
176         * Looks up a symbol in the current scope and return its value.
177         * If the symbol is not bound in the current scope, %NULL is
178         * returned.
179         *
180         * Params:
181         *     symbol = the symbol to look up
182         *
183         * Returns: the value of @symbol in the current scope, or %NULL
184         *     if @symbol is not bound in the current scope
185         */
186        public void* lookupSymbol(string symbol)
187        {
188                return g_scanner_lookup_symbol(gScanner, Str.toStringz(symbol));
189        }
190
191        /**
192         * Parses the next token, without removing it from the input stream.
193         * The token data is placed in the @next_token, @next_value, @next_line,
194         * and @next_position fields of the #GScanner structure.
195         *
196         * Note that, while the token is not removed from the input stream
197         * (i.e. the next call to g_scanner_get_next_token() will return the
198         * same token), it will not be reevaluated. This can lead to surprising
199         * results when changing scope or the scanner configuration after peeking
200         * the next token. Getting the next token after switching the scope or
201         * configuration will return whatever was peeked before, regardless of
202         * any symbols that may have been added or removed in the new scope.
203         *
204         * Returns: the type of the token
205         */
206        public GTokenType peekNextToken()
207        {
208                return g_scanner_peek_next_token(gScanner);
209        }
210
211        /**
212         * Adds a symbol to the given scope.
213         *
214         * Params:
215         *     scopeId = the scope id
216         *     symbol = the symbol to add
217         *     value = the value of the symbol
218         */
219        public void scopeAddSymbol(uint scopeId, string symbol, void* value)
220        {
221                g_scanner_scope_add_symbol(gScanner, scopeId, Str.toStringz(symbol), value);
222        }
223
224        /**
225         * Calls the given function for each of the symbol/value pairs
226         * in the given scope of the #GScanner. The function is passed
227         * the symbol and value of each pair, and the given @user_data
228         * parameter.
229         *
230         * Params:
231         *     scopeId = the scope id
232         *     func = the function to call for each symbol/value pair
233         *     userData = user data to pass to the function
234         */
235        public void scopeForeachSymbol(uint scopeId, GHFunc func, void* userData)
236        {
237                g_scanner_scope_foreach_symbol(gScanner, scopeId, func, userData);
238        }
239
240        /**
241         * Looks up a symbol in a scope and return its value. If the
242         * symbol is not bound in the scope, %NULL is returned.
243         *
244         * Params:
245         *     scopeId = the scope id
246         *     symbol = the symbol to look up
247         *
248         * Returns: the value of @symbol in the given scope, or %NULL
249         *     if @symbol is not bound in the given scope.
250         */
251        public void* scopeLookupSymbol(uint scopeId, string symbol)
252        {
253                return g_scanner_scope_lookup_symbol(gScanner, scopeId, Str.toStringz(symbol));
254        }
255
256        /**
257         * Removes a symbol from a scope.
258         *
259         * Params:
260         *     scopeId = the scope id
261         *     symbol = the symbol to remove
262         */
263        public void scopeRemoveSymbol(uint scopeId, string symbol)
264        {
265                g_scanner_scope_remove_symbol(gScanner, scopeId, Str.toStringz(symbol));
266        }
267
268        /**
269         * Sets the current scope.
270         *
271         * Params:
272         *     scopeId = the new scope id
273         *
274         * Returns: the old scope id
275         */
276        public uint setScope(uint scopeId)
277        {
278                return g_scanner_set_scope(gScanner, scopeId);
279        }
280
281        /**
282         * Rewinds the filedescriptor to the current buffer position
283         * and blows the file read ahead buffer. This is useful for
284         * third party uses of the scanners filedescriptor, which hooks
285         * onto the current scanning position.
286         */
287        public void syncFileOffset()
288        {
289                g_scanner_sync_file_offset(gScanner);
290        }
291
292        /**
293         * Outputs a message through the scanner's msg_handler,
294         * resulting from an unexpected token in the input stream.
295         * Note that you should not call g_scanner_peek_next_token()
296         * followed by g_scanner_unexp_token() without an intermediate
297         * call to g_scanner_get_next_token(), as g_scanner_unexp_token()
298         * evaluates the scanner's current token (not the peeked token)
299         * to construct part of the message.
300         *
301         * Params:
302         *     expectedToken = the expected token
303         *     identifierSpec = a string describing how the scanner's user
304         *         refers to identifiers (%NULL defaults to "identifier").
305         *         This is used if @expected_token is %G_TOKEN_IDENTIFIER or
306         *         %G_TOKEN_IDENTIFIER_NULL.
307         *     symbolSpec = a string describing how the scanner's user refers
308         *         to symbols (%NULL defaults to "symbol"). This is used if
309         *         @expected_token is %G_TOKEN_SYMBOL or any token value greater
310         *         than %G_TOKEN_LAST.
311         *     symbolName = the name of the symbol, if the scanner's current
312         *         token is a symbol.
313         *     message = a message string to output at the end of the
314         *         warning/error, or %NULL.
315         *     isError = if %TRUE it is output as an error. If %FALSE it is
316         *         output as a warning.
317         */
318        public void unexpToken(GTokenType expectedToken, string identifierSpec, string symbolSpec, string symbolName, string message, int isError)
319        {
320                g_scanner_unexp_token(gScanner, expectedToken, Str.toStringz(identifierSpec), Str.toStringz(symbolSpec), Str.toStringz(symbolName), Str.toStringz(message), isError);
321        }
322
323        /**
324         * Creates a new #GScanner.
325         *
326         * The @config_templ structure specifies the initial settings
327         * of the scanner, which are copied into the #GScanner
328         * @config field. If you pass %NULL then the default settings
329         * are used.
330         *
331         * Params:
332         *     configTempl = the initial scanner settings
333         *
334         * Returns: the new #GScanner
335         *
336         * Throws: ConstructionException GTK+ fails to create the object.
337         */
338        public this(GScannerConfig* configTempl)
339        {
340                auto p = g_scanner_new(configTempl);
341               
342                if(p is null)
343                {
344                        throw new ConstructionException("null returned by new");
345                }
346               
347                this(cast(GScanner*) p);
348        }
349}
Note: See TracBrowser for help on using the repository browser.