From 589bd2f4631a6a0e0ed5f02c2e55e33812fb8013 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 8 Nov 2007 03:28:09 +0000 Subject: [PATCH] New function, to get the stack of open elements. (#452887, Ryan Lortie) 2007-11-07 Matthias Clasen * glib/glib.symbols: * glib/gmarkup.[hc] (g_markup_parse_context_get_element_stack): New function, to get the stack of open elements. (#452887, Ryan Lortie) svn path=/trunk/; revision=5816 --- ChangeLog | 7 ++++++ docs/reference/ChangeLog | 3 +++ docs/reference/glib/glib-sections.txt | 1 + glib/glib.symbols | 1 + glib/gmarkup.c | 31 +++++++++++++++++++++++++++ glib/gmarkup.h | 1 + 6 files changed, 44 insertions(+) diff --git a/ChangeLog b/ChangeLog index fd57c2d83..26fd61051 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-11-07 Matthias Clasen + + * glib/glib.symbols: + * glib/gmarkup.[hc] (g_markup_parse_context_get_element_stack): + New function, to get the stack of open elements. (#452887, + Ryan Lortie) + 2007-11-07 Matthias Clasen * glib/gkeyfile.[hc]: Make some functions that take diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog index e11df929d..38975c66a 100644 --- a/docs/reference/ChangeLog +++ b/docs/reference/ChangeLog @@ -1,5 +1,8 @@ 2007-11-07 Matthias Clasen + * glib/glib-sections.txt: Add g_markup_parse_context_get_element_stack +2007-11-07 Matthias Clasen + * glib/building.sgml: Fix a typo 2007-11-07 Matthias Clasen diff --git a/docs/reference/glib/glib-sections.txt b/docs/reference/glib/glib-sections.txt index b815824aa..d07ae531f 100644 --- a/docs/reference/glib/glib-sections.txt +++ b/docs/reference/glib/glib-sections.txt @@ -994,6 +994,7 @@ g_markup_parse_context_end_parse g_markup_parse_context_free g_markup_parse_context_get_position g_markup_parse_context_get_element +g_markup_parse_context_get_element_stack g_markup_parse_context_new g_markup_parse_context_parse diff --git a/glib/glib.symbols b/glib/glib.symbols index ac0907f59..6e4e7876d 100644 --- a/glib/glib.symbols +++ b/glib/glib.symbols @@ -644,6 +644,7 @@ g_markup_escape_text g_markup_parse_context_end_parse g_markup_parse_context_free g_markup_parse_context_get_element +g_markup_parse_context_get_element_stack g_markup_parse_context_get_position g_markup_parse_context_new g_markup_parse_context_parse diff --git a/glib/gmarkup.c b/glib/gmarkup.c index 4c941590f..35c37f595 100644 --- a/glib/gmarkup.c +++ b/glib/gmarkup.c @@ -1856,6 +1856,10 @@ g_markup_parse_context_end_parse (GMarkupParseContext *context, * * 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(). + * * Since: 2.2 **/ G_CONST_RETURN gchar * @@ -1869,6 +1873,33 @@ g_markup_parse_context_get_element (GMarkupParseContext *context) return current_element (context); } +/** + * g_markup_parse_context_get_element_stack: + * @context: a #GMarkupParseContext + * + * 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 + * g_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 g_markup_parse_context_get_element() + * would merely return the name of the element that is being + * processed. + * + * Returns: the element stack, which must not be modified + * + * Since 2.16 + **/ +G_CONST_RETURN GSList * +g_markup_parse_context_get_element_stack (GMarkupParseContext *context) +{ + g_return_val_if_fail (context != NULL, NULL); + + return context->tag_stack; +} + /** * g_markup_parse_context_get_position: * @context: a #GMarkupParseContext diff --git a/glib/gmarkup.h b/glib/gmarkup.h index b272d5ca7..d6bb8a1fd 100644 --- a/glib/gmarkup.h +++ b/glib/gmarkup.h @@ -109,6 +109,7 @@ gboolean g_markup_parse_context_parse (GMarkupParseContext *context, gboolean g_markup_parse_context_end_parse (GMarkupParseContext *context, GError **error); G_CONST_RETURN gchar *g_markup_parse_context_get_element (GMarkupParseContext *context); +G_CONST_RETURN GSList *g_markup_parse_context_get_element_stack (GMarkupParseContext *context); /* For user-constructed error messages, has no precise semantics */ void g_markup_parse_context_get_position (GMarkupParseContext *context,