aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Tilloy <olivier@tilloy.net>2009-11-18 09:03:14 +0100
committerOlivier Tilloy <olivier@tilloy.net>2009-11-18 09:03:14 +0100
commit4821ce39d681e73b63ae436485b01d9bbed6ee12 (patch)
treeaa5430f2dd7e4c70044993202ba2ae2190595f11
parent2d31c731eed0c555faab0845f5196a0320a219c5 (diff)
downloadpyexiv2-4821ce39d681e73b63ae436485b01d9bbed6ee12.tar.gz
Implemented IptcTag::setRawValues.
-rw-r--r--src/exiv2wrapper.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/exiv2wrapper.cpp b/src/exiv2wrapper.cpp
index b17e0af..0066cbf 100644
--- a/src/exiv2wrapper.cpp
+++ b/src/exiv2wrapper.cpp
@@ -25,6 +25,8 @@
#include "exiv2wrapper.hpp"
+#include "boost/python/stl_iterator.hpp"
+
// Custom error codes for Exiv2 exceptions
#define METADATA_NOT_READ 101
#define NON_REPEATABLE 102
@@ -540,6 +542,8 @@ IptcTag::IptcTag(const std::string& key, Exiv2::IptcMetadata* data): _key(key)
{
if (data != 0)
{
+ // TODO: check if the tag is repeatable before assigning more than one
+ // datum.
_data = data;
}
else
@@ -570,9 +574,20 @@ IptcTag::IptcTag(const std::string& key, Exiv2::IptcMetadata* data): _key(key)
void IptcTag::setRawValues(const boost::python::list& values)
{
- // TODO!
- //_datum.setValue(value);
- //_value = _datum.toString();
+ _data->clear();
+ _values = boost::python::list();
+ // TODO: check if the tag is repeatable before assigning more than one
+ // datum.
+ boost::python::stl_input_iterator<std::string> iterator(values);
+ for(boost::python::stl_input_iterator<std::string> iterator(values);
+ iterator != boost::python::stl_input_iterator<std::string>();
+ ++iterator)
+ {
+ Exiv2::Iptcdatum datum(_key);
+ datum.setValue(*iterator);
+ _data->push_back(datum);
+ _values.append(datum.toString());
+ }
}
const std::string IptcTag::getKey()