Repository: qpid-dispatch
Updated Branches:
  refs/heads/master fe1f711e2 -> 4bd79a3d5


DISPATCH-998: Add parse tree remove function with string arg


Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/4bd79a3d
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/4bd79a3d
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/4bd79a3d

Branch: refs/heads/master
Commit: 4bd79a3d51400d74a53f225b8ec9d43f2c975e08
Parents: fe1f711
Author: Chuck Rolke <[email protected]>
Authored: Thu May 10 10:38:05 2018 -0400
Committer: Chuck Rolke <[email protected]>
Committed: Thu May 10 10:38:05 2018 -0400

----------------------------------------------------------------------
 src/parse_tree.c         | 9 +++++++++
 src/parse_tree.h         | 3 +++
 tests/parse_tree_tests.c | 6 ++++++
 3 files changed, 18 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/4bd79a3d/src/parse_tree.c
----------------------------------------------------------------------
diff --git a/src/parse_tree.c b/src/parse_tree.c
index b3651ac..c02b74a 100644
--- a/src/parse_tree.c
+++ b/src/parse_tree.c
@@ -825,3 +825,12 @@ bool qd_parse_tree_retrieve_match_str(qd_parse_tree_t 
*tree,
     return *payload != NULL;
 }
 
+// returns old payload or NULL if not present
+void *qd_parse_tree_remove_pattern_str(qd_parse_tree_t *node,
+                                       const char *pattern)
+{
+    qd_iterator_t *piter = qd_iterator_string(pattern, ITER_VIEW_ALL);
+    void *result = qd_parse_tree_remove_pattern(node, piter);
+    qd_iterator_free(piter);
+    return result;
+}

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/4bd79a3d/src/parse_tree.h
----------------------------------------------------------------------
diff --git a/src/parse_tree.h b/src/parse_tree.h
index 34d29f4..8a06fc9 100644
--- a/src/parse_tree.h
+++ b/src/parse_tree.h
@@ -125,4 +125,7 @@ bool qd_parse_tree_retrieve_match_str(qd_parse_tree_t *tree,
                                       const char *value,
                                       void **payload);
 
+// returns old payload or NULL if not present
+void *qd_parse_tree_remove_pattern_str(qd_parse_tree_t *node,
+                                       const char *pattern);
 #endif /* parse_tree.h */

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/4bd79a3d/tests/parse_tree_tests.c
----------------------------------------------------------------------
diff --git a/tests/parse_tree_tests.c b/tests/parse_tree_tests.c
index d04204d..5800b4a 100644
--- a/tests/parse_tree_tests.c
+++ b/tests/parse_tree_tests.c
@@ -88,6 +88,12 @@ static char *test_add_and_match_str(void *context)
     if (qd_parse_tree_retrieve_match_str(node, "notSoFast", &payload))
         return "Match pattern should not match but did match";
 
+    if (!qd_parse_tree_remove_pattern_str(node, str1))
+        return "Failed to remove an existing pattern str";
+
+    if (qd_parse_tree_retrieve_match_str(node, str1, &payload))
+        return "Removed pattern should not match but did match";
+
     qd_parse_tree_free(node);
     return NULL;
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to