[gexiv2] all: Fix building against Exiv2 master



commit 71002386338250ecb033033278e05cd5c7f94c4c
Author: Jens Georg <mail jensge org>
Date:   Tue Jan 1 12:46:31 2019 +0100

    all: Fix building against Exiv2 master
    
    Also requires C++11 for std::move

 gexiv2/gexiv2-metadata-iptc.cpp  |  2 +-
 gexiv2/gexiv2-metadata-private.h |  4 ++++
 gexiv2/gexiv2-metadata.cpp       | 25 ++++++++++++++++++-------
 gexiv2/gexiv2-stream-io.cpp      | 12 ++++++------
 gexiv2/gexiv2-stream-io.h        | 10 +++++++---
 meson.build                      | 10 +++++++++-
 6 files changed, 45 insertions(+), 18 deletions(-)
---
diff --git a/gexiv2/gexiv2-metadata-iptc.cpp b/gexiv2/gexiv2-metadata-iptc.cpp
index aeac1c7..a45bf38 100644
--- a/gexiv2/gexiv2-metadata-iptc.cpp
+++ b/gexiv2/gexiv2-metadata-iptc.cpp
@@ -220,7 +220,7 @@ gboolean gexiv2_metadata_set_iptc_tag_multiple (GExiv2Metadata *self, const gcha
         }
         
         /* ... and then set the others */
-        Exiv2::Value::AutoPtr iptc_value = Exiv2::Value::create(Exiv2::string);
+        auto iptc_value = Exiv2::Value::create(Exiv2::string);
             
         const gchar **it = values;
         while (*it != NULL) {
diff --git a/gexiv2/gexiv2-metadata-private.h b/gexiv2/gexiv2-metadata-private.h
index 8818c22..b0ccd7a 100644
--- a/gexiv2/gexiv2-metadata-private.h
+++ b/gexiv2/gexiv2-metadata-private.h
@@ -17,7 +17,11 @@ G_BEGIN_DECLS
 
 struct _GExiv2MetadataPrivate
 {
+#if EXIV2_TEST_VERSION(0,27,99)
+    Exiv2::Image::UniquePtr image;
+#else
     Exiv2::Image::AutoPtr image;
+#endif
     gchar* comment;
     gchar* mime_type;
     gint pixel_width;
diff --git a/gexiv2/gexiv2-metadata.cpp b/gexiv2/gexiv2-metadata.cpp
index 9c791ef..83ec604 100644
--- a/gexiv2/gexiv2-metadata.cpp
+++ b/gexiv2/gexiv2-metadata.cpp
@@ -25,6 +25,11 @@
 
 #include <exiv2/exiv2.hpp>
 
+#if EXIV2_TEST_VERSION(0,27,99)
+using image_ptr = Exiv2::Image::UniquePtr;
+#else
+using image_ptr = Exiv2::Image::AutoPtr;
+#endif
 
 G_BEGIN_DECLS
 
@@ -34,7 +39,7 @@ static void gexiv2_metadata_finalize (GObject *object);
 static void gexiv2_metadata_set_comment_internal (GExiv2Metadata *self, const gchar *new_comment);
 
 static gboolean gexiv2_metadata_open_internal (GExiv2Metadata *self, GError **error);
-static gboolean gexiv2_metadata_save_internal (GExiv2Metadata *self, Exiv2::Image::AutoPtr image, GError 
**error);
+static gboolean gexiv2_metadata_save_internal (GExiv2Metadata *self, image_ptr image, GError **error);
 
 static void gexiv2_metadata_init (GExiv2Metadata *self) {
     GExiv2MetadataPrivate *priv;
@@ -156,8 +161,7 @@ gboolean gexiv2_metadata_open_path (GExiv2Metadata *self, const gchar *path, GEr
     g_return_val_if_fail (GEXIV2_IS_METADATA (self), FALSE);
     
     try {
-        Exiv2::BasicIo::AutoPtr file (new Exiv2::FileIo (path));
-        self->priv->image = Exiv2::ImageFactory::open (file);
+        self->priv->image = Exiv2::ImageFactory::open (path);
         
         return gexiv2_metadata_open_internal (self, error);
     } catch (Exiv2::Error &e) {
@@ -186,8 +190,12 @@ gboolean gexiv2_metadata_open_stream (GExiv2Metadata *self, ManagedStreamCallbac
     g_return_val_if_fail (GEXIV2_IS_METADATA (self), FALSE);
     
     try {
-        Exiv2::BasicIo::AutoPtr stream_ptr (new StreamIo (cb));
+        StreamIo::ptr_type stream_ptr{new StreamIo (cb)};
+#if EXIV2_TEST_VERSION(0,27,99)
+        self->priv->image = Exiv2::ImageFactory::open (std::move(stream_ptr));
+#else
         self->priv->image = Exiv2::ImageFactory::open (stream_ptr);
+#endif
         
         return gexiv2_metadata_open_internal (self, error);
     } catch (Exiv2::Error &e) {
@@ -243,8 +251,7 @@ gboolean gexiv2_metadata_from_app1_segment(GExiv2Metadata *self, const guint8 *d
     }
 }
 
-static gboolean gexiv2_metadata_save_internal (GExiv2Metadata *self, Exiv2::Image::AutoPtr image,
-    GError **error) {
+static gboolean gexiv2_metadata_save_internal (GExiv2Metadata *self, image_ptr image, GError **error) {
     if (image.get () == NULL || ! image->good ()) {
         g_set_error_literal (error, g_quark_from_string ("GExiv2"),
             501, "format seems not to be supported");
@@ -331,9 +338,13 @@ gboolean gexiv2_metadata_save_stream (GExiv2Metadata *self, ManagedStreamCallbac
     g_return_val_if_fail (GEXIV2_IS_METADATA (self), FALSE);
     
     try {
-        Exiv2::BasicIo::AutoPtr stream_ptr (new StreamIo (cb));
+        StreamIo::ptr_type stream_ptr{new StreamIo (cb)};
         
+#if EXIV2_TEST_VERSION(0,27,99)
+        return gexiv2_metadata_save_internal (self, Exiv2::ImageFactory::open (std::move(stream_ptr)), 
error);
+#else
         return gexiv2_metadata_save_internal (self, Exiv2::ImageFactory::open (stream_ptr), error);
+#endif
     } catch (Exiv2::Error &e) {
         g_set_error_literal (error, g_quark_from_string ("GExiv2"), e.code (), e.what ());
     }
diff --git a/gexiv2/gexiv2-stream-io.cpp b/gexiv2/gexiv2-stream-io.cpp
index 454305d..75042a5 100644
--- a/gexiv2/gexiv2-stream-io.cpp
+++ b/gexiv2/gexiv2-stream-io.cpp
@@ -21,7 +21,7 @@
 #include <exception>
 
 StreamIo::StreamIo (ManagedStreamCallbacks* callbacks)
-    : cb (callbacks), memio(NULL), is_open (FALSE), can_write(FALSE) {
+    : cb (callbacks), memio(nullptr), is_open (FALSE), can_write(FALSE) {
     /* at least reading and seeking must be possible to read metatada */
     if ( ! cb->CanRead (cb->handle))
         throw std::exception ();
@@ -33,16 +33,16 @@ StreamIo::StreamIo (ManagedStreamCallbacks* callbacks)
 }
 
 StreamIo::~StreamIo () {
-    memio.reset (NULL);
+    memio.reset (nullptr);
 }
 
 int StreamIo::munmap () {
     int result = 0;
     
     /* remove current memio object */
-    if (memio.get () != NULL) {
+    if (memio.get () != nullptr) {
         result = memio->munmap ();
-        memio.reset (NULL);
+        memio.reset (nullptr);
     }
     
     return result;
@@ -58,9 +58,9 @@ Exiv2::byte* StreamIo::mmap (bool isWriteable) {
     return memio->mmap (isWriteable);
 }
 
-Exiv2::BasicIo::AutoPtr StreamIo::temporary () const {
+StreamIo::ptr_type StreamIo::temporary () const {
     /* here again, we just juse the memory for temporary buffer */
-    return Exiv2::BasicIo::AutoPtr (new Exiv2::MemIo ());
+    return ptr_type{new Exiv2::MemIo ()};
 }
 
 long StreamIo::write (const Exiv2::byte* data, long write_count) {
diff --git a/gexiv2/gexiv2-stream-io.h b/gexiv2/gexiv2-stream-io.h
index 8d1fe76..b6aa610 100644
--- a/gexiv2/gexiv2-stream-io.h
+++ b/gexiv2/gexiv2-stream-io.h
@@ -22,6 +22,11 @@
 
 class StreamIo : public Exiv2::BasicIo {
 public:
+#if EXIV2_TEST_VERSION(0,27,99)
+    using ptr_type = Exiv2::BasicIo::UniquePtr;
+#else
+    using ptr_type = Exiv2::BasicIo::AutoPtr;
+#endif
 
        StreamIo (ManagedStreamCallbacks* cb);
 
@@ -47,15 +52,14 @@ public:
 #ifdef EXV_UNICODE_PATH
        virtual std::wstring wpath () const;
 #endif
-       virtual BasicIo::AutoPtr temporary () const;
+       virtual ptr_type temporary () const;
 
 private:
-
        /* stream callbacks */
        ManagedStreamCallbacks* cb;
        
        /* used for mmap and  munmap */
-       Exiv2::BasicIo::AutoPtr memio;
+       ptr_type memio;
 
        /* closing does not mean closing the stream, because this would
           destroy it. So just keep track about current state and let stream
diff --git a/meson.build b/meson.build
index 0430365..579905f 100644
--- a/meson.build
+++ b/meson.build
@@ -1,4 +1,12 @@
-project('gexiv2', ['c', 'cpp'], version : '0.11.0')
+project(
+    'gexiv2',
+    ['c', 'cpp'],
+    version : '0.11.0',
+    default_options : [
+        'cpp_std=c++11'
+    ]
+)
+
 gnome = import('gnome')
 pkg = import('pkgconfig')
 


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