gmarkup.h

Go to the documentation of this file.
00001 /* gmarkup.h - Simple XML-like string parser/writer
00002  *
00003  *  Copyright 2000 Red Hat, Inc.
00004  *
00005  * GLib is free software; you can redistribute it and/or modify it
00006  * under the terms of the GNU Lesser General Public License as
00007  * published by the Free Software Foundation; either version 2 of the
00008  * License, or (at your option) any later version.
00009  *
00010  * GLib is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Lesser General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General Public
00016  * License along with GLib; see the file COPYING.LIB.  If not,
00017  * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018  *   Boston, MA 02111-1307, USA.
00019  */
00020 
00021 #ifndef __G_MARKUP_H__
00022 #define __G_MARKUP_H__
00023 
00024 #include <gerror.h>
00025 
00026 #ifdef __cplusplus
00027 extern "C"
00028 {
00029 #endif
00030 
00031 typedef enum
00032 {
00033   G_MARKUP_ERROR_BAD_UTF8,
00034   G_MARKUP_ERROR_EMPTY,
00035   G_MARKUP_ERROR_PARSE,
00036   /* These three are primarily intended for specific GMarkupParser
00037    * implementations to set.
00038    */
00039   G_MARKUP_ERROR_UNKNOWN_ELEMENT,
00040   G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE,
00041   G_MARKUP_ERROR_INVALID_CONTENT
00042 } GMarkupError;
00043 
00044 #define G_MARKUP_ERROR g_markup_error_quark ()
00045 
00046 GQuark g_markup_error_quark ();
00047 
00048 typedef enum
00049 {
00050   /* Hmm, can't think of any at the moment */
00051   G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG = 1 << 0
00052   
00053 } GMarkupParseFlags;
00054 
00055 typedef struct _GMarkupParseContext GMarkupParseContext;
00056 typedef struct _GMarkupParser GMarkupParser;
00057 
00058 struct _GMarkupParser
00059 {
00060   /* Called for open tags <foo bar="baz"> */
00061   void (*start_element)  (GMarkupParseContext *context,
00062                           const gchar         *element_name,
00063                           const gchar        **attribute_names,
00064                           const gchar        **attribute_values,
00065                           gpointer             user_data,
00066                           GError             **error);
00067 
00068   /* Called for close tags </foo> */
00069   void (*end_element)    (GMarkupParseContext *context,
00070                           const gchar         *element_name,
00071                           gpointer             user_data,
00072                           GError             **error);
00073 
00074   /* Called for character data */
00075   /* text is not nul-terminated */
00076   void (*text)           (GMarkupParseContext *context,
00077                           const gchar         *text,
00078                           gint                 text_len,
00079                           gpointer             user_data,
00080                           GError             **error);
00081 
00082   /* Called for strings that should be re-saved verbatim in this same
00083    * position, but are not otherwise interpretable.  At the moment
00084    * this includes comments and processing instructions.
00085    */
00086   /* text is not nul-terminated. */
00087   void (*passthrough)    (GMarkupParseContext *context,
00088                           const gchar         *passthrough_text,
00089                           gint                 text_len,
00090                           gpointer             user_data,
00091                           GError             **error);
00092 
00093   /* Called on error, including one set by other
00094    * methods in the vtable. The GError should not be freed.
00095    */
00096   void (*error)          (GMarkupParseContext *context,
00097                           GError              *error,
00098                           gpointer             user_data);
00099 };
00100 
00101 GMarkupParseContext *g_markup_parse_context_new   (const GMarkupParser *parser,
00102                                                    GMarkupParseFlags    flags,
00103                                                    gpointer             user_data,
00104                                                    GDestroyNotify       user_data_dnotify);
00105 void                 g_markup_parse_context_free  (GMarkupParseContext *context);
00106 gboolean             g_markup_parse_context_parse (GMarkupParseContext *context,
00107                                                    const gchar         *text,
00108                                                    gint                 text_len,
00109                                                    GError             **error);
00110                                                    
00111 gboolean             g_markup_parse_context_end_parse (GMarkupParseContext *context,
00112                                                        GError             **error);
00113 
00114 /* For user-constructed error messages, has no precise semantics */
00115 void                 g_markup_parse_context_get_position (GMarkupParseContext *context,
00116                                                           gint                *line_number,
00117                                                           gint                *char_number);
00118 
00119 /* useful when saving */
00120 gchar* g_markup_escape_text (const gchar *text,
00121                              gint         length);
00122 
00123 
00124 #ifdef __cplusplus
00125 }
00126 #endif
00127 
00128 #endif /* __G_MARKUP_H__ */
00129 

Generated on Tue Jul 5 14:14:41 2011 for ROOT_528-00b_version by  doxygen 1.5.1