diff options
author | Olivier Tilloy <olivier@tilloy.net> | 2009-11-18 10:07:49 +0100 |
---|---|---|
committer | Olivier Tilloy <olivier@tilloy.net> | 2009-11-18 10:07:49 +0100 |
commit | 88d489884b279979c6d18c47d795befb3af0b6ce (patch) | |
tree | e481740eb614c04cb88e5b294c7e24ab0afc075c /src/exiv2wrapper.cpp | |
parent | f1eb2a7397224fd3049a492297f5a008d5317fdd (diff) | |
download | pyexiv2-88d489884b279979c6d18c47d795befb3af0b6ce.tar.gz |
Throw an exception when trying to set multiple values on non repeatable IPTC tags.
Diffstat (limited to 'src/exiv2wrapper.cpp')
-rw-r--r-- | src/exiv2wrapper.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/exiv2wrapper.cpp b/src/exiv2wrapper.cpp index a24255c..92ab028 100644 --- a/src/exiv2wrapper.cpp +++ b/src/exiv2wrapper.cpp @@ -533,8 +533,6 @@ 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 @@ -555,13 +553,25 @@ IptcTag::IptcTag(const std::string& key, Exiv2::IptcMetadata* data): _key(key) _repeatable = Exiv2::IptcDataSets::dataSetRepeatable(tag, record); _recordName = Exiv2::IptcDataSets::recordName(record); _recordDescription = Exiv2::IptcDataSets::recordDesc(record); + + if (!_repeatable && (_data->size() > 1)) + { + // The tag is not repeatable but we are trying to assign it more than + // one value. + throw Exiv2::Error(NON_REPEATABLE); + } } void IptcTag::setRawValues(const boost::python::list& values) { + if (!_repeatable && (boost::python::len(values) > 1)) + { + // The tag is not repeatable but we are trying to assign it more than + // one value. + throw Exiv2::Error(NON_REPEATABLE); + } + _data->clear(); - // TODO: check if the tag is repeatable before assigning more than one - // datum. for(boost::python::stl_input_iterator<std::string> iterator(values); iterator != boost::python::stl_input_iterator<std::string>(); ++iterator) |