Change Metadatum::size() return value from long to size_t

main
Luis Diaz 3 years ago committed by Luis Díaz Más
parent 62aad98d0b
commit 137ea080b5

@ -168,7 +168,7 @@ namespace Exiv2 {
//! Return the number of components in the value //! Return the number of components in the value
size_t count() const override; size_t count() const override;
//! Return the size of the value in bytes //! Return the size of the value in bytes
long size() const override; size_t size() const override;
//! Return the value as a string. //! Return the value as a string.
std::string toString() const override; std::string toString() const override;
std::string toString(long n) const override; std::string toString(long n) const override;

@ -120,7 +120,7 @@ namespace Exiv2 {
const char* typeName() const override; const char* typeName() const override;
long typeSize() const override; long typeSize() const override;
size_t count() const override; size_t count() const override;
long size() const override; size_t size() const override;
std::string toString() const override; std::string toString() const override;
std::string toString(long n) const override; std::string toString(long n) const override;
int64_t toInt64(long n = 0) const override; int64_t toInt64(long n = 0) const override;
@ -236,19 +236,17 @@ namespace Exiv2 {
uint16_t record = IptcDataSets::application2) const; uint16_t record = IptcDataSets::application2) const;
//! Return true if there is no IPTC metadata //! Return true if there is no IPTC metadata
bool empty() const { return count() == 0; } bool empty() const { return count() == 0; }
//! Get the number of metadata entries //! Get the number of metadata entries
long count() const { return static_cast<long>(iptcMetadata_.size()); } size_t count() const { return iptcMetadata_.size(); }
/*!
@brief Return the exact size of all contained IPTC metadata //! @brief Return the exact size of all contained IPTC metadata
*/ size_t size() const;
long size() const;
/*! //! @brief Return the metadata charset name or 0
@brief Return the metadata charset name or 0
*/
const char *detectCharset() const; const char *detectCharset() const;
/*!
@brief dump iptc formatted binary data (used by printStructure kpsRecursive) //! @brief dump iptc formatted binary data (used by printStructure kpsRecursive)
*/
static void printStructure(std::ostream& out, const Slice<byte*>& bytes,uint32_t depth); static void printStructure(std::ostream& out, const Slice<byte*>& bytes,uint32_t depth);
//@} //@}

@ -191,7 +191,7 @@ namespace Exiv2 {
//! Return the number of components in the value //! Return the number of components in the value
virtual size_t count() const =0; virtual size_t count() const =0;
//! Return the size of the value in bytes //! Return the size of the value in bytes
virtual long size() const =0; virtual size_t size() const =0;
//! Return the value as a string. //! Return the value as a string.
virtual std::string toString() const =0; virtual std::string toString() const =0;
/*! /*!

@ -115,7 +115,7 @@ namespace Exiv2 {
//! The Exif typeSize doesn't make sense here. Return 0. //! The Exif typeSize doesn't make sense here. Return 0.
long typeSize() const override; long typeSize() const override;
size_t count() const override; size_t count() const override;
long size() const override; size_t size() const override;
std::string toString() const override; std::string toString() const override;
std::string toString(long n) const override; std::string toString(long n) const override;
int64_t toInt64(long n = 0) const override; int64_t toInt64(long n = 0) const override;

@ -1019,12 +1019,14 @@ namespace Exiv2::Internal {
const auto ed2 = image.exifData().findKey(k2); const auto ed2 = image.exifData().findKey(k2);
const auto edEnd = image.exifData().end(); const auto edEnd = image.exifData().end();
long size = 0; size_t size{0};
if (ed1 != edEnd) size += ed1->size(); if (ed1 != edEnd)
if (ed2 != edEnd) size += ed2->size(); size += ed1->size();
if (ed2 != edEnd)
size += ed2->size();
if (size != 0) { if (size != 0) {
DataBuf buf(size); DataBuf buf(size);
long pos = 0; size_t pos{0};
if (ed1 != edEnd) { if (ed1 != edEnd) {
ed1->copy(buf.data(), pHead->byteOrder()); ed1->copy(buf.data(), pHead->byteOrder());
pos += ed1->size(); pos += ed1->size();
@ -1039,7 +1041,7 @@ namespace Exiv2::Internal {
else { else {
pHead->remove(pCrwMapping->crwTagId_, pCrwMapping->crwDir_); pHead->remove(pCrwMapping->crwTagId_, pCrwMapping->crwDir_);
} }
} // CrwMap::encode0x080a }
void CrwMap::encodeArray(const Image& image, void CrwMap::encodeArray(const Image& image,
const CrwMapping* pCrwMapping, const CrwMapping* pCrwMapping,

@ -318,7 +318,7 @@ namespace Exiv2 {
size_t Exifdatum::count() const { return value_ ? value_->count() : 0; } size_t Exifdatum::count() const { return value_ ? value_->count() : 0; }
long Exifdatum::size() const { return value_ ? static_cast<long>(value_->size()) : 0; } size_t Exifdatum::size() const { return value_ ? value_->size() : 0; }
std::string Exifdatum::toString() const { return value_ ? value_->toString() : ""; } std::string Exifdatum::toString() const { return value_ ? value_->toString() : ""; }

@ -114,7 +114,7 @@ namespace Exiv2 {
size_t Iptcdatum::count() const { return value_ ? value_->count() : 0; } size_t Iptcdatum::count() const { return value_ ? value_->count() : 0; }
long Iptcdatum::size() const { return value_ ? static_cast<long>(value_->size()) : 0; } size_t Iptcdatum::size() const { return value_ ? value_->size() : 0; }
std::string Iptcdatum::toString() const { return value_ ? value_->toString() : ""; } std::string Iptcdatum::toString() const { return value_ ? value_->toString() : ""; }
@ -197,13 +197,13 @@ namespace Exiv2 {
return *pos; return *pos;
} }
long IptcData::size() const size_t IptcData::size() const
{ {
long newSize = 0; size_t newSize = 0;
for (auto&& iptc : iptcMetadata_) { for (auto&& iptc : iptcMetadata_) {
// marker, record Id, dataset num, first 2 bytes of size // marker, record Id, dataset num, first 2 bytes of size
newSize += 5; newSize += 5;
long dataSize = iptc.size(); size_t dataSize = iptc.size();
newSize += dataSize; newSize += dataSize;
if (dataSize > 32767) { if (dataSize > 32767) {
// extended dataset (we always use 4 bytes) // extended dataset (we always use 4 bytes)
@ -211,7 +211,7 @@ namespace Exiv2 {
} }
} }
return newSize; return newSize;
} // IptcData::size }
int IptcData::add(const IptcKey& key, Value* value) int IptcData::add(const IptcKey& key, Value* value)
{ {
@ -450,13 +450,13 @@ namespace Exiv2 {
*pWrite++ = static_cast<byte>(iter.tag()); *pWrite++ = static_cast<byte>(iter.tag());
// extended or standard dataset? // extended or standard dataset?
long dataSize = iter.size(); size_t dataSize = iter.size();
if (dataSize > 32767) { if (dataSize > 32767) {
// always use 4 bytes for extended length // always use 4 bytes for extended length
uint16_t sizeOfSize = 4 | 0x8000; uint16_t sizeOfSize = 4 | 0x8000;
us2Data(pWrite, sizeOfSize, bigEndian); us2Data(pWrite, sizeOfSize, bigEndian);
pWrite += 2; pWrite += 2;
ul2Data(pWrite, dataSize, bigEndian); ul2Data(pWrite, static_cast<uint32_t>(dataSize), bigEndian);
pWrite += 4; pWrite += 4;
} }
else { else {

@ -1031,7 +1031,7 @@ namespace Exiv2::Internal {
#ifdef EXIV2_DEBUG_MESSAGES #ifdef EXIV2_DEBUG_MESSAGES
bool tooLarge = false; bool tooLarge = false;
#endif #endif
uint32_t newSize = datum->size(); size_t newSize = datum->size();
if (newSize > object->size_) { // value doesn't fit, encode for intrusive writing if (newSize > object->size_) { // value doesn't fit, encode for intrusive writing
setDirty(); setDirty();
#ifdef EXIV2_DEBUG_MESSAGES #ifdef EXIV2_DEBUG_MESSAGES
@ -1046,14 +1046,14 @@ namespace Exiv2::Internal {
std::cerr << "\t\t\t ALLOCATED " << std::dec << object->size_ << " BYTES"; std::cerr << "\t\t\t ALLOCATED " << std::dec << object->size_ << " BYTES";
} }
#endif #endif
} // TiffEncoder::encodeTiffEntryBase }
void TiffEncoder::encodeOffsetEntry(TiffEntryBase* object, const Exifdatum* datum) void TiffEncoder::encodeOffsetEntry(TiffEntryBase* object, const Exifdatum* datum)
{ {
assert(object); assert(object);
assert(datum); assert(datum);
uint32_t newSize = datum->size(); size_t newSize = datum->size();
if (newSize > object->size_) { // value doesn't fit, encode for intrusive writing if (newSize > object->size_) { // value doesn't fit, encode for intrusive writing
setDirty(); setDirty();
object->updateValue(datum->getValue(), byteOrder()); // clones the value object->updateValue(datum->getValue(), byteOrder()); // clones the value
@ -1071,8 +1071,7 @@ namespace Exiv2::Internal {
std::cerr << "\t\t\t PRESERVE VALUE DATA"; std::cerr << "\t\t\t PRESERVE VALUE DATA";
#endif #endif
} }
}
} // TiffEncoder::encodeOffsetEntry
void TiffEncoder::add( void TiffEncoder::add(
TiffComponent* pRootDir, TiffComponent* pRootDir,

@ -352,7 +352,7 @@ namespace Exiv2 {
size_t Xmpdatum::count() const { return p_->value_ ? p_->value_->count() : 0; } size_t Xmpdatum::count() const { return p_->value_ ? p_->value_->count() : 0; }
long Xmpdatum::size() const { return p_->value_ ? static_cast<long>(p_->value_->size()) : 0; } size_t Xmpdatum::size() const { return p_->value_ ? p_->value_->size() : 0; }
std::string Xmpdatum::toString() const { return p_->value_ ? p_->value_->toString() : ""; } std::string Xmpdatum::toString() const { return p_->value_ ? p_->value_->toString() : ""; }

Loading…
Cancel
Save