[json-glib] node: Add a private NodeType-to-string converter
- From: Emmanuele Bassi <ebassi src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [json-glib] node: Add a private NodeType-to-string converter
- Date: Tue, 27 Oct 2009 18:02:08 +0000 (UTC)
commit 7f6a73a0964b66b15e8b5a9858b9bc76b010f67b
Author: Emmanuele Bassi <ebassi linux intel com>
Date: Tue Oct 27 17:43:38 2009 +0000
node: Add a private NodeType-to-string converter
Useful for debugging and logging purposes.
json-glib/json-node.c | 23 ++++++++++++++++++++++-
json-glib/json-types-private.h | 2 ++
2 files changed, 24 insertions(+), 1 deletions(-)
---
diff --git a/json-glib/json-node.c b/json-glib/json-node.c
index a3562f6..a21d587 100644
--- a/json-glib/json-node.c
+++ b/json-glib/json-node.c
@@ -469,6 +469,23 @@ json_node_type_name (JsonNode *node)
switch (node->type)
{
case JSON_NODE_OBJECT:
+ case JSON_NODE_ARRAY:
+ case JSON_NODE_NULL:
+ return json_node_type_get_name (node->type);
+
+ case JSON_NODE_VALUE:
+ return g_type_name (G_VALUE_TYPE (&(node->data.value)));
+ }
+
+ return "unknown";
+}
+
+G_CONST_RETURN gchar *
+json_node_type_get_name (JsonNodeType node_type)
+{
+ switch (node_type)
+ {
+ case JSON_NODE_OBJECT:
return "JsonObject";
case JSON_NODE_ARRAY:
@@ -478,7 +495,11 @@ json_node_type_name (JsonNode *node)
return "NULL";
case JSON_NODE_VALUE:
- return g_type_name (G_VALUE_TYPE (&(node->data.value)));
+ return "Value";
+
+ default:
+ g_assert_not_reached ();
+ break;
}
return "unknown";
diff --git a/json-glib/json-types-private.h b/json-glib/json-types-private.h
index ac72316..d0e073e 100644
--- a/json-glib/json-types-private.h
+++ b/json-glib/json-types-private.h
@@ -59,6 +59,8 @@ struct _JsonObject
volatile gint ref_count;
};
+G_CONST_RETURN gchar *json_node_type_get_name (JsonNodeType node_type);
+
G_END_DECLS
#endif /* __JSON_TYPES_PRIVATE_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]