I've no idea here...
[gtkD.git] / src / glib / SimpleXML.d
blobc84f390bf52293d751bac45e348db2d0a33177f3
1 /*
2 * This file is part of duit.
4 * duit 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 2.1 of the License, or
7 * (at your option) any later version.
9 * duit 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.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with duit; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = glib-Simple-XML-Subset-Parser.html
26 * outPack = glib
27 * outFile = SimpleXML
28 * strct = GMarkupParseContext
29 * realStrct=
30 * ctorStrct=
31 * clss = SimpleXML
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - g_markup_parse_context_
40 * omit structs:
41 * omit prefixes:
42 * omit code:
43 * imports:
44 * - glib.ErrorG
45 * - glib.Dataset
46 * - glib.Str
47 * structWrap:
48 * - GDataset* -> Dataset
49 * local aliases:
52 module glib.SimpleXML;
54 private import glib.glibtypes;
56 private import lib.glib;
58 private import glib.ErrorG;
59 private import glib.Dataset;
60 private import glib.Str;
62 /**
63 * Description
64 * The "GMarkup" parser is intended to parse a simple markup format
65 * that's a subset of XML. This is a small, efficient, easy-to-use
66 * parser. It should not be used if you expect to interoperate with other
67 * applications generating full-scale XML. However, it's very useful for
68 * application data files, config files, etc. where you know your
69 * application will be the only one writing the file. Full-scale XML
70 * parsers should be able to parse the subset used by GMarkup, so you can
71 * easily migrate to full-scale XML at a later time if the need arises.
72 * GMarkup is not guaranteed to signal an error on all invalid XML; the
73 * parser may accept documents that an XML parser would not. However, XML
74 * documents which are not well-formed[4] are not considered valid GMarkup
75 * documents.
76 * Simplifications to XML include:
77 * Only UTF-8 encoding is allowed.
78 * No user-defined entities.
79 * Processing instructions, comments and the doctype declaration are "passed
80 * through" but are not interpreted in any way.
81 * No DTD or validation.
82 * The markup format does support:
83 * Elements
84 * Attributes
85 * 5 standard entities: amp; lt; gt; quot; apos;
86 * Character references
87 * Sections marked as CDATA
89 public class SimpleXML
92 /** the main Gtk struct */
93 protected GMarkupParseContext* gMarkupParseContext;
96 public GMarkupParseContext* getSimpleXMLStruct()
98 return gMarkupParseContext;
102 /** the main Gtk struct as a void* */
103 protected void* getStruct()
105 return cast(void*)gMarkupParseContext;
109 * Sets our main struct and passes it to the parent class
111 public this (GMarkupParseContext* gMarkupParseContext)
113 this.gMarkupParseContext = gMarkupParseContext;
125 * Escapes text so that the markup parser will parse it verbatim.
126 * Less than, greater than, ampersand, etc. are replaced with the
127 * corresponding entities. This function would typically be used
128 * when writing out a file to be parsed with the markup parser.
129 * Note that this function doesn't protect whitespace and line endings
130 * from being processed according to the XML rules for normalization
131 * of line endings and attribute values.
132 * text:
133 * some valid UTF-8 text
134 * length:
135 * length of text in bytes, or -1 if the text is nul-terminated
136 * Returns:
137 * a newly allocated string with the escaped text
139 public static char[] gMarkupEscapeText(char[] text, int length)
141 // gchar* g_markup_escape_text (const gchar *text, gssize length);
142 return Str.toString(g_markup_escape_text(Str.toStringz(text), length) );
146 * Formats arguments according to format, escaping
147 * all string and character arguments in the fashion
148 * of g_markup_escape_text(). This is useful when you
149 * want to insert literal strings into XML-style markup
150 * output, without having to worry that the strings
151 * might themselves contain markup.
152 * const char *store = "Fortnum Mason";
153 * const char *item = "Tea";
154 * char *output;
155 * output = g_markup_printf_escaped ("<purchase>"
156 * "<store>%s</store>"
157 * "<item>%s</item>"
158 * "</purchase>",
159 * store, item);
160 * format:
161 * printf() style format string
162 * ...:
163 * the arguments to insert in the format string
164 * Returns:
165 * newly allocated result from formatting
166 * operation. Free with g_free().
167 * Since 2.4
169 public static char[] gMarkupPrintfEscaped(char[] format, ... )
171 // gchar* g_markup_printf_escaped (const char *format, ...);
172 return Str.toString(g_markup_printf_escaped(Str.toStringz(format)) );
176 * Formats the data in args according to format, escaping
177 * all string and character arguments in the fashion
178 * of g_markup_escape_text(). See g_markup_printf_escaped().
179 * format:
180 * printf() style format string
181 * args:
182 * variable argument list, similar to vprintf()
183 * Returns:
184 * newly allocated result from formatting
185 * operation. Free with g_free().
186 * Since 2.4
188 public static char[] gMarkupVprintfEscaped(char[] format, void* args)
190 // gchar* g_markup_vprintf_escaped (const char *format, va_list args);
191 return Str.toString(g_markup_vprintf_escaped(Str.toStringz(format), args) );
195 * Signals to the GMarkupParseContext that all data has been
196 * fed into the parse context with g_markup_parse_context_parse().
197 * This function reports an error if the document isn't complete,
198 * for example if elements are still open.
199 * context:
200 * a GMarkupParseContext
201 * error:
202 * return location for a GError
203 * Returns:
204 * TRUE on success, FALSE if an error was set
206 public int endParse(GError** error)
208 // gboolean g_markup_parse_context_end_parse (GMarkupParseContext *context, GError **error);
209 return g_markup_parse_context_end_parse(gMarkupParseContext, error);
213 * Frees a GMarkupParseContext. Can't be called from inside
214 * one of the GMarkupParser functions.
215 * context:
216 * a GMarkupParseContext
218 public void free()
220 // void g_markup_parse_context_free (GMarkupParseContext *context);
221 g_markup_parse_context_free(gMarkupParseContext);
225 * Retrieves the current line number and the number of the character on
226 * that line. Intended for use in error messages; there are no strict
227 * semantics for what constitutes the "current" line number other than
228 * "the best number we could come up with for error messages."
229 * context:
230 * a GMarkupParseContext
231 * line_number:
232 * return location for a line number, or NULL
233 * char_number:
234 * return location for a char-on-line number, or NULL
236 public void getPosition(int* lineNumber, int* charNumber)
238 // void g_markup_parse_context_get_position (GMarkupParseContext *context, gint *line_number, gint *char_number);
239 g_markup_parse_context_get_position(gMarkupParseContext, lineNumber, charNumber);
243 * Retrieves the name of the currently open element.
244 * context:
245 * a GMarkupParseContext
246 * Returns:
247 * the name of the currently open element, or NULL
248 * Since 2.2
250 public char[] getElement()
252 // const gchar* g_markup_parse_context_get_element (GMarkupParseContext *context);
253 return Str.toString(g_markup_parse_context_get_element(gMarkupParseContext) );
257 * Creates a new parse context. A parse context is used to parse
258 * marked-up documents. You can feed any number of documents into
259 * a context, as long as no errors occur; once an error occurs,
260 * the parse context can't continue to parse text (you have to free it
261 * and create a new parse context).
262 * parser:
263 * a GMarkupParser
264 * flags:
265 * one or more GMarkupParseFlags
266 * user_data:
267 * user data to pass to GMarkupParser functions
268 * user_data_dnotify:
269 * user data destroy notifier called when the parse context is freed
270 * Returns:
271 * a new GMarkupParseContext
273 public this (GMarkupParser* parser, GMarkupParseFlags flags, void* userData, GDestroyNotify userDataDnotify)
275 // GMarkupParseContext* g_markup_parse_context_new (const GMarkupParser *parser, GMarkupParseFlags flags, gpointer user_data, GDestroyNotify user_data_dnotify);
276 this(cast(GMarkupParseContext*)g_markup_parse_context_new(parser, flags, userData, userDataDnotify) );
280 * Feed some data to the GMarkupParseContext. The data need not
281 * be valid UTF-8; an error will be signaled if it's invalid.
282 * The data need not be an entire document; you can feed a document
283 * into the parser incrementally, via multiple calls to this function.
284 * Typically, as you receive data from a network connection or file,
285 * you feed each received chunk of data into this function, aborting
286 * the process if an error occurs. Once an error is reported, no further
287 * data may be fed to the GMarkupParseContext; all errors are fatal.
288 * context:
289 * a GMarkupParseContext
290 * text:
291 * chunk of text to parse
292 * text_len:
293 * length of text in bytes
294 * error:
295 * return location for a GError
296 * Returns:
297 * FALSE if an error occurred, TRUE on success
298 * [4] XML specification
300 public int parse(char[] text, int textLen, GError** error)
302 // gboolean g_markup_parse_context_parse (GMarkupParseContext *context, const gchar *text, gssize text_len, GError **error);
303 return g_markup_parse_context_parse(gMarkupParseContext, Str.toStringz(text), textLen, error);