Revision to PR#557. Restored XmpData::erase() and added XmpData::eraseFamily(). Restored and augumented conversions.sh

v0.27.3
Robin Mills 7 years ago committed by Luis Díaz Más
parent ccd708df24
commit 1b136f0657

@ -208,10 +208,21 @@ namespace Exiv2 {
@return 0 if successful. @return 0 if successful.
*/ */
int add(const Xmpdatum& xmpdatum); int add(const Xmpdatum& xmpdatum);
/*
@brief Delete the Xmpdatum at iterator position pos, return the
position of the next Xmpdatum.
@note Iterators into the metadata, including pos, are potentially
invalidated by this call.
@brief Delete the Xmpdatum at iterator position pos and update pos
*/
iterator erase(XmpData::iterator pos);
/*! /*!
@brief Delete the Xmpdatum at iterator position pos and update pos @brief Delete the Xmpdatum at iterator position pos and update pos
eraseFamily erases data from the same family
See: https://github.com/Exiv2/exiv2/issues/521
*/ */
void erase(iterator& pos); void eraseFamily(iterator &pos);
//! Delete all Xmpdatum instances resulting in an empty container. //! Delete all Xmpdatum instances resulting in an empty container.
void clear(); void clear();
//! Sort metadata by key //! Sort metadata by key

@ -1616,7 +1616,7 @@ namespace Action {
Exiv2::XmpData::iterator pos; Exiv2::XmpData::iterator pos;
Exiv2::XmpKey xmpKey = Exiv2::XmpKey(modifyCmd.key_); Exiv2::XmpKey xmpKey = Exiv2::XmpKey(modifyCmd.key_);
while((pos = xmpData.findKey(xmpKey)) != xmpData.end()) { while((pos = xmpData.findKey(xmpKey)) != xmpData.end()) {
xmpData.erase(pos); xmpData.eraseFamily(pos);
} }
} }
} }

@ -382,14 +382,18 @@ namespace Exiv2 {
return xmpMetadata_.end(); return xmpMetadata_.end();
} }
void XmpData::erase(XmpData::iterator& pos) XmpData::iterator XmpData::erase(XmpData::iterator pos) {
return xmpMetadata_.erase(pos);
}
void XmpData::eraseFamily(XmpData::iterator &pos)
{ {
// https://github.com/Exiv2/exiv2/issues/521 // https://github.com/Exiv2/exiv2/issues/521
// delete 'children' of XMP composites (XmpSeq and XmpBag) // delete 'children' of XMP composites (XmpSeq and XmpBag)
std::string key = pos->key(); std::string key = pos->key();
while ( pos != end() ) { while ( pos != end() ) {
if ( pos->key().find(key)==0 ) { if ( pos->key().find(key)==0 ) {
xmpMetadata_.erase(pos); erase(pos);
} else { } else {
break ; break ;
} }

@ -206,6 +206,15 @@ fi
runTest exiv2 -PEkycv v.jpg runTest exiv2 -PEkycv v.jpg
runTest exiv2 -pi v.jpg runTest exiv2 -pi v.jpg
# 16) https://github.com/Exiv2/exiv2/issues/521
echo
echo Testcase 16
echo ===========
copyTestFile DSC_3079.jpg
runTest exiv2 -px DSC_3079.jpg
runTest exiv2 -M"del Xmp.mwg-rs.Regions" DSC_3079.jpg
runTest exiv2 -px DSC_3079.jpg
) > $results 2>&1 ) > $results 2>&1
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

@ -149,18 +149,18 @@ Iptc.Envelope.CharacterSet String 3 %G
Testcase 15 Testcase 15
=========== ===========
Xmp.xmp.ModifyDate XmpText 20 2015-04-17T18:10:22Z
Xmp.exif.ExifVersion XmpText 4 2.21 Xmp.exif.ExifVersion XmpText 4 2.21
Xmp.exif.GPSVersionID XmpText 7 2.2.0.1 Xmp.exif.GPSVersionID XmpText 7 2.2.0.1
Xmp.exif.GPSLatitude XmpText 12 3,8.4955752N Xmp.exif.GPSLatitude XmpText 12 3,8.4955752N
Xmp.exif.GPSTimeStamp XmpText 29 2003-12-14T01:02:00.999999999 Xmp.exif.GPSTimeStamp XmpText 29 2003-12-14T01:02:00.999999999
Xmp.exif.ComponentsConfiguration XmpSeq 4 YCbCr
Xmp.exif.Flash XmpText 0 type="Struct" Xmp.exif.Flash XmpText 0 type="Struct"
Xmp.exif.Flash/exif:Fired XmpText 4 True Xmp.exif.Flash/exif:Fired XmpText 4 True
Xmp.exif.Flash/exif:Return XmpText 1 0 Xmp.exif.Flash/exif:Return XmpText 1 0
Xmp.exif.Flash/exif:Mode XmpText 1 1 Xmp.exif.Flash/exif:Mode XmpText 1 1
Xmp.exif.Flash/exif:Function XmpText 5 False Xmp.exif.Flash/exif:Function XmpText 5 False
Xmp.exif.Flash/exif:RedEyeMode XmpText 4 True Xmp.exif.Flash/exif:RedEyeMode XmpText 4 True
Xmp.exif.ComponentsConfiguration XmpSeq 4 YCbCr
Xmp.xmp.ModifyDate XmpText 20 2015-04-17T18:10:22Z
Xmp.photoshop.DateCreated XmpText 29 2003-12-14T12:01:44.999999999 Xmp.photoshop.DateCreated XmpText 29 2003-12-14T12:01:44.999999999
Exif.Image.DateTime Ascii 20 2015:04:18 02:10:22 Exif.Image.DateTime Ascii 20 2015:04:18 02:10:22
Exif.Image.ExifTag Long 1 70 Exif.Image.ExifTag Long 1 70
@ -177,3 +177,27 @@ Exif.GPSInfo.GPSTimeStamp Rational 3 1/1 2/1 999999999/10
Exif.GPSInfo.GPSDateStamp Ascii 11 2003:12:14 Exif.GPSInfo.GPSDateStamp Ascii 11 2003:12:14
Iptc.Envelope.CharacterSet String 3 %G Iptc.Envelope.CharacterSet String 3 %G
Iptc.Application2.DateCreated Date 8 2003-12-14 Iptc.Application2.DateCreated Date 8 2003-12-14
Testcase 16
===========
Xmp.MY.DateConfidence XmpText 4 Full
Xmp.exifEX.PhotographicSensitivity XmpText 2 64
Xmp.mwg-rs.Regions XmpText 0 type="Struct"
Xmp.mwg-rs.Regions/mwg-rs:AppliedToDimensions XmpText 0 type="Struct"
Xmp.mwg-rs.Regions/mwg-rs:AppliedToDimensions/stDim:w XmpText 3 540
Xmp.mwg-rs.Regions/mwg-rs:AppliedToDimensions/stDim:h XmpText 3 960
Xmp.mwg-rs.Regions/mwg-rs:AppliedToDimensions/stDim:unit XmpText 5 pixel
Xmp.mwg-rs.Regions/mwg-rs:RegionList XmpText 0 type="Seq"
Xmp.mwg-rs.Regions/mwg-rs:RegionList[1] XmpText 0 type="Struct"
Xmp.mwg-rs.Regions/mwg-rs:RegionList[1]/mwg-rs:Type XmpText 4 Face
Xmp.mwg-rs.Regions/mwg-rs:RegionList[1]/mwg-rs:Name XmpText 7 America
Xmp.mwg-rs.Regions/mwg-rs:RegionList[1]/mwg-rs:Area XmpText 0 type="Struct"
Xmp.mwg-rs.Regions/mwg-rs:RegionList[1]/mwg-rs:Area/stArea:x XmpText 8 0.825794
Xmp.mwg-rs.Regions/mwg-rs:RegionList[1]/mwg-rs:Area/stArea:y XmpText 8 0.379665
Xmp.mwg-rs.Regions/mwg-rs:RegionList[1]/mwg-rs:Area/stArea:w XmpText 8 0.110064
Xmp.mwg-rs.Regions/mwg-rs:RegionList[1]/mwg-rs:Area/stArea:h XmpText 8 0.077389
Xmp.mwg-rs.Regions/mwg-rs:RegionList[1]/mwg-rs:Area/stArea:unit XmpText 10 normalized
Xmp.dc.subject XmpBag 1 America
Xmp.MY.DateConfidence XmpText 4 Full
Xmp.exifEX.PhotographicSensitivity XmpText 2 64
Xmp.dc.subject XmpBag 1 America

Loading…
Cancel
Save