[libvirt-glib 03/23] Add getters for GVirConfig xmlNode and xmlDoc

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

 



They will be useful in subclasses to access the parsed document,
and to external users needing to directly interact with the
generated XML.
---
 libvirt-gconfig/libvirt-gconfig-object.c |   18 ++++++++++++++++++
 libvirt-gconfig/libvirt-gconfig-object.h |    2 ++
 libvirt-gconfig/libvirt-gconfig.sym      |    2 ++
 3 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/libvirt-gconfig/libvirt-gconfig-object.c b/libvirt-gconfig/libvirt-gconfig-object.c
index 6f80346..52e9be0 100644
--- a/libvirt-gconfig/libvirt-gconfig-object.c
+++ b/libvirt-gconfig/libvirt-gconfig-object.c
@@ -276,3 +276,21 @@ const gchar *gvir_config_object_get_schema(GVirConfigObject *config)
     return priv->schema;
 }
 
+/* NB: the xmlDocPtr must not be freed by the caller */
+xmlDocPtr gvir_config_object_get_xml_doc(GVirConfigObject *config, GError **error)
+{
+    gvir_config_object_parse(config, error);
+    return config->priv->docHandle;
+}
+
+/* FIXME: will we always have one xmlNode per GConfig object? */
+/* FIXME: need to return the right node from subclasses */
+/* NB: the xmlNodePtr must not be freed by the caller */
+xmlNodePtr gvir_config_object_get_xml_node(GVirConfigObject *config,
+                                           GError **error)
+{
+    gvir_config_object_parse(config, error);
+    if (error)
+        return NULL;
+    return config->priv->docHandle->children;
+}
diff --git a/libvirt-gconfig/libvirt-gconfig-object.h b/libvirt-gconfig/libvirt-gconfig-object.h
index d08e97d..a0c0489 100644
--- a/libvirt-gconfig/libvirt-gconfig-object.h
+++ b/libvirt-gconfig/libvirt-gconfig-object.h
@@ -64,6 +64,8 @@ void gvir_config_object_validate(GVirConfigObject *config,
 
 const gchar *gvir_config_object_get_doc(GVirConfigObject *config);
 const gchar *gvir_config_object_get_schema(GVirConfigObject *config);
+xmlDocPtr  gvir_config_object_get_xml_doc(GVirConfigObject *config, GError **error);
+xmlNodePtr gvir_config_object_get_xml_node(GVirConfigObject *config, GError **error);
 
 G_END_DECLS
 
diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym
index 24407c3..d20e73b 100644
--- a/libvirt-gconfig/libvirt-gconfig.sym
+++ b/libvirt-gconfig/libvirt-gconfig.sym
@@ -26,6 +26,8 @@ LIBVIRT_GOBJECT_0.0.1 {
 	gvir_config_object_new;
 	gvir_config_object_get_doc;
 	gvir_config_object_get_schema;
+	gvir_config_object_get_xml_doc;
+	gvir_config_object_get_xml_node;
 	gvir_config_object_validate;
 
 	gvir_config_secret_get_type;
-- 
1.7.6.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]