You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by tr...@apache.org on 2016/03/19 00:06:45 UTC

[27/50] [abbrv] qpid-dispatch git commit: DISPATCH-179 - Added parse_as_bool method to qd_parsed_field_t.

DISPATCH-179 - Added parse_as_bool method to qd_parsed_field_t.


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

Branch: refs/heads/master
Commit: 5c839b381667cf893759ae2f0c7be909ed972a69
Parents: 3ccd9db
Author: Ted Ross <tr...@redhat.com>
Authored: Mon Mar 14 18:26:27 2016 -0400
Committer: Ted Ross <tr...@redhat.com>
Committed: Tue Mar 15 14:08:34 2016 -0400

----------------------------------------------------------------------
 include/qpid/dispatch/parse.h |  8 ++++++++
 src/parse.c                   | 21 +++++++++++++++++++++
 2 files changed, 29 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/5c839b38/include/qpid/dispatch/parse.h
----------------------------------------------------------------------
diff --git a/include/qpid/dispatch/parse.h b/include/qpid/dispatch/parse.h
index dfd57ac..47f3069 100644
--- a/include/qpid/dispatch/parse.h
+++ b/include/qpid/dispatch/parse.h
@@ -128,6 +128,14 @@ int32_t qd_parse_as_int(qd_parsed_field_t *field);
 int64_t qd_parse_as_long(qd_parsed_field_t *field);
 
 /**
+ * Return the raw content as a boolean value.
+ *
+ * @param field The field pointer returned by qd_parse.
+ * @return The raw content of the field cast as a bool.
+ */
+bool qd_parse_as_bool(qd_parsed_field_t *field);
+
+/**
  * Return the number of sub-field in a compound field.  If the field is
  * a list or array, this is the number of items in the list/array.  If
  * the field is a map, this is the number of key/value pairs in the map

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/5c839b38/src/parse.c
----------------------------------------------------------------------
diff --git a/src/parse.c b/src/parse.c
index 3ead3e2..55050ca 100644
--- a/src/parse.c
+++ b/src/parse.c
@@ -309,6 +309,27 @@ int64_t qd_parse_as_long(qd_parsed_field_t *field)
 }
 
 
+bool qd_parse_as_bool(qd_parsed_field_t *field)
+{
+    bool result = false;
+
+    qd_field_iterator_reset(field->raw_iter);
+
+    switch (field->tag) {
+    case QD_AMQP_BYTE:
+    case QD_AMQP_BOOLEAN:
+        result = !!qd_field_iterator_octet(field->raw_iter);
+        break;
+
+    case QD_AMQP_TRUE:
+        result = true;
+        break;
+    }
+
+    return result;
+}
+
+
 uint32_t qd_parse_sub_count(qd_parsed_field_t *field)
 {
     uint32_t count = DEQ_SIZE(field->children);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org