BuildableParseContextProtocol

public protocol BuildableParseContextProtocol

An opaque context struct for GtkBuildableParser.

The BuildableParseContextProtocol protocol exposes the methods and properties of an underlying GtkBuildableParseContext instance. The default implementation of these can be found in the protocol extension below. For a concrete class that implements these methods and properties, see BuildableParseContext. Alternatively, use BuildableParseContextRef as a lighweight, unowned reference if you already have an instance you just want to use.

  • ptr

    Untyped pointer to the underlying GtkBuildableParseContext instance.

    Declaration

    Swift

    var ptr: UnsafeMutableRawPointer! { get }
  • _ptr Default implementation

    Typed pointer to the underlying GtkBuildableParseContext instance.

    Default Implementation

    Return the stored, untyped pointer as a typed pointer to the GtkBuildableParseContext instance.

    Declaration

    Swift

    var _ptr: UnsafeMutablePointer<GtkBuildableParseContext>! { get }
  • Required Initialiser for types conforming to BuildableParseContextProtocol

    Declaration

    Swift

    init(raw: UnsafeMutableRawPointer)

BuildableParseContext Record: BuildableParseContextProtocol extension (methods and fields)

  • getElement() Extension method

    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 gtk_buildable_parse_context_get_element_stack().

    Declaration

    Swift

    @inlinable
    func getElement() -> String!
  • getElementStack() Extension method

    Retrieves the element stack from the internal state of the parser.

    The returned GPtrArray is an array of strings where the last item is the currently open tag (as would be returned by gtk_buildable_parse_context_get_element()) and the previous item is its immediate parent.

    This function is intended to be used in the start_element and end_element handlers where gtk_buildable_parse_context_get_element() would merely return the name of the element that is being processed.

    Declaration

    Swift

    @inlinable
    func getElementStack() -> GLib.PtrArrayRef!
  • 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.”

    Declaration

    Swift

    @inlinable
    func getPosition(lineNumber: UnsafeMutablePointer<gint>! = nil, charNumber: UnsafeMutablePointer<gint>! = nil)
  • pop() Extension method

    Completes the process of a temporary sub-parser redirection.

    This function exists to collect the user_data allocated by a matching call to gtk_buildable_parse_context_push(). It must be called in the end_element handler corresponding to the start_element handler during which gtk_buildable_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.

    Declaration

    Swift

    @inlinable
    func pop() -> gpointer!
  • push(parser:userData:) Extension method

    Temporarily redirects markup data to a sub-parser.

    This function may only be called from the start_element handler of a GtkBuildableParser. It must be matched with a corresponding call to gtk_buildable_parse_context_pop() in the matching end_element handler (except in the case that the parser aborts due to an error).

    All tags, text and other data between the matching tags is redirected to the subparser given by parser. user_data is used as the user_data for that parser. user_data is also passed to the error callback in the event that an error occurs. This includes errors that occur in subparsers of the subparser.

    The end tag matching the start tag for which this call was made is handled by the previous parser (which is given its own user_data) which is why gtk_buildable_parse_context_pop() is provided to allow “one last access” to the user_data provided to this function. In the case of error, the user_data provided here is passed directly to the error callback of the subparser and gtk_buildable_parse_context_pop() should not be called. In either case, if user_data was allocated then it ought to be freed from both of these locations.

    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.

    For an example of how to use this, see g_markup_parse_context_push() which has the same kind of API.

    Declaration

    Swift

    @inlinable
    func push<BuildableParserT>(parser: BuildableParserT, userData: gpointer! = nil) where BuildableParserT : BuildableParserProtocol
  • element Extension method

    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 gtk_buildable_parse_context_get_element_stack().

    Declaration

    Swift

    @inlinable
    var element: String! { get }
  • elementStack Extension method

    Retrieves the element stack from the internal state of the parser.

    The returned GPtrArray is an array of strings where the last item is the currently open tag (as would be returned by gtk_buildable_parse_context_get_element()) and the previous item is its immediate parent.

    This function is intended to be used in the start_element and end_element handlers where gtk_buildable_parse_context_get_element() would merely return the name of the element that is being processed.

    Declaration

    Swift

    @inlinable
    var elementStack: GLib.PtrArrayRef! { get }