Skip to content

Commit

Permalink
remove several constructors
Browse files Browse the repository at this point in the history
Just direct initialize

Signed-off-by: Rosen Penev <rosenp@gmail.com>
  • Loading branch information
neheb committed Mar 21, 2023
1 parent f1008f9 commit aefbd7d
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 68 deletions.
51 changes: 27 additions & 24 deletions src/crwimage_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,31 +81,31 @@ namespace Exiv2::Internal {
const CrwMapping CrwMap::crwMapping_[] = {
// CrwTag CrwDir Size ExifTag IfdId decodeFct encodeFct
// ------ ------ ---- ------- ----- --------- ---------
CrwMapping(0x0805, 0x300a, 0, 0, IfdId::canonId, decode0x0805, encode0x0805),
CrwMapping(0x080a, 0x2807, 0, 0, IfdId::canonId, decode0x080a, encode0x080a),
CrwMapping(0x080b, 0x3004, 0, 0x0007, IfdId::canonId, decodeBasic, encodeBasic),
CrwMapping(0x0810, 0x2807, 0, 0x0009, IfdId::canonId, decodeBasic, encodeBasic),
CrwMapping(0x0815, 0x2804, 0, 0x0006, IfdId::canonId, decodeBasic, encodeBasic),
CrwMapping(0x1029, 0x300b, 0, 0x0002, IfdId::canonId, decodeBasic, encodeBasic),
CrwMapping(0x102a, 0x300b, 0, 0x0004, IfdId::canonId, decodeArray, encodeArray),
CrwMapping(0x102d, 0x300b, 0, 0x0001, IfdId::canonId, decodeArray, encodeArray),
CrwMapping(0x1033, 0x300b, 0, 0x000f, IfdId::canonId, decodeArray, encodeArray),
CrwMapping(0x1038, 0x300b, 0, 0x0012, IfdId::canonId, decodeArray, encodeArray),
CrwMapping(0x10a9, 0x300b, 0, 0x00a9, IfdId::canonId, decodeBasic, encodeBasic),
{0x0805, 0x300a, 0, 0, IfdId::canonId, decode0x0805, encode0x0805},
{0x080a, 0x2807, 0, 0, IfdId::canonId, decode0x080a, encode0x080a},
{0x080b, 0x3004, 0, 0x0007, IfdId::canonId, decodeBasic, encodeBasic},
{0x0810, 0x2807, 0, 0x0009, IfdId::canonId, decodeBasic, encodeBasic},
{0x0815, 0x2804, 0, 0x0006, IfdId::canonId, decodeBasic, encodeBasic},
{0x1029, 0x300b, 0, 0x0002, IfdId::canonId, decodeBasic, encodeBasic},
{0x102a, 0x300b, 0, 0x0004, IfdId::canonId, decodeArray, encodeArray},
{0x102d, 0x300b, 0, 0x0001, IfdId::canonId, decodeArray, encodeArray},
{0x1033, 0x300b, 0, 0x000f, IfdId::canonId, decodeArray, encodeArray},
{0x1038, 0x300b, 0, 0x0012, IfdId::canonId, decodeArray, encodeArray},
{0x10a9, 0x300b, 0, 0x00a9, IfdId::canonId, decodeBasic, encodeBasic},
// Mapped to Exif.Photo.ColorSpace instead (see below)
// CrwMapping(0x10b4, 0x300b, 0, 0x00b4, IfdId::canonId, decodeBasic, encodeBasic),
CrwMapping(0x10b4, 0x300b, 0, 0xa001, IfdId::exifId, decodeBasic, encodeBasic),
CrwMapping(0x10b5, 0x300b, 0, 0x00b5, IfdId::canonId, decodeBasic, encodeBasic),
CrwMapping(0x10c0, 0x300b, 0, 0x00c0, IfdId::canonId, decodeBasic, encodeBasic),
CrwMapping(0x10c1, 0x300b, 0, 0x00c1, IfdId::canonId, decodeBasic, encodeBasic),
CrwMapping(0x1807, 0x3002, 0, 0x9206, IfdId::exifId, decodeBasic, encodeBasic),
CrwMapping(0x180b, 0x3004, 0, 0x000c, IfdId::canonId, decodeBasic, encodeBasic),
CrwMapping(0x180e, 0x300a, 0, 0x9003, IfdId::exifId, decode0x180e, encode0x180e),
CrwMapping(0x1810, 0x300a, 0, 0xa002, IfdId::exifId, decode0x1810, encode0x1810),
CrwMapping(0x1817, 0x300a, 4, 0x0008, IfdId::canonId, decodeBasic, encodeBasic),
// CrwMapping(0x1818, 0x3002, 0, 0x9204, IfdId::exifId, decodeBasic, encodeBasic),
CrwMapping(0x183b, 0x300b, 0, 0x0015, IfdId::canonId, decodeBasic, encodeBasic),
CrwMapping(0x2008, 0x0000, 0, 0, IfdId::ifd1Id, decode0x2008, encode0x2008),
// {0x10b4, 0x300b, 0, 0x00b4, IfdId::canonId, decodeBasic, encodeBasic},
{0x10b4, 0x300b, 0, 0xa001, IfdId::exifId, decodeBasic, encodeBasic},
{0x10b5, 0x300b, 0, 0x00b5, IfdId::canonId, decodeBasic, encodeBasic},
{0x10c0, 0x300b, 0, 0x00c0, IfdId::canonId, decodeBasic, encodeBasic},
{0x10c1, 0x300b, 0, 0x00c1, IfdId::canonId, decodeBasic, encodeBasic},
{0x1807, 0x3002, 0, 0x9206, IfdId::exifId, decodeBasic, encodeBasic},
{0x180b, 0x3004, 0, 0x000c, IfdId::canonId, decodeBasic, encodeBasic},
{0x180e, 0x300a, 0, 0x9003, IfdId::exifId, decode0x180e, encode0x180e},
{0x1810, 0x300a, 0, 0xa002, IfdId::exifId, decode0x1810, encode0x1810},
{0x1817, 0x300a, 4, 0x0008, IfdId::canonId, decodeBasic, encodeBasic},
// {0x1818, 0x3002, 0, 0x9204, IfdId::exifId, decodeBasic, encodeBasic},
{0x183b, 0x300b, 0, 0x0015, IfdId::canonId, decodeBasic, encodeBasic},
{0x2008, 0x0000, 0, 0, IfdId::ifd1Id, decode0x2008, encode0x2008},
}; // CrwMap::crwMapping_[]

/*
Expand All @@ -130,6 +130,9 @@ const CrwSubDir CrwMap::crwSubDir_[] = {
{0x2807, 0x300a}, {0x2804, 0x300a}, {0x300a, 0x0000}, {0x0000, 0xffff},
};

CiffComponent::CiffComponent(uint16_t tag, uint16_t dir) : dir_(dir), tag_(tag) {
}

CiffDirectory::~CiffDirectory() {
for (auto&& component : components_) {
delete component;
Expand Down
22 changes: 2 additions & 20 deletions src/crwimage_int.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ class CiffComponent {
//! Default constructor
CiffComponent() = default;
//! Constructor taking a tag and directory
CiffComponent(uint16_t tag, uint16_t dir) : dir_(dir), tag_(tag) {
}
CiffComponent(uint16_t tag, uint16_t dir);
CiffComponent(const CiffComponent&) = delete;
CiffComponent& operator=(const CiffComponent&) = delete;
//! Virtual destructor.
Expand Down Expand Up @@ -482,31 +481,14 @@ class CiffHeader {
image metadata and vice versa.
*/
struct CrwMapping {
//! @name Creators
//@{
//! Default constructor
CrwMapping(uint16_t crwTagId, uint16_t crwDir, uint32_t size, uint16_t tag, IfdId ifdId, CrwDecodeFct toExif,
CrwEncodeFct fromExif) :
crwTagId_(crwTagId),
crwDir_(crwDir),
size_(size),
tag_(tag),
ifdId_(ifdId),
toExif_(toExif),
fromExif_(fromExif) {
}
//@}

// DATA
uint16_t crwTagId_; //!< CRW tag id
uint16_t crwDir_; //!< CRW directory tag
uint32_t size_; //!< Data size (overwrites the size from the entry)
uint16_t tag_; //!< Exif tag to map to
IfdId ifdId_; //!< Exif Ifd id to map to
CrwDecodeFct toExif_; //!< Conversion function
CrwEncodeFct fromExif_; //!< Reverse conversion function

}; // struct CrwMapping
};

/*!
@brief Static class providing mapping functionality from CRW entries
Expand Down
13 changes: 13 additions & 0 deletions src/tiffcomposite_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,20 @@ void IoWrapper::setTarget(int id, size_t target) {
TiffComponent::TiffComponent(uint16_t tag, IfdId group) : tag_(tag), group_(group) {
}

TiffDirectory::TiffDirectory(uint16_t tag, IfdId group, bool hasNext) : TiffComponent(tag, group), hasNext_(hasNext) {
}

TiffEntryBase::TiffEntryBase(uint16_t tag, IfdId group, TiffType tiffType) :
TiffComponent(tag, group), tiffType_(tiffType) {
}

TiffSizeEntry::TiffSizeEntry(uint16_t tag, IfdId group, uint16_t dtTag, IfdId dtGroup) :
TiffEntryBase(tag, group), dtTag_(dtTag), dtGroup_(dtGroup) {
}

TiffEntry::TiffEntry(uint16_t tag, IfdId group) : TiffEntryBase(tag, group) {
}

TiffSubIfd::TiffSubIfd(uint16_t tag, IfdId group, IfdId newGroup) :
TiffEntryBase(tag, group, ttUnsignedLong), newGroup_(newGroup) {
}
Expand All @@ -92,6 +102,9 @@ TiffBinaryArray::TiffBinaryArray(uint16_t tag, IfdId group, const ArraySet* arra
// We'll figure out the correct cfg later
}

TiffPathItem::TiffPathItem(uint32_t extendedTag, IfdId group) : extendedTag_(extendedTag), group_(group) {
}

TiffDirectory::~TiffDirectory() {
for (auto&& component : components_) {
delete component;
Expand Down
13 changes: 4 additions & 9 deletions src/tiffcomposite_int.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ class TiffPathItem {
//! @name Creators
//@{
//! Constructor
constexpr TiffPathItem(uint32_t extendedTag, IfdId group) : extendedTag_(extendedTag), group_(group) {
}
TiffPathItem(uint32_t extendedTag, IfdId group);
//@}

//! @name Accessors
Expand Down Expand Up @@ -567,8 +566,7 @@ class TiffEntry : public TiffEntryBase {
//! @name Creators
//@{
//! Constructor
TiffEntry(uint16_t tag, IfdId group) : TiffEntryBase(tag, group) {
}
TiffEntry(uint16_t tag, IfdId group);
//@}

protected:
Expand Down Expand Up @@ -781,9 +779,7 @@ class TiffSizeEntry : public TiffEntryBase {
//! @name Creators
//@{
//! Constructor
TiffSizeEntry(uint16_t tag, IfdId group, uint16_t dtTag, IfdId dtGroup) :
TiffEntryBase(tag, group), dtTag_(dtTag), dtGroup_(dtGroup) {
}
TiffSizeEntry(uint16_t tag, IfdId group, uint16_t dtTag, IfdId dtGroup);
//@}

//! @name Accessors
Expand Down Expand Up @@ -829,8 +825,7 @@ class TiffDirectory : public TiffComponent {
//! @name Creators
//@{
//! Default constructor
TiffDirectory(uint16_t tag, IfdId group, bool hasNext = true) : TiffComponent(tag, group), hasNext_(hasNext) {
}
TiffDirectory(uint16_t tag, IfdId group, bool hasNext = true);
//! Virtual destructor
~TiffDirectory() override;
//@}
Expand Down
6 changes: 3 additions & 3 deletions src/tiffimage_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2099,8 +2099,8 @@ TiffComponent::UniquePtr TiffParserWorker::parse(const byte* pData, size_t size,
auto rootDir = TiffCreator::create(root, IfdId::ifdIdNotSet);
if (rootDir) {
rootDir->setStart(pData + pHeader->offset());
TiffRwState state(pHeader->byteOrder(), 0);
TiffReader reader(pData, size, rootDir.get(), state);
auto state = TiffRwState{pHeader->byteOrder(), 0};
auto reader = TiffReader{pData, size, rootDir.get(), state};
rootDir->accept(reader);
reader.postProcess();
}
Expand Down Expand Up @@ -2345,7 +2345,7 @@ bool TiffHeader::isImageTag(uint16_t tag, IfdId group, const PrimaryGroups* pPri
} // TiffHeader::isImageTag

void OffsetWriter::setOrigin(OffsetId id, uint32_t origin, ByteOrder byteOrder) {
offsetList_[id] = OffsetData(origin, byteOrder);
offsetList_[id] = OffsetData{origin, 0, byteOrder};
}

void OffsetWriter::setTarget(OffsetId id, uint32_t target) {
Expand Down
6 changes: 0 additions & 6 deletions src/tiffimage_int.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,6 @@ class OffsetWriter {
private:
//! Data structure for the offset list.
struct OffsetData {
//! Default constructor
OffsetData() = default;
//! Constructor
OffsetData(uint32_t origin, ByteOrder byteOrder) : origin_(origin), byteOrder_(byteOrder) {
}
// DATA
uint32_t origin_{}; //!< Origin address
uint32_t target_{}; //!< Target address
ByteOrder byteOrder_{littleEndian}; //!< Byte order to use to encode target address
Expand Down
10 changes: 8 additions & 2 deletions src/tiffvisitor_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ void TiffVisitor::visitIfdMakernoteEnd(TiffIfdMakernote* /*object*/) {
void TiffVisitor::visitBinaryArrayEnd(TiffBinaryArray* /*object*/) {
}

TiffFinder::TiffFinder(uint16_t tag, IfdId group) : tag_(tag), group_(group) {
}

void TiffFinder::init(uint16_t tag, IfdId group) {
tag_ = tag;
group_ = group;
Expand Down Expand Up @@ -981,6 +984,9 @@ void TiffEncoder::add(TiffComponent* pRootDir, TiffComponent* pSourceDir, uint32

} // TiffEncoder::add

TiffRwState::TiffRwState(ByteOrder byteOrder, size_t baseOffset) : byteOrder_(byteOrder), baseOffset_(baseOffset) {
}

TiffReader::TiffReader(const byte* pData, size_t size, TiffComponent* pRoot, TiffRwState state) :
pData_(pData), size_(size), pLast_(pData + size), pRoot_(pRoot), origState_(state), mnState_(state) {
pState_ = &origState_;
Expand All @@ -995,7 +1001,7 @@ void TiffReader::setMnState(const TiffRwState* state) {
if (state) {
// invalidByteOrder indicates 'no change'
if (state->byteOrder() == invalidByteOrder) {
mnState_ = TiffRwState(origState_.byteOrder(), state->baseOffset());
mnState_ = TiffRwState{origState_.byteOrder(), state->baseOffset()};
} else {
mnState_ = *state;
}
Expand Down Expand Up @@ -1221,7 +1227,7 @@ void TiffReader::visitIfdMakernote(TiffIfdMakernote* object) {

// Modify reader for Makernote peculiarities, byte order and offset
object->mnOffset_ = object->start() - pData_;
TiffRwState state(object->byteOrder(), object->baseOffset());
auto state = TiffRwState{object->byteOrder(), object->baseOffset()};
setMnState(&state);

} // TiffReader::visitIfdMakernote
Expand Down
6 changes: 2 additions & 4 deletions src/tiffvisitor_int.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ class TiffFinder : public TiffVisitor {
//! @name Creators
//@{
//! Constructor, taking \em tag and \em group of the component to find.
TiffFinder(uint16_t tag, IfdId group) : tag_(tag), group_(group) {
}
TiffFinder(uint16_t tag, IfdId group);
TiffFinder(const TiffFinder&) = delete;
TiffFinder& operator=(const TiffFinder&) = delete;
//! Virtual destructor
Expand Down Expand Up @@ -538,8 +537,7 @@ class TiffRwState {
//! @name Creators
//@{
//! Constructor.
TiffRwState(ByteOrder byteOrder, size_t baseOffset) : byteOrder_(byteOrder), baseOffset_(baseOffset) {
}
TiffRwState(ByteOrder byteOrder, size_t baseOffset);
//@}

//! @name Accessors
Expand Down

0 comments on commit aefbd7d

Please sign in to comment.