diff options
| author | 2009-07-18 12:08:13 +0200 | |
|---|---|---|
| committer | 2009-07-18 12:08:13 +0200 | |
| commit | 07c1d3c90512f5fa057e7eff7d307cffe6258111 (patch) | |
| tree | 8c16ba88eff9614a82c9b3089a4a5515e9004414 | |
| parent | f605777d9739d2f8873b9ab65929e8aee1ebb64e (diff) | |
| download | libplist-07c1d3c90512f5fa057e7eff7d307cffe6258111.tar.gz libplist-07c1d3c90512f5fa057e7eff7d307cffe6258111.tar.bz2 | |
Add function to get parent node in API and python bindings.
| -rw-r--r-- | include/plist/plist.h | 7 | ||||
| -rw-r--r-- | src/plist.c | 5 | ||||
| -rw-r--r-- | swig/plist.i | 8 | 
3 files changed, 20 insertions, 0 deletions
| diff --git a/include/plist/plist.h b/include/plist/plist.h index a075fc6..6388603 100644 --- a/include/plist/plist.h +++ b/include/plist/plist.h @@ -148,6 +148,13 @@ extern "C" {  	PLIST_API plist_t plist_get_prev_sibling(plist_t node);  /** + * Get the parent of a node + * + * @param node the parent (NULL if node is root) + */ +	PLIST_API plist_t plist_get_parent(plist_t node); + +/**   * Get the nth child of a #PLIST_ARRAY node.   *   * @param node the node of type #PLIST_ARRAY diff --git a/src/plist.c b/src/plist.c index 8c326af..143418d 100644 --- a/src/plist.c +++ b/src/plist.c @@ -195,6 +195,11 @@ plist_t plist_get_prev_sibling(plist_t node)  	return (plist_t) g_node_prev_sibling((GNode *) node);  } +plist_t plist_get_parent(plist_t node) +{ +	return node ? (plist_t) ((GNode *) node)->parent : NULL; +} +  plist_t plist_get_array_nth_el(plist_t node, uint32_t n)  {  	plist_t ret = NULL; diff --git a/swig/plist.i b/swig/plist.i index b6f9f78..7240817 100644 --- a/swig/plist.i +++ b/swig/plist.i @@ -141,6 +141,14 @@ typedef struct {  		return NULL;  	} +	PListNode* get_parent() { +		plist_t node = plist_get_parent( $self->node ); +		if (node) { +			return allocate_wrapper(node, 1); +		} +		return NULL; +	} +  	%newobject as_key;  	char* as_key() {  		char* k = NULL; | 
