clang-tidy: don't use non const refs
Found with: google-runtime-references Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
parent
01aab49f6f
commit
d29001f2a4
@ -2004,9 +2004,10 @@ TiffComponent::UniquePtr TiffCreator::create(uint32_t extendedTag, IfdId group)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
} // TiffCreator::create
|
} // TiffCreator::create
|
||||||
|
|
||||||
void TiffCreator::getPath(TiffPath& tiffPath, uint32_t extendedTag, IfdId group, uint32_t root) {
|
TiffPath TiffCreator::getPath(uint32_t extendedTag, IfdId group, uint32_t root) {
|
||||||
|
TiffPath ret;
|
||||||
while (true) {
|
while (true) {
|
||||||
tiffPath.emplace(extendedTag, group);
|
ret.emplace(extendedTag, group);
|
||||||
const auto ts = tiffTreeTable_.find(TiffGroupKey(root, group));
|
const auto ts = tiffTreeTable_.find(TiffGroupKey(root, group));
|
||||||
assert(ts != tiffTreeTable_.end());
|
assert(ts != tiffTreeTable_.end());
|
||||||
extendedTag = ts->second.second;
|
extendedTag = ts->second.second;
|
||||||
@ -2015,6 +2016,7 @@ void TiffCreator::getPath(TiffPath& tiffPath, uint32_t extendedTag, IfdId group,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteOrder TiffParserWorker::decode(ExifData& exifData, IptcData& iptcData, XmpData& xmpData, const byte* pData,
|
ByteOrder TiffParserWorker::decode(ExifData& exifData, IptcData& iptcData, XmpData& xmpData, const byte* pData,
|
||||||
@ -2047,8 +2049,7 @@ WriteMethod TiffParserWorker::encode(BasicIo& io, const byte* pData, size_t size
|
|||||||
*/
|
*/
|
||||||
WriteMethod writeMethod = wmIntrusive;
|
WriteMethod writeMethod = wmIntrusive;
|
||||||
auto parsedTree = parse(pData, size, root, pHeader);
|
auto parsedTree = parse(pData, size, root, pHeader);
|
||||||
PrimaryGroups primaryGroups;
|
auto primaryGroups = findPrimaryGroups(parsedTree.get());
|
||||||
findPrimaryGroups(primaryGroups, parsedTree.get());
|
|
||||||
if (parsedTree) {
|
if (parsedTree) {
|
||||||
// Attempt to update existing TIFF components based on metadata entries
|
// 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);
|
||||||
@ -2107,9 +2108,10 @@ TiffComponent::UniquePtr TiffParserWorker::parse(const byte* pData, size_t size,
|
|||||||
|
|
||||||
} // TiffParserWorker::parse
|
} // TiffParserWorker::parse
|
||||||
|
|
||||||
void TiffParserWorker::findPrimaryGroups(PrimaryGroups& primaryGroups, TiffComponent* pSourceDir) {
|
PrimaryGroups TiffParserWorker::findPrimaryGroups(TiffComponent* pSourceDir) {
|
||||||
|
PrimaryGroups ret;
|
||||||
if (!pSourceDir)
|
if (!pSourceDir)
|
||||||
return;
|
return ret;
|
||||||
|
|
||||||
static constexpr auto imageGroups = std::array{
|
static constexpr auto imageGroups = std::array{
|
||||||
IfdId::ifd0Id, IfdId::ifd1Id, IfdId::ifd2Id, IfdId::ifd3Id, IfdId::subImage1Id,
|
IfdId::ifd0Id, IfdId::ifd1Id, IfdId::ifd2Id, IfdId::ifd3Id, IfdId::subImage1Id,
|
||||||
@ -2123,10 +2125,10 @@ void TiffParserWorker::findPrimaryGroups(PrimaryGroups& primaryGroups, TiffCompo
|
|||||||
auto te = dynamic_cast<TiffEntryBase*>(finder.result());
|
auto te = dynamic_cast<TiffEntryBase*>(finder.result());
|
||||||
const Value* pV = te ? te->pValue() : nullptr;
|
const Value* pV = te ? te->pValue() : nullptr;
|
||||||
if (pV && pV->typeId() == unsignedLong && pV->count() == 1 && (pV->toInt64() & 1) == 0) {
|
if (pV && pV->typeId() == unsignedLong && pV->count() == 1 && (pV->toInt64() & 1) == 0) {
|
||||||
primaryGroups.push_back(te->group());
|
ret.push_back(te->group());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return ret;
|
||||||
} // TiffParserWorker::findPrimaryGroups
|
} // TiffParserWorker::findPrimaryGroups
|
||||||
|
|
||||||
TiffHeaderBase::TiffHeaderBase(uint16_t tag, uint32_t size, ByteOrder byteOrder, uint32_t offset) :
|
TiffHeaderBase::TiffHeaderBase(uint16_t tag, uint32_t size, ByteOrder byteOrder, uint32_t offset) :
|
||||||
|
|||||||
@ -170,7 +170,7 @@ class TiffCreator {
|
|||||||
the \em root TIFF element to the TIFF entry \em extendedTag and
|
the \em root TIFF element to the TIFF entry \em extendedTag and
|
||||||
\em group.
|
\em group.
|
||||||
*/
|
*/
|
||||||
static void getPath(TiffPath& tiffPath, uint32_t extendedTag, IfdId group, uint32_t root);
|
static TiffPath getPath(uint32_t extendedTag, IfdId group, uint32_t root);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const TiffTreeTable tiffTreeTable_; //<! TIFF tree structure
|
static const TiffTreeTable tiffTreeTable_; //<! TIFF tree structure
|
||||||
@ -244,7 +244,7 @@ class TiffParserWorker {
|
|||||||
@param primaryGroups List of primary groups which is populated
|
@param primaryGroups List of primary groups which is populated
|
||||||
@param pSourceDir Pointer to the source composite tree to search (may be 0)
|
@param pSourceDir Pointer to the source composite tree to search (may be 0)
|
||||||
*/
|
*/
|
||||||
static void findPrimaryGroups(PrimaryGroups& primaryGroups, TiffComponent* pSourceDir);
|
static PrimaryGroups findPrimaryGroups(TiffComponent* pSourceDir);
|
||||||
|
|
||||||
}; // class TiffParserWorker
|
}; // class TiffParserWorker
|
||||||
|
|
||||||
|
|||||||
@ -134,8 +134,7 @@ void TiffCopier::copyObject(const TiffComponent* object) {
|
|||||||
if (pHeader_->isImageTag(object->tag(), object->group(), pPrimaryGroups_)) {
|
if (pHeader_->isImageTag(object->tag(), object->group(), pPrimaryGroups_)) {
|
||||||
auto clone = object->clone();
|
auto clone = object->clone();
|
||||||
// Assumption is that the corresponding TIFF entry doesn't exist
|
// Assumption is that the corresponding TIFF entry doesn't exist
|
||||||
TiffPath tiffPath;
|
auto tiffPath = TiffCreator::getPath(object->tag(), object->group(), root_);
|
||||||
TiffCreator::getPath(tiffPath, object->tag(), object->group(), root_);
|
|
||||||
pRoot_->addPath(object->tag(), tiffPath, pRoot_, std::move(clone));
|
pRoot_->addPath(object->tag(), tiffPath, pRoot_, std::move(clone));
|
||||||
#ifdef EXIV2_DEBUG_MESSAGES
|
#ifdef EXIV2_DEBUG_MESSAGES
|
||||||
ExifKey key(object->tag(), groupName(object->group()));
|
ExifKey key(object->tag(), groupName(object->group()));
|
||||||
@ -939,8 +938,7 @@ void TiffEncoder::add(TiffComponent* pRootDir, TiffComponent* pSourceDir, uint32
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Assumption is that the corresponding TIFF entry doesn't exist
|
// Assumption is that the corresponding TIFF entry doesn't exist
|
||||||
TiffPath tiffPath;
|
auto tiffPath = TiffCreator::getPath(i->tag(), group, root);
|
||||||
TiffCreator::getPath(tiffPath, i->tag(), group, root);
|
|
||||||
TiffComponent* tc = pRootDir->addPath(i->tag(), tiffPath, pRootDir);
|
TiffComponent* tc = pRootDir->addPath(i->tag(), tiffPath, pRootDir);
|
||||||
auto object = dynamic_cast<TiffEntryBase*>(tc);
|
auto object = dynamic_cast<TiffEntryBase*>(tc);
|
||||||
#ifdef EXIV2_DEBUG_MESSAGES
|
#ifdef EXIV2_DEBUG_MESSAGES
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user