[libgdamm] ServerOperation: set_value_at(): Make this templated.



commit 241ce5bdfad7dce3c90e9ef7e4e777361c6ff65d
Author: Murray Cumming <murrayc murrayc com>
Date:   Mon Jun 21 18:27:41 2010 +0200

    ServerOperation: set_value_at(): Make this templated.
    
    	* libgda/src/serveroperation.[hg|ccg]: Add set_value_at_as_value() and make
    	set_value_at() a templated method, instead of just taking a string.

 ChangeLog                      |    7 +++++++
 libgda/src/serveroperation.ccg |    8 +++++---
 libgda/src/serveroperation.hg  |   31 ++++++++++++++++++++++++++++---
 3 files changed, 40 insertions(+), 6 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 945c5e2..fb7085f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2010-06-21  Murray Cumming  <murrayc murrayc com>
 
+	ServerOperation: set_value_at(): Make this templated.
+
+	* libgda/src/serveroperation.[hg|ccg]: Add set_value_at_as_value() and make 
+	set_value_at() a templated method, instead of just taking a string.
+
+2010-06-21  Murray Cumming  <murrayc murrayc com>
+
 	Add CREATE_USER, ALTER USER and DROP USER server operations.
 
 	* libgda/src/libgda_methods.defs: Regenerate with h2defs.py though the enums 
diff --git a/libgda/src/serveroperation.ccg b/libgda/src/serveroperation.ccg
index 75d5d98..7938adb 100644
--- a/libgda/src/serveroperation.ccg
+++ b/libgda/src/serveroperation.ccg
@@ -124,13 +124,15 @@ Value ServerOperation::get_value_at(const Glib::ustring& path) const
 }  
 
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
-void ServerOperation::set_value_at(const Glib::ustring& path, const Glib::ustring& value)
+void ServerOperation::set_value_at_as_value(const Glib::ustring& path, const Glib::ValueBase& value)
 #else
-void ServerOperation::set_value_at(const Glib::ustring& path, const Glib::ustring& value, std::auto_ptr<Glib::Error>& error)
+void ServerOperation::set_value_at_as_value(const Glib::ustring& path, const Glib::ValueBase& value, std::auto_ptr<Glib::Error>& error)
 #endif // GLIBMM_EXCEPTIONS_ENABLED
 {
+  gchar* strvalue = gda_value_stringify(value.gobj());
   GError* gerror = 0;
-  gda_server_operation_set_value_at(gobj(), value.c_str(), &gerror, "%s", path.c_str());
+  gda_server_operation_set_value_at(gobj(), strvalue, &gerror, "%s", path.c_str());
+  g_free(strvalue);
 
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
   if(gerror) ::Glib::Error::throw_exception(gerror);
diff --git a/libgda/src/serveroperation.hg b/libgda/src/serveroperation.hg
index 10c34b5..a5d04e8 100644
--- a/libgda/src/serveroperation.hg
+++ b/libgda/src/serveroperation.hg
@@ -89,11 +89,18 @@ public:
   _WRAP_METHOD_DOCS_ONLY(gda_server_operation_get_value_at)
   Value get_value_at(const Glib::ustring& path_format) const;
 
-  _WRAP_METHOD_DOCS_ONLY(gda_server_operation_set_value_at)
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
-  void set_value_at(const Glib::ustring& path_format, const Glib::ustring& value);
+  template <class ValueType>
+  void set_value_at(const Glib::ustring& path_format, const ValueType& value);
 #else
-  void set_value_at(const Glib::ustring& path_format, const Glib::ustring& value, std::auto_ptr<Glib::Error>& error);
+  template <class ValueType>
+  void set_value_at(const Glib::ustring& path_format, const ValueType& value, std::auto_ptr<Glib::Error>& error);
+#endif // GLIBMM_EXCEPTIONS_ENABLED
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+  void set_value_at_as_value(const Glib::ustring& path_format, const Glib::ValueBase& value);
+#else
+  void set_value_at_as_value(const Glib::ustring& path_format, const Glib::ValueBase& value, std::auto_ptr<Glib::Error>& error);
 #endif // GLIBMM_EXCEPTIONS_ENABLED
 
   //TODO: See http://bugzilla.gnome.org/show_bug.cgi?id=574742
@@ -127,6 +134,24 @@ public:
  //TODO: vfuncs.
 };
 
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+template <class ValueType> inline
+void ServerOperation::set_value_at(const Glib::ustring& path_format, const ValueType& value)
+{
+  Gnome::Gda::Value gdavalue(value);
+  this->set_value_at_as_value(path_format.c_str(), gdavalue);
+}
+#else
+template <class ValueType> inline
+void ServerOperation::set_value_at(const Glib::ustring& path_format, const ValueType& value, std::auto_ptr<Glib::Error>& error)
+{
+  Gnome::Gda::Value gdavalue(value);
+  this->set_value_at_as_value(path_format.c_str(), gdavalue, error);
+}
+#endif
+#endif //DOXYGEN_SHOULD_SKIP_THIS
+
 } // namespace Gda
 } // namespace Gnome
 



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