<GMarkupParseContext>

<GMarkupParseContext>

Description

A parse context is used to parse a stream of bytes that you expect to contain marked-up text.

See g_markup_parse_context_new(), GMarkupParser, and so on for more details.

Functions

end-parse?

(define-values (%return) (markup-parse-context:end-parse? self))

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.

Parameters

context

a GMarkupParseContext

Passed as self

free

(define-values () (markup-parse-context:free self))

Frees a GMarkupParseContext.

This function can't be called from inside one of the GMarkupParser functions or while a subparser is pushed.

Parameters

context

a GMarkupParseContext

Passed as self

get-element

(define-values (%return) (markup-parse-context:get-element self))

Retrieves the name of the currently open element.

If called from the start_element or end_element handlers this will give the element_name as passed to those functions. For the parent elements, see g_markup_parse_context_get_element_stack().

Parameters

context

a GMarkupParseContext

Passed as self

get-position

(define-values
  (line-number char-number)
  (markup-parse-context:get-position self))

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."

Parameters

context

a GMarkupParseContext

Passed as self

line_number

return location for a line number, or NULL

Passed as line-number

char_number

return location for a char-on-line number, or NULL

Passed as char-number

get-user-data

(define-values (%return) (markup-parse-context:get-user-data self))

Returns the user_data associated with context.

This will either be the user_data that was provided to g_markup_parse_context_new() or to the most recent call of g_markup_parse_context_push().

Parameters

context

a GMarkupParseContext

Passed as self

parse?

(define-values (%return) (markup-parse-context:parse? self text text-len))

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.

Parameters

context

a GMarkupParseContext

Passed as self

text

chunk of text to parse

Passed as text

text_len

length of text in bytes

Passed as text-len

pop

(define-values (%return) (markup-parse-context:pop self))

Completes the process of a temporary sub-parser redirection.

This function exists to collect the user_data allocated by a matching call to g_markup_parse_context_push(). It must be called in the end_element handler corresponding to the start_element handler during which g_markup_parse_context_push() was called. You must not call this function from the error callback -- the user_data is provided directly to the callback in that case.

This function is not intended to be directly called by users interested in invoking subparsers. Instead, it is intended to be used by the subparsers themselves to implement a higher-level interface.

Parameters

context

a GMarkupParseContext

Passed as self

ref

(define-values (%return) (markup-parse-context:ref self))

Increases the reference count of context.

Parameters

context

a GMarkupParseContext

Passed as self

unref

(define-values () (markup-parse-context:unref self))

Decreases the reference count of context. When its reference count drops to 0, it is freed.

Parameters

context

a GMarkupParseContext

Passed as self