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

[virt-tools-list] [PATCH libosinfo 1/7] Add helper APIs to OsinfoEntity for boolean params



From: "Daniel P. Berrange" <berrange redhat com>

---
 osinfo/libosinfo.syms  |    2 ++
 osinfo/osinfo_entity.c |   13 +++++++++++++
 osinfo/osinfo_entity.h |    2 ++
 3 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index 1f1a161..bb6da44 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -209,6 +209,8 @@ LIBOSINFO_0.0.6 {
 
 LIBOSINFO_0.1.0 {
     global:
+	osinfo_entity_set_param_boolean;
+	osinfo_entity_get_param_value_boolean;
 	osinfo_tree_new;
 	osinfo_tree_create_from_location;
 	osinfo_tree_create_from_location_async;
diff --git a/osinfo/osinfo_entity.c b/osinfo/osinfo_entity.c
index 48d475d..2e448fb 100644
--- a/osinfo/osinfo_entity.c
+++ b/osinfo/osinfo_entity.c
@@ -196,6 +196,11 @@ void osinfo_entity_set_param(OsinfoEntity *entity, const gchar *key, const gchar
 }
 
 
+void osinfo_entity_set_param_boolean(OsinfoEntity *entity, const gchar *key, gboolean value)
+{
+    osinfo_entity_set_param(entity, key, value ? "true" : "false");
+}
+
 /**
  * osinfo_entity_add_param:
  * @entity: OsinfoEntity containing the parameters
@@ -302,6 +307,14 @@ const gchar *osinfo_entity_get_param_value(OsinfoEntity *entity, const gchar *ke
 }
 
 
+gboolean osinfo_entity_get_param_value_boolean(OsinfoEntity *entity, const gchar *key)
+{
+    const gchar *value = osinfo_entity_get_param_value(entity, key);
+
+    return value && g_str_equal(value, "true");
+}
+
+
 /**
  * osinfo_entity_get_param_value_list:
  * @entity: OsinfoEntity containing the parameters
diff --git a/osinfo/osinfo_entity.h b/osinfo/osinfo_entity.h
index 2ddba57..ce1968e 100644
--- a/osinfo/osinfo_entity.h
+++ b/osinfo/osinfo_entity.h
@@ -68,8 +68,10 @@ const gchar *osinfo_entity_get_id(OsinfoEntity *entity);
 
 GList *osinfo_entity_get_param_keys(OsinfoEntity *entity);
 const gchar *osinfo_entity_get_param_value(OsinfoEntity *entity, const gchar *key);
+gboolean osinfo_entity_get_param_value_boolean(OsinfoEntity *entity, const gchar *key);
 GList *osinfo_entity_get_param_value_list(OsinfoEntity *entity, const gchar *key);
 void osinfo_entity_set_param(OsinfoEntity *entity, const gchar *key, const gchar *value);
+void osinfo_entity_set_param_boolean(OsinfoEntity *entity, const gchar *key, gboolean value);
 void osinfo_entity_add_param(OsinfoEntity *entity, const gchar *key, const gchar *value);
 void osinfo_entity_clear_param(OsinfoEntity *entity, const gchar *key);
 
-- 
1.7.7.6


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