glib.SimpleXML.SimpleXML Class Reference

List of all members.

Detailed Description

Description The "GMarkup" parser is intended to parse a simple markup format that's a subset of XML.

This is a small, efficient, easy-to-use parser. It should not be used if you expect to interoperate with other applications generating full-scale XML. However, it's very useful for application data files, config files, etc. where you know your application will be the only one writing the file. Full-scale XML parsers should be able to parse the subset used by GMarkup, so you can easily migrate to full-scale XML at a later time if the need arises. GMarkup is not guaranteed to signal an error on all invalid XML; the parser may accept documents that an XML parser would not. However, XML documents which are not well-formed[4] are not considered valid GMarkup documents. Simplifications to XML include: Only UTF-8 encoding is allowed. No user-defined entities. Processing instructions, comments and the doctype declaration are "passed through" but are not interpreted in any way. No DTD or validation. The markup format does support: Elements Attributes 5 standard entities: amp; lt; gt; quot; apos; Character references Sections marked as CDATA


Public Member Functions

GMarkupParseContextgetSimpleXMLStruct ()
 this (GMarkupParseContext *gMarkupParseContext)
 Sets our main struct and passes it to the parent class.
int endParse (GError **error)
 Signals to the GMarkupParseContext that all data has been fed into the parse context with g_markup_parse_context_parse().
void free ()
 Frees a GMarkupParseContext.
void getPosition (int *lineNumber, int *charNumber)
 Retrieves the current line number and the number of the character on that line.
char[] getElement ()
 Retrieves the name of the currently open element.
 this (GMarkupParser *parser, GMarkupParseFlags flags, void *userData, GDestroyNotify userDataDnotify)
 Creates a new parse context.
int parse (char[] text, int textLen, GError **error)
 Feed some data to the GMarkupParseContext.

Static Public Member Functions

static char[] gMarkupEscapeText (char[] text, int length)
 Escapes text so that the markup parser will parse it verbatim.
static char[] gMarkupPrintfEscaped (char[] format,...)
 Formats arguments according to format, escaping all string and character arguments in the fashion of g_markup_escape_text().
static char[] gMarkupVprintfEscaped (char[] format, void *args)
 Formats the data in args according to format, escaping all string and character arguments in the fashion of g_markup_escape_text().

Protected Member Functions

void * getStruct ()
 the main Gtk struct as a void*

Protected Attributes

GMarkupParseContextgMarkupParseContext
 the main Gtk struct


Constructor & Destructor Documentation

glib.SimpleXML.SimpleXML.this ( GMarkupParseContext gMarkupParseContext  ) 

Sets our main struct and passes it to the parent class.

glib.SimpleXML.SimpleXML.this ( GMarkupParser parser,
GMarkupParseFlags  flags,
void *  userData,
GDestroyNotify  userDataDnotify 
)

Creates a new parse context.

A parse context is used to parse marked-up documents. You can feed any number of documents into a context, as long as no errors occur; once an error occurs, the parse context can't continue to parse text (you have to free it and create a new parse context). parser: a GMarkupParser flags: one or more GMarkupParseFlags user_data: user data to pass to GMarkupParser functions user_data_dnotify: user data destroy notifier called when the parse context is freed Returns: a new GMarkupParseContext


Member Function Documentation

int glib.SimpleXML.SimpleXML.endParse ( GError **  error  ) 

Signals to the GMarkupParseContext that all data has been fed into the parse context with g_markup_parse_context_parse().

This function reports an error if the document isn't complete, for example if elements are still open. context: a GMarkupParseContext error: return location for a GError Returns: TRUE on success, FALSE if an error was set

void glib.SimpleXML.SimpleXML.free (  ) 

Frees a GMarkupParseContext.

Can't be called from inside one of the GMarkupParser functions. context: a GMarkupParseContext

char [] glib.SimpleXML.SimpleXML.getElement (  ) 

Retrieves the name of the currently open element.

context: a GMarkupParseContext Returns: the name of the currently open element, or NULL Since 2.2

void glib.SimpleXML.SimpleXML.getPosition ( int lineNumber,
int charNumber 
)

Retrieves the current line number and the number of the character on that line.

Intended for use in error messages; there are no strict semantics for what constitutes the "current" line number other than "the best number we could come up with for error messages." context: a GMarkupParseContext line_number: return location for a line number, or NULL char_number: return location for a char-on-line number, or NULL

GMarkupParseContext* glib.SimpleXML.SimpleXML.getSimpleXMLStruct (  ) 

void* glib.SimpleXML.SimpleXML.getStruct (  )  [protected]

the main Gtk struct as a void*

static char [] glib.SimpleXML.SimpleXML.gMarkupEscapeText ( char[]  text,
int  length 
) [static]

Escapes text so that the markup parser will parse it verbatim.

Less than, greater than, ampersand, etc. are replaced with the corresponding entities. This function would typically be used when writing out a file to be parsed with the markup parser. Note that this function doesn't protect whitespace and line endings from being processed according to the XML rules for normalization of line endings and attribute values. text: some valid UTF-8 text length: length of text in bytes, or -1 if the text is nul-terminated Returns: a newly allocated string with the escaped text

static char [] glib.SimpleXML.SimpleXML.gMarkupPrintfEscaped ( char[]  format,
  ... 
) [static]

Formats arguments according to format, escaping all string and character arguments in the fashion of g_markup_escape_text().

This is useful when you want to insert literal strings into XML-style markup output, without having to worry that the strings might themselves contain markup. const char *store = "Fortnum Mason"; const char *item = "Tea"; char *output; output = g_markup_printf_escaped ("<purchase>" "<store>%s</store>" "<item>%s</item>" "</purchase>", store, item); format: printf() style format string ...: the arguments to insert in the format string Returns: newly allocated result from formatting operation. Free with g_free(). Since 2.4

static char [] glib.SimpleXML.SimpleXML.gMarkupVprintfEscaped ( char[]  format,
void *  args 
) [static]

Formats the data in args according to format, escaping all string and character arguments in the fashion of g_markup_escape_text().

See g_markup_printf_escaped(). format: printf() style format string args: variable argument list, similar to vprintf() Returns: newly allocated result from formatting operation. Free with g_free(). Since 2.4

int glib.SimpleXML.SimpleXML.parse ( char[]  text,
int  textLen,
GError **  error 
)

Feed some data to the GMarkupParseContext.

The data need not be valid UTF-8; an error will be signaled if it's invalid. The data need not be an entire document; you can feed a document into the parser incrementally, via multiple calls to this function. Typically, as you receive data from a network connection or file, you feed each received chunk of data into this function, aborting the process if an error occurs. Once an error is reported, no further data may be fed to the GMarkupParseContext; all errors are fatal. context: a GMarkupParseContext text: chunk of text to parse text_len: length of text in bytes error: return location for a GError Returns: FALSE if an error occurred, TRUE on success [4] XML specification


Member Data Documentation

GMarkupParseContext* glib.SimpleXML.SimpleXML.gMarkupParseContext [protected]

the main Gtk struct


SourceForge.net Logo DSource.org Logo digitalmars.com Logo