[SCM] exiv2 packaging branch, master, updated. debian/0.25-3.1-3734-gdcbc29a

Maximiliano Curia maxy at moszumanska.debian.org
Thu Jul 13 17:38:49 UTC 2017


Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/exiv2.git;a=commitdiff;h=ce170e0

The following commit has been merged in the master branch:
commit ce170e093b9cd86c7cccebc37fbdb34b66fb6af5
Author: Andreas Huggel <ahuggel at gmx.net>
Date:   Sun Sep 30 14:23:19 2007 +0000

    Generalized Xmpdatum::operator=.
---
 src/xmp.cpp                  |  8 --------
 src/xmp.hpp                  | 45 +++++++++++++++++++++++++++++++++++++-------
 src/xmpsample.cpp            | 22 ++++++++++++++++++----
 test/data/xmpparser-test.out | 14 ++++++++++++++
 4 files changed, 70 insertions(+), 19 deletions(-)

diff --git a/src/xmp.cpp b/src/xmp.cpp
index e2668d3..ae32b89 100644
--- a/src/xmp.cpp
+++ b/src/xmp.cpp
@@ -246,14 +246,6 @@ namespace Exiv2 {
         return 0;
     }
 
-    Xmpdatum& Xmpdatum::operator=(const uint16_t& value)
-    {
-        XmpTextValue::AutoPtr v(new XmpTextValue);
-        v->read(toString(value));
-        p_->value_ = v;
-        return *this;
-    }
-
     Xmpdatum& Xmpdatum::operator=(const std::string& value)
     {
         setValue(value);
diff --git a/src/xmp.hpp b/src/xmp.hpp
index b61aece..e4745c5 100644
--- a/src/xmp.hpp
+++ b/src/xmp.hpp
@@ -80,17 +80,28 @@ namespace Exiv2 {
         //! Assignment operator
         Xmpdatum& operator=(const Xmpdatum& rhs);
         /*!
-          @brief Assign \em value to the %Xmpdatum. The type of the new Value
-                 is set to XmpTextValue.
-         */
-        Xmpdatum& operator=(const uint16_t& value);
-        /*!
-          @brief Assign \em value to the %Xmpdatum.
+          @brief Assign std::string \em value to the %Xmpdatum.
                  Calls setValue(const std::string&).
          */
         Xmpdatum& operator=(const std::string& value);
         /*!
-          @brief Assign \em value to the %Xmpdatum.
+          @brief Assign const char* \em value to the %Xmpdatum.
+                 Calls operator=(const std::string&).
+         */
+        Xmpdatum& operator=(const char* value);
+        /*!
+          @brief Assign a boolean \em value to the %Xmpdatum.
+                 Translates the value to a string "true" or "false".
+         */
+        Xmpdatum& operator=(const bool& value);
+        /*!
+          @brief Assign a \em value of any type with an output operator
+                 to the %Xmpdatum. Calls operator=(const std::string&).
+         */
+        template<typename T>
+        Xmpdatum& operator=(const T& value);
+        /*!
+          @brief Assign Value \em value to the %Xmpdatum.
                  Calls setValue(const Value*).
          */
         Xmpdatum& operator=(const Value& value);
@@ -311,6 +322,26 @@ namespace Exiv2 {
 
     }; // class XmpParser
 
+// *****************************************************************************
+// free functions, template and inline definitions
+
+    inline Xmpdatum& Xmpdatum::operator=(const char* value)
+    {
+        return Xmpdatum::operator=(std::string(value));
+    }
+
+    inline Xmpdatum& Xmpdatum::operator=(const bool& value)
+    {
+        return operator=(value ? "true" : "false");
+    }
+
+    template<typename T>
+    Xmpdatum& Xmpdatum::operator=(const T& value)
+    {
+        setValue(Exiv2::toString(value));
+        return *this;
+    }
+
 }                                       // namespace Exiv2
 
 #endif                                  // #ifndef XMP_HPP_
diff --git a/src/xmpsample.cpp b/src/xmpsample.cpp
index dbd65a9..aa71740 100644
--- a/src/xmpsample.cpp
+++ b/src/xmpsample.cpp
@@ -15,7 +15,7 @@ try {
     Exiv2::XmpData xmpData;
 
     // -------------------------------------------------------------------------
-    // Teaser: The quickest way to add simple XMP properties using Exiv2
+    // Teaser: Setting XMP properties doesn't get much easier than this:
 
     xmpData["Xmp.dc.source"]  = "xmpsample.cpp";    // a simple text value
     xmpData["Xmp.dc.subject"] = "Palmtree";         // an array item
@@ -23,6 +23,20 @@ try {
     xmpData["Xmp.dc.title"]   = "lang=en-US Beach"; // a language alternative
 
     // -------------------------------------------------------------------------
+    // Any properties can be set provided the namespace is known. Values of any
+    // type can be assigned to an Xmpdatum (requires an output operator). The
+    // default XMP value type for unknown properties is a simple text value.
+
+    xmpData["Xmp.dc.one"]     = -1;
+    xmpData["Xmp.dc.two"]     = 3.1415;
+    xmpData["Xmp.dc.three"]   = Exiv2::Rational(5, 7);
+    xmpData["Xmp.dc.four"]    = uint16_t(255);
+    xmpData["Xmp.dc.five"]    = int32_t(256);
+    xmpData["Xmp.dc.six"]     = false;
+    Exiv2::XmpTextValue val("Seven");
+    xmpData["Xmp.dc.seven"]   = val;
+
+    // -------------------------------------------------------------------------
     // Exiv2 has specialized values for simple XMP properties, arrays of simple
     // properties and language alternatives.
 
@@ -52,7 +66,7 @@ try {
 
     // -------------------------------------------------------------------------
     // There are no specialized values for structures, qualifiers and nested
-    // types. However, these can be added by using a XmpTextValue and a path as
+    // types. However, these can be added by using an XmpTextValue and a path as
     // the key.
 
     // Add a structure
@@ -74,11 +88,11 @@ try {
     xmpData.add(Exiv2::XmpKey("Xmp.dc.creator[2]/?ns:role"), &tv);
 
     // Add an array of structures
-    tv.read("");
+    tv.read("");                                         // Clear the value
     tv.setXmpArrayType(Exiv2::XmpValue::xaBag);
     xmpData.add(Exiv2::XmpKey("Xmp.xmpBJ.JobRef"), &tv); // Set the array type.
-    tv.setXmpArrayType(Exiv2::XmpValue::xaNone);
 
+    tv.setXmpArrayType(Exiv2::XmpValue::xaNone);
     tv.read("Birtday party");
     xmpData.add(Exiv2::XmpKey("Xmp.xmpBJ.JobRef[1]/stJob:name"), &tv);
     tv.read("Photographer");
diff --git a/test/data/xmpparser-test.out b/test/data/xmpparser-test.out
index 8b2629c..4bf0c04 100644
--- a/test/data/xmpparser-test.out
+++ b/test/data/xmpparser-test.out
@@ -282,6 +282,13 @@ Xmp.ns1.NestedStructProp/ns2:Outer/ns2:Middle/ns2:Inner/ns2:Field2 XmpText    12
 Xmp.dc.source                                XmpText    13  xmpsample.cpp
 Xmp.dc.subject                               XmpBag      2  Palmtree, Rubbertree
 Xmp.dc.title                                 LangAlt     1  lang="en-US" Beach
+Xmp.dc.one                                   XmpText     2  -1
+Xmp.dc.two                                   XmpText     6  3.1415
+Xmp.dc.three                                 XmpText     3  5/7
+Xmp.dc.four                                  XmpText     3  255
+Xmp.dc.five                                  XmpText     3  256
+Xmp.dc.six                                   XmpText     5  false
+Xmp.dc.seven                                 XmpText     5  Seven
 Xmp.dc.format                                XmpText    10  image/jpeg
 Xmp.dc.creator                               XmpSeq      3  1) The first creator, 2) The second creator, 3) And another one
 Xmp.dc.description                           LangAlt     2  lang="de-DE" Hallo, Welt, lang="x-default" Hello, World
@@ -307,6 +314,13 @@ Xmp.xmpBJ.JobRef[2]/stJob:role               XmpText     8  Best man
     xmlns:xapBJ="http://ns.adobe.com/xap/1.0/bj/"
     xmlns:stJob="http://ns.adobe.com/xap/1.0/sType/Job#"
    dc:source="xmpsample.cpp"
+   dc:one="-1"
+   dc:two="3.1415"
+   dc:three="5/7"
+   dc:four="255"
+   dc:five="256"
+   dc:six="false"
+   dc:seven="Seven"
    dc:format="image/jpeg">
    <dc:subject>
     <rdf:Bag>

-- 
exiv2 packaging



More information about the pkg-kde-commits mailing list