summaryrefslogtreecommitdiff
path: root/pjlib-util/include
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2009-06-01 09:28:28 +0000
committerBenny Prijono <bennylp@teluu.com>2009-06-01 09:28:28 +0000
commit72f8877d57343fbc2bb42785da9d0c26bd3f0d7a (patch)
tree21178d62ea726ecc78e310dfc7a03132cd67678a /pjlib-util/include
parent7e7590add84c6f8ab76e3d67106ec0b7d21149e8 (diff)
Ticket #868: Added functions to search XML child nodes recursively
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2727 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib-util/include')
-rw-r--r--pjlib-util/include/pjlib-util/xml.h57
1 files changed, 48 insertions, 9 deletions
diff --git a/pjlib-util/include/pjlib-util/xml.h b/pjlib-util/include/pjlib-util/xml.h
index 5595c20c..9188ae6b 100644
--- a/pjlib-util/include/pjlib-util/xml.h
+++ b/pjlib-util/include/pjlib-util/xml.h
@@ -149,17 +149,18 @@ PJ_DECL(void) pj_xml_add_node( pj_xml_node *parent, pj_xml_node *node );
PJ_DECL(void) pj_xml_add_attr( pj_xml_node *node, pj_xml_attr *attr );
/**
- * Find first node with the specified name.
+ * Find first direct child node with the specified name.
*
* @param parent Parent node.
* @param name Node name to find.
*
* @return XML node found or NULL.
*/
-PJ_DECL(pj_xml_node*) pj_xml_find_node(pj_xml_node *parent, const pj_str_t *name);
+PJ_DECL(pj_xml_node*) pj_xml_find_node(const pj_xml_node *parent,
+ const pj_str_t *name);
/**
- * Find first node with the specified name.
+ * Find next direct child node with the specified name.
*
* @param parent Parent node.
* @param node node->next is the starting point.
@@ -167,11 +168,26 @@ PJ_DECL(pj_xml_node*) pj_xml_find_node(pj_xml_node *parent, const pj_str_t *name
*
* @return XML node found or NULL.
*/
-PJ_DECL(pj_xml_node*) pj_xml_find_next_node(pj_xml_node *parent, pj_xml_node *node,
+PJ_DECL(pj_xml_node*) pj_xml_find_next_node(const pj_xml_node *parent,
+ const pj_xml_node *node,
const pj_str_t *name);
/**
- * Find first attribute within a node with the specified name and optional value.
+ * Recursively find the first node with the specified name in the child nodes
+ * and their children.
+ *
+ * @param parent Parent node.
+ * @param name Node name to find.
+ *
+ * @return XML node found or NULL.
+ */
+PJ_DECL(pj_xml_node*) pj_xml_find_node_rec(const pj_xml_node *parent,
+ const pj_str_t *name);
+
+
+/**
+ * Find first attribute within a node with the specified name and optional
+ * value.
*
* @param node XML Node.
* @param name Attribute name to find.
@@ -179,7 +195,8 @@ PJ_DECL(pj_xml_node*) pj_xml_find_next_node(pj_xml_node *parent, pj_xml_node *no
*
* @return XML attribute found, or NULL.
*/
-PJ_DECL(pj_xml_attr*) pj_xml_find_attr(pj_xml_node *node, const pj_str_t *name,
+PJ_DECL(pj_xml_attr*) pj_xml_find_attr(const pj_xml_node *node,
+ const pj_str_t *name,
const pj_str_t *value);
@@ -187,15 +204,37 @@ PJ_DECL(pj_xml_attr*) pj_xml_find_attr(pj_xml_node *node, const pj_str_t *name,
* Find a direct child node with the specified name and match the function.
*
* @param parent Parent node.
- * @param name Optional name.
+ * @param name Optional name. If this is NULL, the name will not be
+ * matched.
* @param data Data to be passed to matching function.
* @param match Optional matching function.
*
* @return The first matched node, or NULL.
*/
-PJ_DECL(pj_xml_node*) pj_xml_find( pj_xml_node *parent, const pj_str_t *name,
+PJ_DECL(pj_xml_node*) pj_xml_find( const pj_xml_node *parent,
+ const pj_str_t *name,
const void *data,
- pj_bool_t (*match)(pj_xml_node *, const void*));
+ pj_bool_t (*match)(const pj_xml_node *,
+ const void*));
+
+
+/**
+ * Recursively find a child node with the specified name and match the
+ * function.
+ *
+ * @param parent Parent node.
+ * @param name Optional name. If this is NULL, the name will not be
+ * matched.
+ * @param data Data to be passed to matching function.
+ * @param match Optional matching function.
+ *
+ * @return The first matched node, or NULL.
+ */
+PJ_DECL(pj_xml_node*) pj_xml_find_rec(const pj_xml_node *parent,
+ const pj_str_t *name,
+ const void *data,
+ pj_bool_t (*match)(const pj_xml_node*,
+ const void*));
/**