[SCM] exiv2 packaging branch, master, updated. debian/0.25-3.1-3734-gdcbc29a
Maximiliano Curia
maxy at moszumanska.debian.org
Thu Jul 13 17:36:49 UTC 2017
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/exiv2.git;a=commitdiff;h=dff55f6
The following commit has been merged in the master branch:
commit dff55f692ed4a14fb407a622517d45f296e8109f
Author: Andreas Huggel <ahuggel at gmx.net>
Date: Wed Dec 8 16:41:08 2004 +0000
Changed semantic of Iptcdatum::setValue(const std::string&) !!! - it now creates a
value of a type determined by the Iptcdatum.
Added IptcData::op[] and Iptcdatum::op=. With this, you can do things like:
iptcData["Iptc.Envelope.TimeSent"] = "14:41:0-05:00"; which creates a TimeValue.
---
src/iptc.cpp | 39 +++++++++++++++++++++++++++++++++++++--
src/iptc.hpp | 27 ++++++++++++++++++++++++---
2 files changed, 61 insertions(+), 5 deletions(-)
diff --git a/src/iptc.cpp b/src/iptc.cpp
index f64f428..9bb1c21 100644
--- a/src/iptc.cpp
+++ b/src/iptc.cpp
@@ -81,6 +81,21 @@ namespace Exiv2 {
return *this;
} // Iptcdatum::operator=
+ Iptcdatum& Iptcdatum::operator=(const uint16_t& value)
+ {
+ UShortValue::AutoPtr v = UShortValue::AutoPtr(new UShortValue);
+ v->value_.push_back(value);
+ value_ = v;
+ modified_ = true;
+ return *this;
+ }
+
+ Iptcdatum& Iptcdatum::operator=(const std::string& value)
+ {
+ setValue(value);
+ return *this;
+ }
+
void Iptcdatum::setValue(const Value* pValue)
{
modified_ = true;
@@ -90,9 +105,18 @@ namespace Exiv2 {
void Iptcdatum::setValue(const std::string& buf)
{
+ Value::AutoPtr value;
+ try {
+ TypeId type = IptcDataSets::dataSetType(tag(), record());
+ value = Value::create(type);
+ }
+ catch (const Error&) {
+ // Default to a StringValue if the type is unknown or the parse fails
+ value = Value::create(string);
+ }
+ value->read(buf);
+ value_ = value;
modified_ = true;
- if (value_.get() == 0) value_ = Value::create(string);
- value_->read(buf);
}
const byte IptcData::marker_ = 0x1C; // Dataset marker
@@ -107,6 +131,17 @@ namespace Exiv2 {
delete[] pData_;
}
+ Iptcdatum& IptcData::operator[](const std::string& key)
+ {
+ IptcKey iptcKey(key);
+ iterator pos = findKey(iptcKey);
+ if (pos == end()) {
+ add(Iptcdatum(iptcKey));
+ pos = findKey(iptcKey);
+ }
+ return *pos;
+ }
+
int IptcData::read(const std::string& path)
{
if (!fileExists(path, true)) return -1;
diff --git a/src/iptc.hpp b/src/iptc.hpp
index ba8b91d..c9bf527 100644
--- a/src/iptc.hpp
+++ b/src/iptc.hpp
@@ -80,14 +80,26 @@ namespace Exiv2 {
//! Assignment operator
Iptcdatum& operator=(const Iptcdatum& rhs);
/*!
+ @brief Assign \em value to the %Iptcdatum. The type of the new value
+ is determined from %Iptcdatum. If that fails, a StringValue is
+ used. Calls setValue(const std::string&).
+ */
+ Iptcdatum& operator=(const std::string& value);
+ /*!
+ @brief Assign \em value to the %Iptcdatum. The type of the new value
+ is set to UShortValue.
+ */
+ Iptcdatum& operator=(const uint16_t& value);
+ /*!
@brief Set the value. This method copies (clones) the value pointed
to by pValue.
*/
void setValue(const Value* pValue);
/*!
- @brief Set the value to the string buf.
- Uses Value::read(const std::string& buf). If the Iptcdatum does
- not have a value yet, then an StringValue is created.
+ @brief Set the value to the string buf. Uses Value::read(const
+ std::string& buf). If the %Iptcdatum does not have a value yet,
+ then a value of the correct type for this %Iptcdatum is
+ created. If that fails, a StringValue is created.
*/
void setValue(const std::string& buf);
//@}
@@ -343,6 +355,15 @@ namespace Exiv2 {
*/
DataBuf copy();
/*!
+ @brief Returns a reference to the %Iptcdatum that is associated with a
+ particular \em key. If %IptcData does not already contain such
+ an %Iptcdatum, operator[] adds object \em Iptcdatum(key).
+
+ @note Since operator[] might insert a new element, it can't be a const
+ member function.
+ */
+ Iptcdatum& operator[](const std::string& key);
+ /*!
@brief Add an %Iptcdatum from the supplied key and value pair. This
method copies (clones) the value. A check for non-repeatable
datasets is performed.
--
exiv2 packaging
More information about the pkg-kde-commits
mailing list