Skip to content

Commit

Permalink
replace std::pair and tuple with C structs
Browse files Browse the repository at this point in the history
fixes internal MSVC libc++ warnings

Signed-off-by: Rosen Penev <[email protected]>
  • Loading branch information
neheb committed Feb 11, 2023
1 parent f2a71d2 commit 25bfe3d
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 88 deletions.
13 changes: 7 additions & 6 deletions src/crwimage_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ class RotationMap {

private:
//! Helper structure for the mapping list
using OmList = std::pair<uint16_t, int32_t>;
using OmList = struct {
uint16_t orientation;
int32_t degrees;
};
// DATA
static const OmList omList_[];
}; // class RotationMap
Expand Down Expand Up @@ -540,13 +543,12 @@ CiffComponent* CiffDirectory::doAdd(CrwDirs& crwDirs, uint16_t crwTagId) {
auto dir = crwDirs.top();
crwDirs.pop();
// Find the directory
auto it =
std::find_if(components_.begin(), components_.end(), [=](const auto& c) { return c->tag() == dir.first; });
auto it = std::find_if(components_.begin(), components_.end(), [=](const auto& c) { return c->tag() == dir.dir; });
if (it != components_.end())
cc_ = *it;
if (!cc_) {
// Directory doesn't exist yet, add it
m_ = std::make_unique<CiffDirectory>(dir.first, dir.second);
m_ = std::make_unique<CiffDirectory>(dir.dir, dir.parent);
cc_ = m_.get();
add(std::move(m_));
}
Expand Down Expand Up @@ -590,8 +592,7 @@ void CiffDirectory::doRemove(CrwDirs& crwDirs, uint16_t crwTagId) {
auto dir = crwDirs.top();
crwDirs.pop();
// Find the directory
auto it =
std::find_if(components_.begin(), components_.end(), [=](const auto& c) { return c->tag() == dir.first; });
auto it = std::find_if(components_.begin(), components_.end(), [=](const auto& c) { return c->tag() == dir.dir; });
if (it != components_.end()) {
// Recursive call to next lower level directory
(*it)->remove(crwDirs, crwTagId);
Expand Down
5 changes: 4 additions & 1 deletion src/crwimage_int.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ namespace Exiv2::Internal {
class CiffHeader;
class CiffComponent;
struct CrwMapping;
using CrwSubDir = std::pair<uint16_t, uint16_t>;
using CrwSubDir = struct {
uint16_t dir;
uint16_t parent;
};

// *****************************************************************************
// type definitions
Expand Down
54 changes: 29 additions & 25 deletions src/nikonmn_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3807,31 +3807,35 @@ std::ostream& Nikon3MakerNote::printLensId4ZMount(std::ostream& os, const Value&
}

// from https://github.com/exiftool/exiftool/blob/12.44/lib/Image/ExifTool/Nikon.pm#L4969
using ZMntLens = std::tuple<uint16_t, const char*, const char*>;
static constexpr auto zmountlens = std::array{
ZMntLens(1, "Nikon", "Nikkor Z 24-70mm f/4 S"),
ZMntLens(2, "Nikon", "Nikkor Z 14-30mm f/4 S"),
ZMntLens(4, "Nikon", "Nikkor Z 35mm f/1.8 S"),
ZMntLens(8, "Nikon", "Nikkor Z 58mm f/0.95 S Noct"), // IB
ZMntLens(9, "Nikon", "Nikkor Z 50mm f/1.8 S"),
ZMntLens(11, "Nikon", "Nikkor Z DX 16-50mm f/3.5-6.3 VR"),
ZMntLens(12, "Nikon", "Nikkor Z DX 50-250mm f/4.5-6.3 VR"),
ZMntLens(13, "Nikon", "Nikkor Z 24-70mm f/2.8 S"),
ZMntLens(14, "Nikon", "Nikkor Z 85mm f/1.8 S"),
ZMntLens(15, "Nikon", "Nikkor Z 24mm f/1.8 S"), // IB
ZMntLens(16, "Nikon", "Nikkor Z 70-200mm f/2.8 VR S"), // IB
ZMntLens(17, "Nikon", "Nikkor Z 20mm f/1.8 S"), // IB
ZMntLens(18, "Nikon", "Nikkor Z 24-200mm f/4-6.3 VR"), // IB
ZMntLens(21, "Nikon", "Nikkor Z 50mm f/1.2 S"), // IB
ZMntLens(22, "Nikon", "Nikkor Z 24-50mm f/4-6.3"), // IB
ZMntLens(23, "Nikon", "Nikkor Z 14-24mm f/2.8 S"), // IB
ZMntLens(24, "Nikon", "Nikkor Z MC 105mm f/2.8 VR S"), // IB
ZMntLens(27, "Nikon", "Nikkor Z MC 50mm f/2.8"), // IB
ZMntLens(28, "Nikon", "Nikkor Z 100-400mm f/4.5-5.6 VR S"), // 28
ZMntLens(29, "Nikon", "Nikkor Z 28mm f/2.8"), // IB
ZMntLens(30, "Nikon", "Nikkor Z 400mm f/2.8 TC VR S"), // 28
ZMntLens(31, "Nikon", "Nikkor Z 24-120 f/4"), // 28
ZMntLens(32, "Nikon", "Nikkor Z 800mm f/6.3 VR S"), // 28
using lens = struct {
uint16_t l;
const char* vendor;
const char* name;
};
static constexpr lens zmountlens[] = {
{1, "Nikon", "Nikkor Z 24-70mm f/4 S"},
{2, "Nikon", "Nikkor Z 14-30mm f/4 S"},
{4, "Nikon", "Nikkor Z 35mm f/1.8 S"},
{8, "Nikon", "Nikkor Z 58mm f/0.95 S Noct"}, // IB
{9, "Nikon", "Nikkor Z 50mm f/1.8 S"},
{11, "Nikon", "Nikkor Z DX 16-50mm f/3.5-6.3 VR"},
{12, "Nikon", "Nikkor Z DX 50-250mm f/4.5-6.3 VR"},
{13, "Nikon", "Nikkor Z 24-70mm f/2.8 S"},
{14, "Nikon", "Nikkor Z 85mm f/1.8 S"},
{15, "Nikon", "Nikkor Z 24mm f/1.8 S"}, // IB
{16, "Nikon", "Nikkor Z 70-200mm f/2.8 VR S"}, // IB
{17, "Nikon", "Nikkor Z 20mm f/1.8 S"}, // IB
{18, "Nikon", "Nikkor Z 24-200mm f/4-6.3 VR"}, // IB
{21, "Nikon", "Nikkor Z 50mm f/1.2 S"}, // IB
{22, "Nikon", "Nikkor Z 24-50mm f/4-6.3"}, // IB
{23, "Nikon", "Nikkor Z 14-24mm f/2.8 S"}, // IB
{24, "Nikon", "Nikkor Z MC 105mm f/2.8 VR S"}, // IB
{27, "Nikon", "Nikkor Z MC 50mm f/2.8"}, // IB
{28, "Nikon", "Nikkor Z 100-400mm f/4.5-5.6 VR S"}, // 28
{29, "Nikon", "Nikkor Z 28mm f/2.8"}, // IB
{30, "Nikon", "Nikkor Z 400mm f/2.8 TC VR S"}, // 28
{31, "Nikon", "Nikkor Z 24-120 f/4"}, // 28
{32, "Nikon", "Nikkor Z 800mm f/6.3 VR S"}, // 28
};

auto lid = static_cast<uint16_t>(value.toInt64());
Expand Down
85 changes: 46 additions & 39 deletions src/olympusmn_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1425,17 +1425,19 @@ std::ostream& OlympusMakerNote::printEq0x0301(std::ostream& os, const Value& val
//! OlympusCs FocusMode, tag 0x0301
// (1 or 2 values)
std::ostream& OlympusMakerNote::printCs0x0301(std::ostream& os, const Value& value, const ExifData*) {
using mode0 = std::pair<uint16_t, const char*>;
static constexpr auto focusModes0 = std::array{
mode0(0, N_("Single AF")), mode0(1, N_("Sequential shooting AF")),
mode0(2, N_("Continuous AF")), mode0(3, N_("Multi AF")),
mode0(4, N_("Face detect")), mode0(10, N_("MF")),
using mode = struct {
uint16_t tag;
const char* name;
};
static constexpr mode focusModes0[] = {
{0, N_("Single AF")}, {1, N_("Sequential shooting AF")},
{2, N_("Continuous AF")}, {3, N_("Multi AF")},
{4, N_("Face detect")}, {10, N_("MF")},
};

using mode1 = std::pair<uint16_t, const char*>;
static constexpr auto focusModes1 = std::array{
mode1(0x0001, N_("S-AF")), mode1(0x0004, N_("C-AF")), mode1(0x0010, N_("MF")),
mode1(0x0020, N_("Face detect")), mode1(0x0040, N_("Imager AF")), mode1(0x0100, N_("AF sensor")),
static constexpr mode focusModes1[] = {
{0x0001, N_("S-AF")}, {0x0004, N_("C-AF")}, {0x0010, N_("MF")},
{0x0020, N_("Face detect")}, {0x0040, N_("Imager AF")}, {0x0100, N_("AF sensor")},
};

if (value.count() < 1 || value.typeId() != unsignedShort) {
Expand Down Expand Up @@ -1535,38 +1537,43 @@ std::ostream& OlympusMakerNote::print0x0305(std::ostream& os, const Value& value

// Olympus FocusInfo tag 0x0308 AFPoint
std::ostream& OlympusMakerNote::print0x0308(std::ostream& os, const Value& value, const ExifData* metadata) {
using point = std::pair<uint16_t, const char*>;
static constexpr auto afPoints = std::array{
point(0, N_("Left (or n/a)")), point(1, N_("Center (horizontal)")),
point(2, N_("Right")), point(3, N_("Center (vertical)")),
point(255, N_("None")),
using point = struct {
uint16_t p;
const char* name;
};
static constexpr point afPoints[] = {
{0, N_("Left (or n/a)")}, {1, N_("Center (horizontal)")}, {2, N_("Right")}, {3, N_("Center (vertical)")},
{255, N_("None")},
};

using pointE3 = std::pair<byte, const char*>;
static constexpr auto afPointsE3 = std::array{
pointE3(0x00, N_("None")),
pointE3(0x01, N_("Top-left (horizontal)")),
pointE3(0x02, N_("Top-center (horizontal)")),
pointE3(0x03, N_("Top-right (horizontal)")),
pointE3(0x04, N_("Left (horizontal)")),
pointE3(0x05, N_("Mid-left (horizontal)")),
pointE3(0x06, N_("Center (horizontal)")),
pointE3(0x07, N_("Mid-right (horizontal)")),
pointE3(0x08, N_("Right (horizontal)")),
pointE3(0x09, N_("Bottom-left (horizontal)")),
pointE3(0x0a, N_("Bottom-center (horizontal)")),
pointE3(0x0b, N_("Bottom-right (horizontal)")),
pointE3(0x0c, N_("Top-left (vertical)")),
pointE3(0x0d, N_("Top-center (vertical)")),
pointE3(0x0e, N_("Top-right (vertical)")),
pointE3(0x0f, N_("Left (vertical)")),
pointE3(0x10, N_("Mid-left (vertical)")),
pointE3(0x11, N_("Center (vertical)")),
pointE3(0x12, N_("Mid-right (vertical)")),
pointE3(0x13, N_("Right (vertical)")),
pointE3(0x14, N_("Bottom-left (vertical)")),
pointE3(0x15, N_("Bottom-center (vertical)")),
pointE3(0x16, N_("Bottom-right (vertical)")),
using pointE3 = struct {
byte p;
const char* name;
};
static constexpr pointE3 afPointsE3[] = {
{0x00, N_("None")},
{0x01, N_("Top-left (horizontal)")},
{0x02, N_("Top-center (horizontal)")},
{0x03, N_("Top-right (horizontal)")},
{0x04, N_("Left (horizontal)")},
{0x05, N_("Mid-left (horizontal)")},
{0x06, N_("Center (horizontal)")},
{0x07, N_("Mid-right (horizontal)")},
{0x08, N_("Right (horizontal)")},
{0x09, N_("Bottom-left (horizontal)")},
{0x0a, N_("Bottom-center (horizontal)")},
{0x0b, N_("Bottom-right (horizontal)")},
{0x0c, N_("Top-left (vertical)")},
{0x0d, N_("Top-center (vertical)")},
{0x0e, N_("Top-right (vertical)")},
{0x0f, N_("Left (vertical)")},
{0x10, N_("Mid-left (vertical)")},
{0x11, N_("Center (vertical)")},
{0x12, N_("Mid-right (vertical)")},
{0x13, N_("Right (vertical)")},
{0x14, N_("Bottom-left (vertical)")},
{0x15, N_("Bottom-center (vertical)")},
{0x16, N_("Bottom-right (vertical)")},
};

if (value.count() != 1 || value.typeId() != unsignedShort) {
Expand Down
38 changes: 21 additions & 17 deletions src/tiffvisitor_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,23 +364,27 @@ void TiffDecoder::decodeCanonAFInfo(const TiffEntryBase* object) {
const uint16_t nMasks = (nPoints + 15) / (sizeof(uint16_t) * 8);
int nStart = 0;

using record = std::tuple<uint16_t, uint16_t, bool>;
static const auto records = std::array{
record(0x2600, 1, true), // AFInfoSize
record(0x2601, 1, true), // AFAreaMode
record(0x2602, 1, true), // AFNumPoints
record(0x2603, 1, true), // AFValidPoints
record(0x2604, 1, true), // AFCanonImageWidth
record(0x2605, 1, true), // AFCanonImageHeight
record(0x2606, 1, true), // AFImageWidth"
record(0x2607, 1, true), // AFImageHeight
record(0x2608, nPoints, true), // AFAreaWidths
record(0x2609, nPoints, true), // AFAreaHeights
record(0x260a, nPoints, true), // AFXPositions
record(0x260b, nPoints, true), // AFYPositions
record(0x260c, nMasks, false), // AFPointsInFocus
record(0x260d, nMasks, false), // AFPointsSelected
record(0x260e, nMasks, false), // AFPointsUnusable
using record = struct {
uint16_t tag;
uint16_t size;
bool bSigned;
};
static const record records[] = {
{0x2600, 1, true}, // AFInfoSize
{0x2601, 1, true}, // AFAreaMode
{0x2602, 1, true}, // AFNumPoints
{0x2603, 1, true}, // AFValidPoints
{0x2604, 1, true}, // AFCanonImageWidth
{0x2605, 1, true}, // AFCanonImageHeight
{0x2606, 1, true}, // AFImageWidth"
{0x2607, 1, true}, // AFImageHeight
{0x2608, nPoints, true}, // AFAreaWidths
{0x2609, nPoints, true}, // AFAreaHeights
{0x260a, nPoints, true}, // AFXPositions
{0x260b, nPoints, true}, // AFYPositions
{0x260c, nMasks, false}, // AFPointsInFocus
{0x260d, nMasks, false}, // AFPointsSelected
{0x260e, nMasks, false}, // AFPointsUnusable
};
// check we have enough data!
uint16_t count = 0;
Expand Down

0 comments on commit 25bfe3d

Please sign in to comment.