[couchdb-glib] Added some field management functions for both Document's and StructField's
- From: Rodrigo Moya <rodrigo src gnome org>
- To: svn-commits-list gnome org
- Subject: [couchdb-glib] Added some field management functions for both Document's and StructField's
- Date: Fri, 12 Jun 2009 08:07:07 -0400 (EDT)
commit 57601824eab834344681c509acd90b1672037c2f
Author: Rodrigo Moya <rodrigo gnome-db org>
Date: Fri Jun 12 14:06:52 2009 +0200
Added some field management functions for both Document's and StructField's
couchdb-glib/couchdb-document.c | 12 ++++++++++--
couchdb-glib/couchdb-glib.h | 2 ++
couchdb-glib/couchdb-types.c | 18 ++++++++++++++++++
couchdb-glib/couchdb-types.h | 3 +++
4 files changed, 33 insertions(+), 2 deletions(-)
---
diff --git a/couchdb-glib/couchdb-document.c b/couchdb-glib/couchdb-document.c
index d4117c6..ade0be1 100644
--- a/couchdb-glib/couchdb-document.c
+++ b/couchdb-glib/couchdb-document.c
@@ -153,8 +153,16 @@ couchdb_document_has_field (CouchDBDocument *document, const char *field)
g_return_val_if_fail (COUCHDB_IS_DOCUMENT (document), FALSE);
g_return_val_if_fail (field != NULL, FALSE);
- return json_object_get_member (json_node_get_object (document->root_node),
- field) ? TRUE : FALSE;
+ return json_object_has_member (json_node_get_object (document->root_node), field);
+}
+
+void
+couchdb_document_remove_field (CouchDBDocument *document, const char *field)
+{
+ g_return_if_fail (COUCHDB_IS_DOCUMENT (document));
+ g_return_if_fail (field != NULL);
+
+ json_object_remove_member (json_node_get_object (document->root_node), field);
}
gboolean
diff --git a/couchdb-glib/couchdb-glib.h b/couchdb-glib/couchdb-glib.h
index 10b57ae..2da9195 100644
--- a/couchdb-glib/couchdb-glib.h
+++ b/couchdb-glib/couchdb-glib.h
@@ -81,6 +81,8 @@ void couchdb_document_set_id (CouchDBDocument *document, const char
const char *couchdb_document_get_revision (CouchDBDocument *document);
gboolean couchdb_document_has_field (CouchDBDocument *document, const char *field);
+void couchdb_document_remove_field (CouchDBDocument *document, const char *field);
+
gboolean couchdb_document_get_boolean_field (CouchDBDocument *document, const char *field);
void couchdb_document_set_boolean_field (CouchDBDocument *document, const char *field, gboolean value);
gint couchdb_document_get_int_field (CouchDBDocument *document, const char *field);
diff --git a/couchdb-glib/couchdb-types.c b/couchdb-glib/couchdb-types.c
index ede6bb5..0d09ea9 100644
--- a/couchdb-glib/couchdb-types.c
+++ b/couchdb-glib/couchdb-types.c
@@ -281,6 +281,24 @@ couchdb_struct_field_unref (CouchDBStructField *sf)
}
gboolean
+couchdb_struct_field_has_field (CouchDBStructField *sf, const char *field)
+{
+ g_return_val_if_fail (sf != NULL, FALSE);
+ g_return_val_if_fail (field != NULL, field);
+
+ return json_object_has_member (sf->json_object, field);
+}
+
+void
+couchdb_struct_field_remove_field (CouchDBStructField *sf, const char *field)
+{
+ g_return_val_if_fail (sf != NULL, 0);
+ g_return_val_if_fail (field != NULL, 0);
+
+ json_object_remove_member (sf->json_object, field);
+}
+
+gboolean
couchdb_struct_field_get_boolean_field (CouchDBStructField *sf, const char *field)
{
g_return_val_if_fail (sf != NULL, 0);
diff --git a/couchdb-glib/couchdb-types.h b/couchdb-glib/couchdb-types.h
index 9e27b3d..daf243e 100644
--- a/couchdb-glib/couchdb-types.h
+++ b/couchdb-glib/couchdb-types.h
@@ -66,6 +66,9 @@ CouchDBStructField *couchdb_struct_field_new (void);
CouchDBStructField *couchdb_struct_field_ref (CouchDBStructField *sf);
void couchdb_struct_field_unref (CouchDBStructField *sf);
+gboolean couchdb_struct_field_has_field (CouchDBStructField *sf, const char *field);
+void couchdb_struct_field_remove_field (CouchDBStructField *sf, const char *field);
+
gboolean couchdb_struct_field_get_boolean_field (CouchDBStructField *sf, const char *field);
void couchdb_struct_field_set_boolean_field (CouchDBStructField *sf, const char *field, gboolean value);
gdouble couchdb_struct_field_get_double_field (CouchDBStructField *sf, const char *field);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]