224
/*boost::python::list Image::getIptcTag(std::string key)
228
boost::python::list valuesList;
229
unsigned int valueOccurences = 0;
230
Exiv2::IptcKey iptcKey = Exiv2::IptcKey(key);
231
for (Exiv2::IptcMetadata::iterator dataIterator = _iptcData.begin();
232
dataIterator != _iptcData.end(); ++dataIterator)
234
if (dataIterator->key() == key)
236
valuesList.append(boost::python::make_tuple(std::string(dataIterator->typeName()), dataIterator->toString()));
240
if (valueOccurences > 0)
243
throw Exiv2::Error(KEY_NOT_FOUND, key);
246
throw Exiv2::Error(METADATA_NOT_READ);
249
boost::python::tuple Image::setIptcTag(std::string key, std::string value, unsigned int index=0)
253
boost::python::tuple returnValue;
224
/*void Image::setIptcTag(std::string key, std::string value, unsigned int index=0)
254
228
unsigned int indexCounter = index;
255
229
Exiv2::IptcKey iptcKey = Exiv2::IptcKey(key);
256
230
Exiv2::IptcMetadata::iterator dataIterator = _iptcData.findKey(iptcKey);
263
237
if (dataIterator != _iptcData.end())
265
239
// The tag at given index already exists, override it
266
returnValue = boost::python::make_tuple(std::string(dataIterator->typeName()), dataIterator->toString());
267
240
dataIterator->setValue(value);
271
244
// Either index is greater than the index of the last repetition
272
245
// of the tag, or the tag does not exist yet.
273
246
// In both cases, it is created.
274
returnValue = boost::python::make_tuple(std::string(""), std::string(""));
275
247
Exiv2::Iptcdatum iptcDatum(iptcKey);
276
248
iptcDatum.setValue(value);
277
249
int state = _iptcData.add(iptcDatum);
279
251
throw Exiv2::Error(NON_REPEATABLE);
284
255
throw Exiv2::Error(METADATA_NOT_READ);
258
void Image::setIptcTagValues(std::string key, boost::python::tuple values)
262
throw Exiv2::Error(METADATA_NOT_READ);
265
Exiv2::IptcKey iptcKey = Exiv2::IptcKey(key);
266
unsigned int index = 0;
267
unsigned int max = len(values);
268
Exiv2::IptcMetadata::iterator dataIterator = _iptcData.findKey(iptcKey);
271
std::string value = boost::python::extract<std::string>(values[index++]);
272
if (dataIterator != _iptcData.end())
274
// Override an existing value
275
dataIterator->setValue(value);
276
dataIterator = std::find_if(++dataIterator, _iptcData.end(),
277
Exiv2::FindMetadatumById::FindMetadatumById(iptcKey.tag(),
282
// Append a new value
283
Exiv2::Iptcdatum iptcDatum(iptcKey);
284
iptcDatum.setValue(value);
285
int state = _iptcData.add(iptcDatum);
288
throw Exiv2::Error(NON_REPEATABLE);
292
// Erase the remaining values if any
293
while (dataIterator != _iptcData.end())
295
_iptcData.erase(dataIterator);
296
dataIterator = std::find_if(dataIterator, _iptcData.end(),
297
Exiv2::FindMetadatumById::FindMetadatumById(iptcKey.tag(),
287
boost::python::tuple Image::deleteIptcTag(std::string key, unsigned int index=0)
302
/*void Image::deleteIptcTag(std::string key, unsigned int index=0)
291
boost::python::tuple returnValue;
292
306
unsigned int indexCounter = index;
293
307
Exiv2::IptcKey iptcKey = Exiv2::IptcKey(key);
294
308
Exiv2::IptcMetadata::iterator dataIterator = _iptcData.findKey(iptcKey);
301
315
if (dataIterator != _iptcData.end())
303
317
// The tag at given index already exists, delete it
304
returnValue = boost::python::make_tuple(std::string(dataIterator->typeName()), dataIterator->toString());
305
318
_iptcData.erase(dataIterator);
309
321
throw Exiv2::Error(KEY_NOT_FOUND, key);