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.
Signals to the <GMarkupParseContext>
that all data has been fed into the parse context with
markup-parse-context:parse?.
This function reports an error if the document isn’t complete, for example if elements are still open.
Passed: a <GMarkupParseContext>.
Returned: a boolean.
#t on success, #f if an error was set
Frees a <GMarkupParseContext>.
This function can’t be called from inside one of the
GMarkupParser functions or while a subparser is pushed.
Passed: a <GMarkupParseContext>.
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 markup-parse-context:get-element-stack.
Passed: a <GMarkupParseContext>.
Returned: a string.
the name of the currently open element, or #f
Retrieves the element stack from the internal state of the parser.
The returned GSList is a list of strings where the first item is
the currently open tag (as would be returned by
markup-parse-context:get-element) and the next item is
its immediate parent.
This function is intended to be used in the start_element and
end_element handlers where markup-parse-context:get-element would merely return the
name of the element that is being processed.
Passed: a <GMarkupParseContext>.
Returned: a list, each a string.
the element stack, which must not be modified
Retrieves the current offset from the beginning of the document, in bytes.
The information is meant to accompany the values returned by
markup-parse-context:get-position, and comes with the
same accuracy guarantees.
Passed: a <GMarkupParseContext>.
Returned: an unsigned 64-bit integer.
the offset
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."
Passed: a <GMarkupParseContext>.
Returned: a 32-bit integer.
return location for a line number, or #f
Returned: a 32-bit integer.
return location for a char-on-line number, or #f
Retrieves the start position of the current start or end tag.
This function can be used in the start_element or
end_element callbacks to obtain location information for error
reporting.
Note that line-number and char-number are intended for human readable error messages and are therefore 1-based and in Unicode characters. offset on the other hand is meant for programmatic use, and thus is 0-based and in bytes.
The information is meant to accompany the values returned by
markup-parse-context:get-position, and comes with the
same accuracy guarantees.
Passed: a <GMarkupParseContext>.
Returned: an unsigned 64-bit integer.
return location for the line number
Returned: an unsigned 64-bit integer.
return location for the character number
Returned: an unsigned 64-bit integer.
return location for offset from the beginning of the document
Returns the user_data associated with self.
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().
Passed: a <GMarkupParseContext>.
Returned: a foreign pointer, or #f.
the provided user_data. The returned data belongs to the markup context
and will be freed when markup-parse-context:free is called.
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.
Passed: a <GMarkupParseContext>.
Passed: a string.
chunk of text to parse
Passed: a 64-bit integer.
length of text in bytes
Returned: a boolean.
#f if an error occurred, #t on success
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.
Passed: a <GMarkupParseContext>.
Returned: a foreign pointer, or #f.
the user data passed to g_markup_parse_context_push()
Increases the reference count of self.
Passed: a <GMarkupParseContext>.
Returned: a <GMarkupParseContext>.
the same self
Decreases the reference count of self. When its reference count drops to 0, it is freed.
Passed: a <GMarkupParseContext>.