[gexiv2] Bug 736799 - missing structure creating Adds a function that allows to create a structure in xmp dat



commit 69d2c05fb201a5c3b0166e2660919d092c33a390
Author: Hartmut Kuhse <hk_priv gmx de>
Date:   Fri Sep 26 08:46:02 2014 +0200

    Bug 736799 - missing structure creating
    Adds a function that allows to create a structure
    in xmp data.

 gexiv2/gexiv2-metadata-xmp.cpp |   41 ++++++++++++++++++++++++++++++++++++++++
 gexiv2/gexiv2-metadata.h       |   18 +++++++++++++++++
 2 files changed, 59 insertions(+), 0 deletions(-)
---
diff --git a/gexiv2/gexiv2-metadata-xmp.cpp b/gexiv2/gexiv2-metadata-xmp.cpp
index b857ef5..ea5b9d3 100644
--- a/gexiv2/gexiv2-metadata-xmp.cpp
+++ b/gexiv2/gexiv2-metadata-xmp.cpp
@@ -156,6 +156,47 @@ gchar* gexiv2_metadata_get_xmp_tag_interpreted_string (GExiv2Metadata *self, con
     return NULL;
 }
 
+gboolean gexiv2_metadata_set_xmp_tag_struct (GExiv2Metadata *self, const gchar* tag, GExiv2StructureType 
type) {
+    g_return_val_if_fail(GEXIV2_IS_METADATA (self), FALSE);
+    g_return_val_if_fail(tag != NULL, FALSE);
+    g_return_val_if_fail(self->priv->image.get() != NULL, FALSE);
+
+    Exiv2::XmpTextValue tv("");
+    Exiv2::XmpData& xmp_data = self->priv->image->xmpData();
+
+    switch (type) {
+      case GEXIV2_STRUCTURE_XA_NONE:
+        tv.read("");  // Clear the value
+        tv.setXmpArrayType(Exiv2::XmpValue::xaNone);
+        break;
+      case GEXIV2_STRUCTURE_XA_ALT:
+        tv.read("");
+        tv.setXmpArrayType(Exiv2::XmpValue::xaAlt);
+        break;
+      case GEXIV2_STRUCTURE_XA_BAG:
+        tv.read("");
+        tv.setXmpArrayType(Exiv2::XmpValue::xaBag);
+        break;
+      case GEXIV2_STRUCTURE_XA_SEQ:
+        tv.read("");
+        tv.setXmpArrayType(Exiv2::XmpValue::xaSeq);
+        break;
+      default:
+        g_warning("Invalid structure type.");
+        return FALSE;
+        break;
+    }
+
+    try {
+        xmp_data.add(Exiv2::XmpKey(tag), &tv);
+        return TRUE;
+    } catch (Exiv2::Error& e) {
+        LOG_ERROR(e);
+    }
+    
+    return FALSE;
+}
+
 gboolean gexiv2_metadata_set_xmp_tag_string (GExiv2Metadata *self, const gchar* tag, 
     const gchar* value) {
     g_return_val_if_fail(GEXIV2_IS_METADATA (self), FALSE);
diff --git a/gexiv2/gexiv2-metadata.h b/gexiv2/gexiv2-metadata.h
index 612cf31..bc4ebd3 100644
--- a/gexiv2/gexiv2-metadata.h
+++ b/gexiv2/gexiv2-metadata.h
@@ -64,6 +64,13 @@ typedef enum {
        GEXIV2_ORIENTATION_MAX                  = 8
 } GExiv2Orientation;
 
+typedef enum {
+  GEXIV2_STRUCTURE_XA_NONE = 0,
+  GEXIV2_STRUCTURE_XA_ALT  = 20,
+  GEXIV2_STRUCTURE_XA_BAG  = 21,
+  GEXIV2_STRUCTURE_XA_SEQ  = 22,
+  GEXIV2_STRUCTURE_XA_LANG = 23
+} GExiv2StructureType;
 
 typedef struct _GExiv2Metadata                 GExiv2Metadata;
 typedef struct _GExiv2MetadataClass            GExiv2MetadataClass;
@@ -338,6 +345,17 @@ gchar*                     gexiv2_metadata_get_tag_string          (GExiv2Metadata 
*self, const gchar* tag
 gboolean               gexiv2_metadata_set_tag_string          (GExiv2Metadata *self, const gchar* tag, 
const gchar* value);
 
 /**
+ * gexiv2_metadata_set_tag_struct:
+ * @tag: Exiv2 tag name
+ * @type: The GExiv2StructureType specifying the type of structure
+ *
+ * The Exiv2 Tag Reference can be found at http://exiv2.org/metadata.html
+ *
+ * Returns: TRUE on success
+ */
+gboolean gexiv2_metadata_set_xmp_tag_struct (GExiv2Metadata *self, const gchar* tag, GExiv2StructureType 
type);
+
+/**
  * gexiv2_metadata_get_tag_interpreted_string:
  * @tag: Exiv2 tag name
  *


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