1 /* 2 * Distributed under the Boost Software License, Version 1.0. 3 * (See accompanying file LICENSE_1_0.txt or copy at 4 * http://www.boost.org/LICENSE_1_0.txt) 5 */ 6 module glib.gmarkup; 7 8 import glib.gtypes; 9 import glib.gerror; 10 import glib.gslist; 11 12 import core.stdc.stdarg; 13 14 15 enum GMarkupError 16 { 17 G_MARKUP_ERROR_BAD_UTF8, 18 G_MARKUP_ERROR_EMPTY, 19 G_MARKUP_ERROR_PARSE, 20 /* The following are primarily intended for specific GMarkupParser 21 * implementations to set. 22 */ 23 G_MARKUP_ERROR_UNKNOWN_ELEMENT, 24 G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, 25 G_MARKUP_ERROR_INVALID_CONTENT, 26 G_MARKUP_ERROR_MISSING_ATTRIBUTE 27 } 28 29 //enum G_MARKUP_ERROR = g_markup_error_quark (); 30 31 extern (C) 32 GQuark g_markup_error_quark (); 33 34 enum GMarkupParseFlags 35 { 36 G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG = 1 << 0, 37 G_MARKUP_TREAT_CDATA_AS_TEXT = 1 << 1, 38 G_MARKUP_PREFIX_ERROR_POSITION = 1 << 2, 39 G_MARKUP_IGNORE_QUALIFIED = 1 << 3 40 } 41 42 struct GMarkupParseContext; 43 44 extern (C) { 45 46 struct GMarkupParser 47 { 48 /* Called for open tags <foo bar="baz"> */ 49 void function (GMarkupParseContext *context, 50 const(gchar) *element_name, 51 const(gchar) **attribute_names, 52 const(gchar) **attribute_values, 53 gpointer user_data, 54 GError **error) start_element; 55 56 void function (GMarkupParseContext *context, 57 const(gchar) *element_name, 58 gpointer user_data, 59 GError **error) end_element; 60 61 /* Called for character data */ 62 /* text is not nul-terminated */ 63 void function (GMarkupParseContext *context, 64 const(gchar) *text, 65 gsize text_len, 66 gpointer user_data, 67 GError **error) text; 68 69 /* Called for strings that should be re-saved verbatim in this same 70 * position, but are not otherwise interpretable. At the moment 71 * this includes comments and processing instructions. 72 */ 73 /* text is not nul-terminated. */ 74 void function (GMarkupParseContext *context, 75 const(gchar) *passthrough_text, 76 gsize text_len, 77 gpointer user_data, 78 GError **error) passthrough; 79 80 /* Called on error, including one set by other 81 * methods in the vtable. The GError should not be freed. 82 */ 83 void function (GMarkupParseContext *context, 84 GError *error, 85 gpointer user_data) error; 86 } 87 88 89 GMarkupParseContext *g_markup_parse_context_new (const(GMarkupParser) *parser, 90 GMarkupParseFlags flags, 91 gpointer user_data, 92 GDestroyNotify user_data_dnotify); 93 94 GMarkupParseContext *g_markup_parse_context_ref (GMarkupParseContext *context); 95 96 void g_markup_parse_context_unref (GMarkupParseContext *context); 97 98 void g_markup_parse_context_free (GMarkupParseContext *context); 99 100 gboolean g_markup_parse_context_parse (GMarkupParseContext *context, 101 const(gchar) *text, 102 gssize text_len, 103 GError **error); 104 105 void g_markup_parse_context_push (GMarkupParseContext *context, 106 const(GMarkupParser) *parser, 107 gpointer user_data); 108 109 gpointer g_markup_parse_context_pop (GMarkupParseContext *context); 110 111 112 gboolean g_markup_parse_context_end_parse (GMarkupParseContext *context, 113 GError **error); 114 115 const(gchar) * g_markup_parse_context_get_element (GMarkupParseContext *context); 116 117 const(GSList) * g_markup_parse_context_get_element_stack (GMarkupParseContext *context); 118 119 120 void g_markup_parse_context_get_position (GMarkupParseContext *context, 121 gint *line_number, 122 gint *char_number); 123 124 gpointer g_markup_parse_context_get_user_data (GMarkupParseContext *context); 125 126 127 gchar* g_markup_escape_text (const(gchar) *text, 128 gssize length); 129 130 131 gchar *g_markup_printf_escaped (const(char) *format, 132 ...); 133 134 gchar *g_markup_vprintf_escaped (const(char) *format, 135 va_list args); 136 137 } 138 139 enum GMarkupCollectType 140 { 141 G_MARKUP_COLLECT_INVALID, 142 G_MARKUP_COLLECT_STRING, 143 G_MARKUP_COLLECT_STRDUP, 144 G_MARKUP_COLLECT_BOOLEAN, 145 G_MARKUP_COLLECT_TRISTATE, 146 147 G_MARKUP_COLLECT_OPTIONAL = (1 << 16) 148 } 149 150 151 extern (C) 152 gboolean g_markup_collect_attributes (const(gchar) *element_name, 153 const(gchar) **attribute_names, 154 const(gchar) **attribute_values, 155 GError **error, 156 GMarkupCollectType first_type, 157 const(gchar) *first_attr, 158 ...); 159