aboutsummaryrefslogtreecommitdiffstats
path: root/src/libpyexiv2.cpp
diff options
context:
space:
mode:
authorOlivier Tilloy <olivier@tilloy.net>2007-03-13 22:22:31 +0100
committerOlivier Tilloy <olivier@tilloy.net>2007-03-13 22:22:31 +0100
commitb97d510a9dd3f7d220d8543a9087c554bf96d6ee (patch)
treeb4b92c8e9a8bc87020e68c8f5b05446d40ef4060 /src/libpyexiv2.cpp
parent1b48deeb7952c27e8dba6c5b3c702efc5e582a65 (diff)
downloadpyexiv2-b97d510a9dd3f7d220d8543a9087c554bf96d6ee.tar.gz
Modified method Image::deleteIptcTag(...) to take into account the possibility for an IPTC tag to be repeatable.
Diffstat (limited to 'src/libpyexiv2.cpp')
-rw-r--r--src/libpyexiv2.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/libpyexiv2.cpp b/src/libpyexiv2.cpp
index 9ce4a9d..22c4063 100644
--- a/src/libpyexiv2.cpp
+++ b/src/libpyexiv2.cpp
@@ -281,18 +281,25 @@ namespace LibPyExiv2
throw Exiv2::Error(METADATA_NOT_READ);
}
- boost::python::tuple Image::deleteIptcTag(std::string key)
+ boost::python::tuple Image::deleteIptcTag(std::string key, unsigned int index=0)
{
- boost::python::tuple returnValue;
if(_dataRead)
{
+ boost::python::tuple returnValue;
+ unsigned int indexCounter = index;
Exiv2::IptcKey iptcKey = Exiv2::IptcKey(key);
- Exiv2::IptcMetadata::iterator i = _iptcData.findKey(iptcKey);
- if(i != _iptcData.end())
+ Exiv2::IptcMetadata::iterator dataIterator = _iptcData.findKey(iptcKey);
+ while ((indexCounter > 0) && (dataIterator != _iptcData.end()))
{
- Exiv2::Iptcdatum iptcDatum = _iptcData[key];
- returnValue = boost::python::make_tuple(iptcDatum.typeName(), iptcDatum.toString());
- _iptcData.erase(i);
+ dataIterator = std::find_if(++dataIterator, _iptcData.end(),
+ Exiv2::FindMetadatumById::FindMetadatumById(iptcKey.tag(), iptcKey.record()));
+ --indexCounter;
+ }
+ if (dataIterator != _iptcData.end())
+ {
+ // The tag at given index already exists, delete it
+ returnValue = boost::python::make_tuple(dataIterator->typeName(), dataIterator->toString());
+ _iptcData.erase(dataIterator);
return returnValue;
}
else