diff options
author | Olivier Tilloy <olivier@tilloy.net> | 2010-05-20 13:40:00 +0200 |
---|---|---|
committer | Olivier Tilloy <olivier@tilloy.net> | 2010-05-20 13:40:00 +0200 |
commit | bb33f2b87aea2038f18b8484d3895e2757f0d72f (patch) | |
tree | 6b1c07e527b1c3ef51ef677f56ce174389ff2195 /src/exiv2wrapper.cpp | |
parent | 345251460bfd25e68eed67435eb035a46efa8006 (diff) | |
download | pyexiv2-bb33f2b87aea2038f18b8484d3895e2757f0d72f.tar.gz |
Attach the image's XmpData to a tag when it is assigned to an image.
Remove redundant code that would set the value of a tag twice (in the tag itself, and in the image).
Remove the now useless metadata attribute.
Diffstat (limited to 'src/exiv2wrapper.cpp')
-rw-r--r-- | src/exiv2wrapper.cpp | 77 |
1 files changed, 36 insertions, 41 deletions
diff --git a/src/exiv2wrapper.cpp b/src/exiv2wrapper.cpp index 83a5712..d8ee8e5 100644 --- a/src/exiv2wrapper.cpp +++ b/src/exiv2wrapper.cpp @@ -329,47 +329,6 @@ const XmpTag Image::getXmpTag(std::string key) return XmpTag(key, &_xmpData[key]); } -void Image::setXmpTagTextValue(const std::string& key, const std::string& value) -{ - CHECK_METADATA_READ - - _xmpData[key].setValue(value); -} - -void Image::setXmpTagArrayValue(const std::string& key, const boost::python::list& values) -{ - CHECK_METADATA_READ - - Exiv2::Xmpdatum& datum = _xmpData[key]; - // Reset the value - datum.setValue(0); - - for(boost::python::stl_input_iterator<std::string> iterator(values); - iterator != boost::python::stl_input_iterator<std::string>(); - ++iterator) - { - datum.setValue(*iterator); - } -} - -void Image::setXmpTagLangAltValue(const std::string& key, const boost::python::dict& values) -{ - CHECK_METADATA_READ - - Exiv2::Xmpdatum& datum = _xmpData[key]; - // Reset the value - datum.setValue(0); - - for(boost::python::stl_input_iterator<std::string> iterator(values); - iterator != boost::python::stl_input_iterator<std::string>(); - ++iterator) - { - std::string key = *iterator; - std::string value = boost::python::extract<std::string>(values.get(key)); - datum.setValue("lang=\"" + key + "\" " + value); - } -} - void Image::deleteXmpTag(std::string key) { CHECK_METADATA_READ @@ -814,6 +773,42 @@ void XmpTag::setLangAltValue(const boost::python::dict& values) } } +void XmpTag::setParentImage(Image& image) +{ + switch (Exiv2::XmpProperties::propertyType(_key)) + { + case Exiv2::xmpText: + { + const std::string value = getTextValue(); + delete _datum; + _from_datum = true; + _datum = &(*image.getXmpData())[_key.key()]; + setTextValue(value); + break; + } + case Exiv2::xmpAlt: + case Exiv2::xmpBag: + case Exiv2::xmpSeq: + { + const boost::python::list value = getArrayValue(); + delete _datum; + _from_datum = true; + _datum = &(*image.getXmpData())[_key.key()]; + setArrayValue(value); + break; + } + case Exiv2::langAlt: + { + const boost::python::dict value = getLangAltValue(); + delete _datum; + _from_datum = true; + _datum = &(*image.getXmpData())[_key.key()]; + setLangAltValue(value); + break; + } + } +} + const std::string XmpTag::getKey() { return _key.key(); |