Minor improvements when writing duplicate tags.

This commit is contained in:
Andreas Huggel 2008-11-26 09:34:48 +00:00
parent 442a4c4fc0
commit b657f8a9be
4 changed files with 17 additions and 3 deletions

View File

@ -28,7 +28,9 @@ try {
}
Exiv2::ExifData::const_iterator end = exifData.end();
for (Exiv2::ExifData::const_iterator i = exifData.begin(); i != end; ++i) {
std::cout << std::setw(44) << std::setfill(' ') << std::left
std::cout << std::setw(3) << std::right
<< i->idx() << " "
<< std::setw(44) << std::setfill(' ') << std::left
<< i->key() << " "
<< "0x" << std::setw(4) << std::setfill('0') << std::right
<< std::hex << i->tag() << " "

View File

@ -1402,7 +1402,8 @@ namespace Exiv2 {
{
assert(lhs != 0);
assert(rhs != 0);
return lhs->tag() < rhs->tag();
if (lhs->tag() != rhs->tag()) return lhs->tag() < rhs->tag();
return lhs->idx() < rhs->idx();
}
TiffComponent::AutoPtr newTiffDirectory(uint16_t tag,

View File

@ -245,6 +245,12 @@ namespace Exiv2 {
their implementation of writeImage().
*/
uint32_t sizeImage() const;
/*!
@brief Return the unique id of the entry in the image.
*/
// Todo: This is only implemented in TiffEntryBase. It is needed here so that
// we can sort components by tag and idx. Something is not quite right.
virtual int idx() const { return 0; }
//@}
protected:
@ -426,7 +432,7 @@ namespace Exiv2 {
/*!
@brief Return the unique id of the entry in the image
*/
int idx() const { return idx_; }
virtual int idx() const { return idx_; }
/*!
@brief Return a pointer to the binary representation of the
value of this component.

View File

@ -646,6 +646,11 @@ namespace Exiv2 {
ed = &(*pos);
}
}
else {
// For intrusive writing, the index is used to preserve the order of
// duplicate tags
object->idx_ = ed->idx();
}
if (ed) {
const EncoderFct fct = findEncoderFct_(make_, object->tag(), object->group());
if (fct) {