[json-glib] [node] Add is_null() method



commit 58999bddac74c176fbd8544fa2cd30e2f067d863
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Fri Apr 17 15:45:42 2009 +0100

    [node] Add is_null() method
    
    The json_node_is_null() function is just a quick check for
    nodes set to null.
---
 doc/reference/json-glib-sections.txt |    1 +
 json-glib/json-node.c                |   20 ++++++++++++++++++++
 json-glib/json-types.h               |    1 +
 3 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/doc/reference/json-glib-sections.txt b/doc/reference/json-glib-sections.txt
index a7f3336..b30e190 100644
--- a/doc/reference/json-glib-sections.txt
+++ b/doc/reference/json-glib-sections.txt
@@ -116,6 +116,7 @@ json_node_get_parent
 json_node_type_name
 json_node_get_value_type
 json_node_get_node_type
+json_node_is_null
 
 <SUBSECTION Private>
 JSON_TYPE_NODE
diff --git a/json-glib/json-node.c b/json-glib/json-node.c
index 508b3dd..04570dd 100644
--- a/json-glib/json-node.c
+++ b/json-glib/json-node.c
@@ -707,3 +707,23 @@ json_node_get_node_type (JsonNode *node)
 
   return node->type;
 }
+
+/**
+ * json_node_is_null:
+ * @node: a #JsonNode
+ *
+ * Checks whether @node is a %JSON_NODE_NULL
+ *
+ * <note>A null node is not the same as a %NULL #JsonNode</note>
+ *
+ * Return value: %TRUE if the node is null
+ *
+ * Since: 0.8
+ */
+gboolean
+json_node_is_null (JsonNode *node)
+{
+  g_return_val_if_fail (node != NULL, TRUE);
+
+  return node->type == JSON_NODE_NULL;
+}
diff --git a/json-glib/json-types.h b/json-glib/json-types.h
index 1942a43..1851ef0 100644
--- a/json-glib/json-types.h
+++ b/json-glib/json-types.h
@@ -133,6 +133,7 @@ gdouble               json_node_get_double      (JsonNode     *node);
 void                  json_node_set_boolean     (JsonNode     *node,
                                                  gboolean      value);
 gboolean              json_node_get_boolean     (JsonNode     *node);
+gboolean              json_node_is_null         (JsonNode     *node);
 
 /*
  * JsonObject



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]