[glibmm] Gio::File::load_contents() override to allow ignoring the etag contents. (Bug #581349)



commit 4c1807c4cfb588597bcd0bb7de3744eb37a09c77
Author: Hubert Figuiere <hub figuiere net>
Date:   Wed Jun 17 17:15:16 2009 -0400

    Gio::File::load_contents() override to allow ignoring the etag contents. (Bug #581349)

 ChangeLog                  |    6 +++
 docs/reference/Doxyfile.in |    3 +-
 gio/src/file.ccg           |   76 ++++++++++++++++++++++++++++++++++++++++++++
 gio/src/file.hg            |   60 ++++++++++++++++++++++++++++++++++
 4 files changed, 144 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 82a564f..2fa2a59 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-06-17  Hubert Figuiere  <hub figuiere net>
+
+	* gio/src/file.hg: 
+	* gio/src/file.ccg: Gio::File::load_contents() override to allow ignoring the
+	etag contents. (Bug #581349)
+
 2009-06-16  José Alburquerque  <jaalburqu svn gnome org>
 
 	* tools/extra_defs_gen/generate_extra_defs.cc:
diff --git a/docs/reference/Doxyfile.in b/docs/reference/Doxyfile.in
index ebb5cd6..94c3d18 100644
--- a/docs/reference/Doxyfile.in
+++ b/docs/reference/Doxyfile.in
@@ -194,7 +194,8 @@ ALIASES                = "newin2p2=\xrefitem newin2p2s \"Since glibmm 2.2\" \"Ne
                          "newin2p14=\xrefitem newin2p14s \"Since glibmm 2.14\" \"New API since glibmm 2.14\" " \
                          "newin2p16=\xrefitem newin2p16s \"Since glibmm 2.16\" \"New API since glibmm 2.16\" " \
                          "newin2p18=\xrefitem newin2p18s \"Since glibmm 2.18\" \"New API since glibmm 2.18\" " \
-                         "newin2p20=\xrefitem newin2p20s \"Since glibmm 2.20\" \"New API since glibmm 2.20\" "
+                         "newin2p20=\xrefitem newin2p20s \"Since glibmm 2.20\" \"New API since glibmm 2.20\" " \
+                         "newin2p22=\xrefitem newin2p22s \"Since glibmm 2.22\" \"New API since glibmm 2.22\" "
 
 # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C 
 # sources only. Doxygen will then generate output that is more tailored for C. 
diff --git a/gio/src/file.ccg b/gio/src/file.ccg
index a3d8cac..007e73f 100644
--- a/gio/src/file.ccg
+++ b/gio/src/file.ccg
@@ -2076,6 +2076,25 @@ bool File::load_contents(const Glib::RefPtr<Cancellable>& cancellable, char*& co
 }
 
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
+bool File::load_contents(const Glib::RefPtr<Cancellable>& cancellable, char*& contents, gsize& length)
+#else
+bool File::load_contents(const Glib::RefPtr<Cancellable>& cancellable, char*& contents, gsize& length, std::auto_ptr<Glib::Error>& error)
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+{
+  GError* gerror = 0;
+  bool retvalue = g_file_load_contents(gobj(), Glib::unwrap(cancellable), &contents, &(length), 0, &(gerror));
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+  if(gerror)
+    ::Glib::Error::throw_exception(gerror);
+#else
+  if(gerror)
+    error = ::Glib::Error::throw_exception(gerror);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+
+  return retvalue;
+}
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
 bool File::load_contents(char*& contents, gsize& length, std::string& etag_out)
 #else
 bool File::load_contents(char*& contents, gsize& length, std::string& etag_out, std::auto_ptr<Glib::Error>& error)
@@ -2098,6 +2117,25 @@ bool File::load_contents(char*& contents, gsize& length, std::string& etag_out,
 }
 
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
+bool File::load_contents(char*& contents, gsize& length)
+#else
+bool File::load_contents(char*& contents, gsize& length, std::auto_ptr<Glib::Error>& error)
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+{
+  GError* gerror = 0;
+  bool retvalue = g_file_load_contents(gobj(), NULL, &contents, &(length), 0, &(gerror));
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+  if(gerror)
+    ::Glib::Error::throw_exception(gerror);
+#else
+  if(gerror)
+    error = ::Glib::Error::throw_exception(gerror);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+
+  return retvalue;
+}
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
 bool File::load_contents_finish(const Glib::RefPtr<AsyncResult>& result, char*& contents, gsize& length, std::string& etag_out)
 #else
 bool File::load_contents_finish(const Glib::RefPtr<AsyncResult>& result, char*& contents, gsize& length, std::string& etag_out, std::auto_ptr<Glib::Error>& error)
@@ -2120,6 +2158,25 @@ bool File::load_contents_finish(const Glib::RefPtr<AsyncResult>& result, char*&
 }
 
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
+bool File::load_contents_finish(const Glib::RefPtr<AsyncResult>& result, char*& contents, gsize& length)
+#else
+bool File::load_contents_finish(const Glib::RefPtr<AsyncResult>& result, char*& contents, gsize& length, std::auto_ptr<Glib::Error>& error)
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+{
+  GError* gerror = 0;
+  bool retvalue = g_file_load_contents_finish(gobj(), Glib::unwrap(result), &contents, &(length), 0, &(gerror));
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+  if(gerror)
+    ::Glib::Error::throw_exception(gerror);
+#else
+  if(gerror)
+    error = ::Glib::Error::throw_exception(gerror);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+
+  return retvalue;
+}
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
 bool File::load_partial_contents_finish(const Glib::RefPtr<AsyncResult>& result, char*& contents, gsize& length, std::string& etag_out)
 #else
 bool File::load_partial_contents_finish(const Glib::RefPtr<AsyncResult>& result, char*& contents, gsize& length, std::string& etag_out, std::auto_ptr<Glib::Error>& error)
@@ -2141,4 +2198,23 @@ bool File::load_partial_contents_finish(const Glib::RefPtr<AsyncResult>& result,
   return retvalue;
 }
 
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+bool File::load_partial_contents_finish(const Glib::RefPtr<AsyncResult>& result, char*& contents, gsize& length)
+#else
+bool File::load_partial_contents_finish(const Glib::RefPtr<AsyncResult>& result, char*& contents, gsize& length, std::auto_ptr<Glib::Error>& error)
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+{
+  GError* gerror = 0;
+  bool retvalue = g_file_load_partial_contents_finish(gobj(), Glib::unwrap(result), &contents, &(length), 0, &(gerror));
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+  if(gerror)
+    ::Glib::Error::throw_exception(gerror);
+#else
+  if(gerror)
+    error = ::Glib::Error::throw_exception(gerror);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+
+  return retvalue;
+}
+
 } // namespace Gio
diff --git a/gio/src/file.hg b/gio/src/file.hg
index 6c0b52c..1b8d919 100644
--- a/gio/src/file.hg
+++ b/gio/src/file.hg
@@ -1731,6 +1731,22 @@ public:
 #else
   bool load_contents(const Glib::RefPtr<Cancellable>& cancellable, char*& contents, gsize& length, std::string& etag_out, std::auto_ptr<Glib::Error>& error);
 #endif
+  /** Loads the content of the file into memory, returning the size of the data. 
+   * The data is always zero terminated, but this is not included in the resultant @a length.
+   * 
+   * The operation can be cancelled by triggering the cancellable object from another thread. 
+   * If the operation was cancelled, a Gio::Error exception with CANCELLED will be returned.
+   *
+   * @param cancellable A cancellable object.
+   * @param contents A location to place the contents of the file. 
+   * @param length A location to place the length of the contents of the file.
+   * @newin2p22
+   */
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+  bool load_contents(const Glib::RefPtr<Cancellable>& cancellable, char*& contents, gsize& length);
+#else
+  bool load_contents(const Glib::RefPtr<Cancellable>& cancellable, char*& contents, gsize& length, std::auto_ptr<Glib::Error>& error);
+#endif
   //TODO: Something better than char*& for contents?
   /** Loads the content of the file into memory, returning the size of the data. 
    * The data is always zero terminated, but this is not included in the resultant @a length.
@@ -1745,6 +1761,18 @@ public:
   bool load_contents(char*& contents, gsize& length, std::string& etag_out,
                      std::auto_ptr<Glib::Error>& error);
 #endif
+  /** Loads the content of the file into memory, returning the size of the data. 
+   * The data is always zero terminated, but this is not included in the resultant @a length.
+   *
+   * @param contents A location to place the contents of the file. 
+   * @param length A location to place the length of the contents of the file.
+   * @newin2p22
+   */
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+  bool load_contents(char*& contents, gsize& length);
+#else
+  bool load_contents(char*& contents, gsize& length, std::auto_ptr<Glib::Error>& error);
+#endif
   _IGNORE(g_file_load_contents)
 
   /** Starts an asynchronous load of the file's contents.
@@ -1788,6 +1816,23 @@ public:
 #else
   bool load_contents_finish(const Glib::RefPtr<AsyncResult>& result, char*& contents, gsize& length, std::string& etag_out, std::auto_ptr<Glib::Error>& error);
 #endif //GLIBMM_EXCEPTIONS_ENABLED
+
+  /** Finishes an asynchronous load of the @a file's contents. 
+   * The contents are placed in @a contents, and @a length is set to the 
+   * size of the @a contents string. If @a etag_out is present, it will be 
+   * set to the new entity tag for the @a file.
+   * @param res A AsyncResult.
+   * @param contents A location to place the contents of the file.
+   * @param length A location to place the length of the contents of the file.
+   * @return <tt>true</tt> if the load was successful. If <tt>false</tt> and @a error is 
+   * present, it will be set appropriately.
+   * @newin2p22
+   */
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+  bool load_contents_finish(const Glib::RefPtr<AsyncResult>& result, char*& contents, gsize& length);
+#else
+  bool load_contents_finish(const Glib::RefPtr<AsyncResult>& result, char*& contents, gsize& length, std::auto_ptr<Glib::Error>& error);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
   _IGNORE(g_file_load_contents_finish)
 
 
@@ -1842,6 +1887,21 @@ public:
 #else
   bool load_partial_contents_finish(const Glib::RefPtr<AsyncResult>& result, char*& contents, gsize& length, std::string& etag_out, std::auto_ptr<Glib::Error>& error);
 #endif //GLIBMM_EXCEPTIONS_ENABLED
+
+  /** Finishes an asynchronous partial load operation that was started
+   * with load_partial_contents_async().
+   * @param res A AsyncResult.
+   * @param contents A location to place the contents of the file.
+   * @param length A location to place the length of the contents of the file.
+   * @return <tt>true</tt> if the load was successful. If <tt>false</tt> and @a error is 
+   * present, it will be set appropriately.
+   * @newin2p22
+   */
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+  bool load_partial_contents_finish(const Glib::RefPtr<AsyncResult>& result, char*& contents, gsize& length);
+#else
+  bool load_partial_contents_finish(const Glib::RefPtr<AsyncResult>& result, char*& contents, gsize& length, std::auto_ptr<Glib::Error>& error);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
   _IGNORE(g_file_load_partial_contents_finish)
 
   /** Replaces the contents of the file with @a contents of @a length bytes.



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