From 4821ce39d681e73b63ae436485b01d9bbed6ee12 Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Wed, 18 Nov 2009 09:03:14 +0100 Subject: Implemented IptcTag::setRawValues. --- src/exiv2wrapper.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/exiv2wrapper.cpp') 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 iterator(values); + for(boost::python::stl_input_iterator iterator(values); + iterator != boost::python::stl_input_iterator(); + ++iterator) + { + Exiv2::Iptcdatum datum(_key); + datum.setValue(*iterator); + _data->push_back(datum); + _values.append(datum.toString()); + } } const std::string IptcTag::getKey() -- cgit