Skip to content

Commit

Permalink
replace pointer with reference
Browse files Browse the repository at this point in the history
This is never null.

Signed-off-by: Rosen Penev <[email protected]>
  • Loading branch information
neheb committed Feb 10, 2025
1 parent 5d5503f commit d5b643c
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/cr2header_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ DataBuf Cr2Header::write() const {
return buf;
} // Cr2Header::write

bool Cr2Header::isImageTag(uint16_t tag, IfdId group, const PrimaryGroups* /*pPrimaryGroups*/) const {
bool Cr2Header::isImageTag(uint16_t tag, IfdId group, const PrimaryGroups& /*pPrimaryGroups*/) const {
// CR2 image tags are all IFD2 and IFD3 tags
if (group == IfdId::ifd2Id || group == IfdId::ifd3Id)
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/cr2header_int.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Cr2Header : public TiffHeaderBase {
//! @name Accessors
//@{
[[nodiscard]] DataBuf write() const override;
bool isImageTag(uint16_t tag, IfdId group, const PrimaryGroups* pPrimaryGroups) const override;
bool isImageTag(uint16_t tag, IfdId group, const PrimaryGroups& pPrimaryGroups) const override;
//@}

//! Return the address of offset2 from the start of the header
Expand Down
16 changes: 8 additions & 8 deletions src/tiffimage_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2061,7 +2061,7 @@ WriteMethod TiffParserWorker::encode(BasicIo& io, const byte* pData, size_t size
auto primaryGroups = findPrimaryGroups(parsedTree);
if (parsedTree) {
// Attempt to update existing TIFF components based on metadata entries
TiffEncoder encoder(exifData, iptcData, xmpData, parsedTree.get(), false, &primaryGroups, pHeader, findEncoderFct);
TiffEncoder encoder(exifData, iptcData, xmpData, parsedTree.get(), false, primaryGroups, pHeader, findEncoderFct);
parsedTree->accept(encoder);
if (!encoder.dirty())
writeMethod = wmNonIntrusive;
Expand All @@ -2070,11 +2070,11 @@ WriteMethod TiffParserWorker::encode(BasicIo& io, const byte* pData, size_t size
auto createdTree = TiffCreator::create(root, IfdId::ifdIdNotSet);
if (parsedTree) {
// Copy image tags from the original image to the composite
TiffCopier copier(createdTree.get(), root, pHeader, &primaryGroups);
TiffCopier copier(createdTree.get(), root, pHeader, primaryGroups);
parsedTree->accept(copier);
}
// Add entries from metadata to composite
TiffEncoder encoder(exifData, iptcData, xmpData, createdTree.get(), !parsedTree, &primaryGroups, pHeader,
TiffEncoder encoder(exifData, iptcData, xmpData, createdTree.get(), !parsedTree, primaryGroups, pHeader,
findEncoderFct);
encoder.add(createdTree.get(), parsedTree.get(), root);
// Write binary representation from the composite tree
Expand Down Expand Up @@ -2228,7 +2228,7 @@ uint16_t TiffHeaderBase::tag() const {
return tag_;
}

bool TiffHeaderBase::isImageTag(uint16_t /*tag*/, IfdId /*group*/, const PrimaryGroups* /*primaryGroups*/) const {
bool TiffHeaderBase::isImageTag(uint16_t /*tag*/, IfdId /*group*/, const PrimaryGroups& /*primaryGroups*/) const {
return false;
}

Expand Down Expand Up @@ -2327,7 +2327,7 @@ TiffHeader::TiffHeader(ByteOrder byteOrder, uint32_t offset, bool hasImageTags)
TiffHeaderBase(42, 8, byteOrder, offset), hasImageTags_(hasImageTags) {
}

bool TiffHeader::isImageTag(uint16_t tag, IfdId group, const PrimaryGroups* pPrimaryGroups) const {
bool TiffHeader::isImageTag(uint16_t tag, IfdId group, const PrimaryGroups& pPrimaryGroups) const {
if (!hasImageTags_) {
#ifdef EXIV2_DEBUG_MESSAGES
std::cerr << "No image tags in this image\n";
Expand All @@ -2338,16 +2338,16 @@ bool TiffHeader::isImageTag(uint16_t tag, IfdId group, const PrimaryGroups* pPri
ExifKey key(tag, groupName(group));
#endif
// If there are primary groups and none matches group, we're done
if (pPrimaryGroups && !pPrimaryGroups->empty() &&
std::find(pPrimaryGroups->begin(), pPrimaryGroups->end(), group) == pPrimaryGroups->end()) {
if (!pPrimaryGroups.empty() &&
std::find(pPrimaryGroups.begin(), pPrimaryGroups.end(), group) == pPrimaryGroups.end()) {
#ifdef EXIV2_DEBUG_MESSAGES
std::cerr << "Not an image tag: " << key << " (1)\n";
#endif
return false;
}
// All tags of marked primary groups other than IFD0 are considered
// image tags. That should take care of NEFs until we know better.
if (pPrimaryGroups && !pPrimaryGroups->empty() && group != IfdId::ifd0Id) {
if (!pPrimaryGroups.empty() && group != IfdId::ifd0Id) {
#ifdef EXIV2_DEBUG_MESSAGES
ExifKey key(tag, groupName(group));
std::cerr << "Image tag: " << key << " (2)\n";
Expand Down
4 changes: 2 additions & 2 deletions src/tiffimage_int.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class TiffHeaderBase {
@return The default implementation returns \c false.
*/
virtual bool isImageTag(uint16_t tag, IfdId group, const PrimaryGroups* pPrimaryGroups) const;
virtual bool isImageTag(uint16_t tag, IfdId group, const PrimaryGroups& pPrimaryGroups) const;
//@}

private:
Expand All @@ -120,7 +120,7 @@ class TiffHeader : public TiffHeaderBase {
//@}
//@{
//! @name Accessors
bool isImageTag(uint16_t tag, IfdId group, const PrimaryGroups* pPrimaryGroups) const override;
bool isImageTag(uint16_t tag, IfdId group, const PrimaryGroups& pPrimaryGroups) const override;
//@}

private:
Expand Down
4 changes: 2 additions & 2 deletions src/tiffvisitor_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void TiffFinder::visitBinaryElement(TiffBinaryElement* object) {
}

TiffCopier::TiffCopier(TiffComponent* pRoot, uint32_t root, const TiffHeaderBase* pHeader,
const PrimaryGroups* pPrimaryGroups) :
const PrimaryGroups& pPrimaryGroups) :
pRoot_(pRoot), root_(root), pHeader_(pHeader), pPrimaryGroups_(pPrimaryGroups) {
}

Expand Down Expand Up @@ -440,7 +440,7 @@ void TiffDecoder::visitBinaryElement(TiffBinaryElement* object) {
}

TiffEncoder::TiffEncoder(ExifData& exifData, IptcData& iptcData, XmpData& xmpData, TiffComponent* pRoot,
const bool isNewImage, const PrimaryGroups* pPrimaryGroups, const TiffHeaderBase* pHeader,
const bool isNewImage, const PrimaryGroups& pPrimaryGroups, const TiffHeaderBase* pHeader,
FindEncoderFct findEncoderFct) :
exifData_(exifData),
iptcData_(iptcData),
Expand Down
8 changes: 4 additions & 4 deletions src/tiffvisitor_int.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class TiffCopier : public TiffVisitor {
@param pHeader Pointer to the TIFF header of the source image.
@param pPrimaryGroups Pointer to the list of primary groups.
*/
TiffCopier(TiffComponent* pRoot, uint32_t root, const TiffHeaderBase* pHeader, const PrimaryGroups* pPrimaryGroups);
TiffCopier(TiffComponent* pRoot, uint32_t root, const TiffHeaderBase* pHeader, const PrimaryGroups& pPrimaryGroups);
TiffCopier(const TiffCopier&) = delete;
TiffCopier& operator=(const TiffCopier&) = delete;
//! Virtual destructor
Expand Down Expand Up @@ -241,7 +241,7 @@ class TiffCopier : public TiffVisitor {
TiffComponent* pRoot_;
uint32_t root_;
const TiffHeaderBase* pHeader_;
const PrimaryGroups* pPrimaryGroups_;
PrimaryGroups pPrimaryGroups_;
}; // class TiffCopier

/*!
Expand Down Expand Up @@ -352,7 +352,7 @@ class TiffEncoder : public TiffVisitor {
find special encoders.
*/
TiffEncoder(ExifData& exifData, IptcData& iptcData, XmpData& xmpData, TiffComponent* pRoot, bool isNewImage,
const PrimaryGroups* pPrimaryGroups, const TiffHeaderBase* pHeader, FindEncoderFct findEncoderFct);
const PrimaryGroups& pPrimaryGroups, const TiffHeaderBase* pHeader, FindEncoderFct findEncoderFct);
TiffEncoder(const TiffEncoder&) = delete;
TiffEncoder& operator=(const TiffEncoder&) = delete;
//! Virtual destructor
Expand Down Expand Up @@ -517,7 +517,7 @@ class TiffEncoder : public TiffVisitor {
const TiffHeaderBase* pHeader_; //!< TIFF image header
TiffComponent* pRoot_; //!< Root element of the composite
bool isNewImage_; //!< True if the TIFF image is created from scratch
const PrimaryGroups* pPrimaryGroups_; //!< List of primary image groups
PrimaryGroups pPrimaryGroups_; //!< List of primary image groups
TiffComponent* pSourceTree_{nullptr}; //!< Parsed source tree for reference
ByteOrder byteOrder_; //!< Byteorder for encoding
ByteOrder origByteOrder_; //!< Byteorder as set in the c'tor
Expand Down

0 comments on commit d5b643c

Please sign in to comment.