Skip to content

Commit d5b643c

Browse files
committed
replace pointer with reference
This is never null. Signed-off-by: Rosen Penev <rosenp@gmail.com>
1 parent 5d5503f commit d5b643c

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

src/cr2header_int.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ DataBuf Cr2Header::write() const {
5656
return buf;
5757
} // Cr2Header::write
5858

59-
bool Cr2Header::isImageTag(uint16_t tag, IfdId group, const PrimaryGroups* /*pPrimaryGroups*/) const {
59+
bool Cr2Header::isImageTag(uint16_t tag, IfdId group, const PrimaryGroups& /*pPrimaryGroups*/) const {
6060
// CR2 image tags are all IFD2 and IFD3 tags
6161
if (group == IfdId::ifd2Id || group == IfdId::ifd3Id)
6262
return true;

src/cr2header_int.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Cr2Header : public TiffHeaderBase {
3737
//! @name Accessors
3838
//@{
3939
[[nodiscard]] DataBuf write() const override;
40-
bool isImageTag(uint16_t tag, IfdId group, const PrimaryGroups* pPrimaryGroups) const override;
40+
bool isImageTag(uint16_t tag, IfdId group, const PrimaryGroups& pPrimaryGroups) const override;
4141
//@}
4242

4343
//! Return the address of offset2 from the start of the header

src/tiffimage_int.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2061,7 +2061,7 @@ WriteMethod TiffParserWorker::encode(BasicIo& io, const byte* pData, size_t size
20612061
auto primaryGroups = findPrimaryGroups(parsedTree);
20622062
if (parsedTree) {
20632063
// Attempt to update existing TIFF components based on metadata entries
2064-
TiffEncoder encoder(exifData, iptcData, xmpData, parsedTree.get(), false, &primaryGroups, pHeader, findEncoderFct);
2064+
TiffEncoder encoder(exifData, iptcData, xmpData, parsedTree.get(), false, primaryGroups, pHeader, findEncoderFct);
20652065
parsedTree->accept(encoder);
20662066
if (!encoder.dirty())
20672067
writeMethod = wmNonIntrusive;
@@ -2070,11 +2070,11 @@ WriteMethod TiffParserWorker::encode(BasicIo& io, const byte* pData, size_t size
20702070
auto createdTree = TiffCreator::create(root, IfdId::ifdIdNotSet);
20712071
if (parsedTree) {
20722072
// Copy image tags from the original image to the composite
2073-
TiffCopier copier(createdTree.get(), root, pHeader, &primaryGroups);
2073+
TiffCopier copier(createdTree.get(), root, pHeader, primaryGroups);
20742074
parsedTree->accept(copier);
20752075
}
20762076
// Add entries from metadata to composite
2077-
TiffEncoder encoder(exifData, iptcData, xmpData, createdTree.get(), !parsedTree, &primaryGroups, pHeader,
2077+
TiffEncoder encoder(exifData, iptcData, xmpData, createdTree.get(), !parsedTree, primaryGroups, pHeader,
20782078
findEncoderFct);
20792079
encoder.add(createdTree.get(), parsedTree.get(), root);
20802080
// Write binary representation from the composite tree
@@ -2228,7 +2228,7 @@ uint16_t TiffHeaderBase::tag() const {
22282228
return tag_;
22292229
}
22302230

2231-
bool TiffHeaderBase::isImageTag(uint16_t /*tag*/, IfdId /*group*/, const PrimaryGroups* /*primaryGroups*/) const {
2231+
bool TiffHeaderBase::isImageTag(uint16_t /*tag*/, IfdId /*group*/, const PrimaryGroups& /*primaryGroups*/) const {
22322232
return false;
22332233
}
22342234

@@ -2327,7 +2327,7 @@ TiffHeader::TiffHeader(ByteOrder byteOrder, uint32_t offset, bool hasImageTags)
23272327
TiffHeaderBase(42, 8, byteOrder, offset), hasImageTags_(hasImageTags) {
23282328
}
23292329

2330-
bool TiffHeader::isImageTag(uint16_t tag, IfdId group, const PrimaryGroups* pPrimaryGroups) const {
2330+
bool TiffHeader::isImageTag(uint16_t tag, IfdId group, const PrimaryGroups& pPrimaryGroups) const {
23312331
if (!hasImageTags_) {
23322332
#ifdef EXIV2_DEBUG_MESSAGES
23332333
std::cerr << "No image tags in this image\n";
@@ -2338,16 +2338,16 @@ bool TiffHeader::isImageTag(uint16_t tag, IfdId group, const PrimaryGroups* pPri
23382338
ExifKey key(tag, groupName(group));
23392339
#endif
23402340
// If there are primary groups and none matches group, we're done
2341-
if (pPrimaryGroups && !pPrimaryGroups->empty() &&
2342-
std::find(pPrimaryGroups->begin(), pPrimaryGroups->end(), group) == pPrimaryGroups->end()) {
2341+
if (!pPrimaryGroups.empty() &&
2342+
std::find(pPrimaryGroups.begin(), pPrimaryGroups.end(), group) == pPrimaryGroups.end()) {
23432343
#ifdef EXIV2_DEBUG_MESSAGES
23442344
std::cerr << "Not an image tag: " << key << " (1)\n";
23452345
#endif
23462346
return false;
23472347
}
23482348
// All tags of marked primary groups other than IFD0 are considered
23492349
// image tags. That should take care of NEFs until we know better.
2350-
if (pPrimaryGroups && !pPrimaryGroups->empty() && group != IfdId::ifd0Id) {
2350+
if (!pPrimaryGroups.empty() && group != IfdId::ifd0Id) {
23512351
#ifdef EXIV2_DEBUG_MESSAGES
23522352
ExifKey key(tag, groupName(group));
23532353
std::cerr << "Image tag: " << key << " (2)\n";

src/tiffimage_int.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class TiffHeaderBase {
9494
9595
@return The default implementation returns \c false.
9696
*/
97-
virtual bool isImageTag(uint16_t tag, IfdId group, const PrimaryGroups* pPrimaryGroups) const;
97+
virtual bool isImageTag(uint16_t tag, IfdId group, const PrimaryGroups& pPrimaryGroups) const;
9898
//@}
9999

100100
private:
@@ -120,7 +120,7 @@ class TiffHeader : public TiffHeaderBase {
120120
//@}
121121
//@{
122122
//! @name Accessors
123-
bool isImageTag(uint16_t tag, IfdId group, const PrimaryGroups* pPrimaryGroups) const override;
123+
bool isImageTag(uint16_t tag, IfdId group, const PrimaryGroups& pPrimaryGroups) const override;
124124
//@}
125125

126126
private:

src/tiffvisitor_int.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ void TiffFinder::visitBinaryElement(TiffBinaryElement* object) {
123123
}
124124

125125
TiffCopier::TiffCopier(TiffComponent* pRoot, uint32_t root, const TiffHeaderBase* pHeader,
126-
const PrimaryGroups* pPrimaryGroups) :
126+
const PrimaryGroups& pPrimaryGroups) :
127127
pRoot_(pRoot), root_(root), pHeader_(pHeader), pPrimaryGroups_(pPrimaryGroups) {
128128
}
129129

@@ -440,7 +440,7 @@ void TiffDecoder::visitBinaryElement(TiffBinaryElement* object) {
440440
}
441441

442442
TiffEncoder::TiffEncoder(ExifData& exifData, IptcData& iptcData, XmpData& xmpData, TiffComponent* pRoot,
443-
const bool isNewImage, const PrimaryGroups* pPrimaryGroups, const TiffHeaderBase* pHeader,
443+
const bool isNewImage, const PrimaryGroups& pPrimaryGroups, const TiffHeaderBase* pHeader,
444444
FindEncoderFct findEncoderFct) :
445445
exifData_(exifData),
446446
iptcData_(iptcData),

src/tiffvisitor_int.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ class TiffCopier : public TiffVisitor {
203203
@param pHeader Pointer to the TIFF header of the source image.
204204
@param pPrimaryGroups Pointer to the list of primary groups.
205205
*/
206-
TiffCopier(TiffComponent* pRoot, uint32_t root, const TiffHeaderBase* pHeader, const PrimaryGroups* pPrimaryGroups);
206+
TiffCopier(TiffComponent* pRoot, uint32_t root, const TiffHeaderBase* pHeader, const PrimaryGroups& pPrimaryGroups);
207207
TiffCopier(const TiffCopier&) = delete;
208208
TiffCopier& operator=(const TiffCopier&) = delete;
209209
//! Virtual destructor
@@ -241,7 +241,7 @@ class TiffCopier : public TiffVisitor {
241241
TiffComponent* pRoot_;
242242
uint32_t root_;
243243
const TiffHeaderBase* pHeader_;
244-
const PrimaryGroups* pPrimaryGroups_;
244+
PrimaryGroups pPrimaryGroups_;
245245
}; // class TiffCopier
246246

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

0 commit comments

Comments
 (0)