1010#include " tags_int.hpp"
1111#include " value.hpp"
1212
13+ #include < array>
14+
1315// *****************************************************************************
1416// class member definitions
1517namespace Exiv2 ::Internal {
@@ -1344,20 +1346,17 @@ std::ostream& OlympusMakerNote::printEq0x0301(std::ostream& os, const Value& val
13441346// ! OlympusCs FocusMode, tag 0x0301
13451347// (1 or 2 values)
13461348std::ostream& OlympusMakerNote::printCs0x0301 (std::ostream& os, const Value& value, const ExifData*) {
1347- static struct {
1348- uint16_t val;
1349- const char * label;
1350- } focusModes0[] = {
1351- {0 , N_ (" Single AF" )}, {1 , N_ (" Sequential shooting AF" )},
1352- {2 , N_ (" Continuous AF" )}, {3 , N_ (" Multi AF" )},
1353- {4 , N_ (" Face detect" )}, {10 , N_ (" MF" )},
1349+ using mode0 = std::pair<uint16_t , const char *>;
1350+ static constexpr auto focusModes0 = std::array{
1351+ mode0 (0 , N_ (" Single AF" )), mode0 (1 , N_ (" Sequential shooting AF" )),
1352+ mode0 (2 , N_ (" Continuous AF" )), mode0 (3 , N_ (" Multi AF" )),
1353+ mode0 (4 , N_ (" Face detect" )), mode0 (10 , N_ (" MF" )),
13541354 };
1355- static struct {
1356- uint16_t val;
1357- const char * label;
1358- } focusModes1[] = {
1359- {0x0001 , N_ (" S-AF" )}, {0x0004 , N_ (" C-AF" )}, {0x0010 , N_ (" MF" )},
1360- {0x0020 , N_ (" Face detect" )}, {0x0040 , N_ (" Imager AF" )}, {0x0100 , N_ (" AF sensor" )},
1355+
1356+ using mode1 = std::pair<uint16_t , const char *>;
1357+ static constexpr auto focusModes1 = std::array{
1358+ mode1 (0x0001 , N_ (" S-AF" )), mode1 (0x0004 , N_ (" C-AF" )), mode1 (0x0010 , N_ (" MF" )),
1359+ mode1 (0x0020 , N_ (" Face detect" )), mode1 (0x0040 , N_ (" Imager AF" )), mode1 (0x0100 , N_ (" AF sensor" )),
13611360 };
13621361
13631362 if (value.count () < 1 || value.typeId () != unsignedShort) {
@@ -1370,19 +1369,19 @@ std::ostream& OlympusMakerNote::printCs0x0301(std::ostream& os, const Value& val
13701369 std::string p; // Used to enable ',' separation
13711370
13721371 v = static_cast <uint16_t >(value.toInt64 (1 ));
1373- for (auto && mode : focusModes1) {
1374- if ((v & mode. val ) != 0 ) {
1372+ for (auto && [val, label] : focusModes1) {
1373+ if ((v & val) != 0 ) {
13751374 if (!p.empty ()) {
13761375 os << " , " ;
13771376 }
1378- p = mode. label ;
1377+ p = label;
13791378 os << p;
13801379 }
13811380 }
13821381 } else {
1383- for (auto && mode : focusModes0) {
1384- if (mode. val == v) {
1385- os << mode. label ;
1382+ for (auto && [val, label] : focusModes0) {
1383+ if (val == v) {
1384+ os << label;
13861385 break ;
13871386 }
13881387 }
@@ -1500,41 +1499,38 @@ std::ostream& OlympusMakerNote::print0x0305(std::ostream& os, const Value& value
15001499
15011500// Olympus FocusInfo tag 0x0308 AFPoint
15021501std::ostream& OlympusMakerNote::print0x0308 (std::ostream& os, const Value& value, const ExifData* metadata) {
1503- static struct {
1504- uint16_t val;
1505- const char * label;
1506- } afPoints[] = {
1507- {0 , N_ (" Left (or n/a)" )}, {1 , N_ (" Center (horizontal)" )}, {2 , N_ (" Right" )}, {3 , N_ (" Center (vertical)" )},
1508- {255 , N_ (" None" )},
1502+ using point = std::pair<uint16_t , const char *>;
1503+ static constexpr auto afPoints = std::array{
1504+ point (0 , N_ (" Left (or n/a)" )), point (1 , N_ (" Center (horizontal)" )),
1505+ point (2 , N_ (" Right" )), point (3 , N_ (" Center (vertical)" )),
1506+ point (255 , N_ (" None" )),
15091507 };
15101508
1511- static struct {
1512- byte val;
1513- const char * label;
1514- } afPointsE3[] = {
1515- {0x00 , N_ (" None" )},
1516- {0x01 , N_ (" Top-left (horizontal)" )},
1517- {0x02 , N_ (" Top-center (horizontal)" )},
1518- {0x03 , N_ (" Top-right (horizontal)" )},
1519- {0x04 , N_ (" Left (horizontal)" )},
1520- {0x05 , N_ (" Mid-left (horizontal)" )},
1521- {0x06 , N_ (" Center (horizontal)" )},
1522- {0x07 , N_ (" Mid-right (horizontal)" )},
1523- {0x08 , N_ (" Right (horizontal)" )},
1524- {0x09 , N_ (" Bottom-left (horizontal)" )},
1525- {0x0a , N_ (" Bottom-center (horizontal)" )},
1526- {0x0b , N_ (" Bottom-right (horizontal)" )},
1527- {0x0c , N_ (" Top-left (vertical)" )},
1528- {0x0d , N_ (" Top-center (vertical)" )},
1529- {0x0e , N_ (" Top-right (vertical)" )},
1530- {0x0f , N_ (" Left (vertical)" )},
1531- {0x10 , N_ (" Mid-left (vertical)" )},
1532- {0x11 , N_ (" Center (vertical)" )},
1533- {0x12 , N_ (" Mid-right (vertical)" )},
1534- {0x13 , N_ (" Right (vertical)" )},
1535- {0x14 , N_ (" Bottom-left (vertical)" )},
1536- {0x15 , N_ (" Bottom-center (vertical)" )},
1537- {0x16 , N_ (" Bottom-right (vertical)" )},
1509+ using pointE3 = std::pair<byte, const char *>;
1510+ static constexpr auto afPointsE3 = std::array{
1511+ pointE3 (0x00 , N_ (" None" )),
1512+ pointE3 (0x01 , N_ (" Top-left (horizontal)" )),
1513+ pointE3 (0x02 , N_ (" Top-center (horizontal)" )),
1514+ pointE3 (0x03 , N_ (" Top-right (horizontal)" )),
1515+ pointE3 (0x04 , N_ (" Left (horizontal)" )),
1516+ pointE3 (0x05 , N_ (" Mid-left (horizontal)" )),
1517+ pointE3 (0x06 , N_ (" Center (horizontal)" )),
1518+ pointE3 (0x07 , N_ (" Mid-right (horizontal)" )),
1519+ pointE3 (0x08 , N_ (" Right (horizontal)" )),
1520+ pointE3 (0x09 , N_ (" Bottom-left (horizontal)" )),
1521+ pointE3 (0x0a , N_ (" Bottom-center (horizontal)" )),
1522+ pointE3 (0x0b , N_ (" Bottom-right (horizontal)" )),
1523+ pointE3 (0x0c , N_ (" Top-left (vertical)" )),
1524+ pointE3 (0x0d , N_ (" Top-center (vertical)" )),
1525+ pointE3 (0x0e , N_ (" Top-right (vertical)" )),
1526+ pointE3 (0x0f , N_ (" Left (vertical)" )),
1527+ pointE3 (0x10 , N_ (" Mid-left (vertical)" )),
1528+ pointE3 (0x11 , N_ (" Center (vertical)" )),
1529+ pointE3 (0x12 , N_ (" Mid-right (vertical)" )),
1530+ pointE3 (0x13 , N_ (" Right (vertical)" )),
1531+ pointE3 (0x14 , N_ (" Bottom-left (vertical)" )),
1532+ pointE3 (0x15 , N_ (" Bottom-center (vertical)" )),
1533+ pointE3 (0x16 , N_ (" Bottom-right (vertical)" )),
15381534 };
15391535
15401536 if (value.count () != 1 || value.typeId () != unsignedShort) {
@@ -1556,16 +1552,16 @@ std::ostream& OlympusMakerNote::print0x0308(std::ostream& os, const Value& value
15561552 auto v = static_cast <uint16_t >(value.toInt64 (0 ));
15571553
15581554 if (!E3_E30model) {
1559- for (auto && point : afPoints) {
1560- if (point. val == v) {
1561- return os << point. label ;
1555+ for (auto && [val, label] : afPoints) {
1556+ if (val == v) {
1557+ return os << label;
15621558 }
15631559 }
15641560 } else {
15651561 // E-3 and E-30
1566- for (auto && point : afPointsE3) {
1567- if (point. val == (v & 0x1f )) {
1568- os << point. label ;
1562+ for (auto && [val, label] : afPointsE3) {
1563+ if (val == (v & 0x1f )) {
1564+ os << label;
15691565 os << " , " ;
15701566 if ((v & 0xe0 ) == 0 )
15711567 return os << N_ (" Single Target" );
0 commit comments