some std::array conversions (#2148)

Signed-off-by: Rosen Penev <rosenp@gmail.com>
main
Rosen Penev 3 years ago committed by GitHub
parent 573c3c79fc
commit b2b6d834ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -125,7 +125,7 @@ namespace {
multi-byte characters correctly. Replace code in the form multi-byte characters correctly. Replace code in the form
os << setw(width) << myString os << setw(width) << myString
with with
os << make_pair( myString, width) os << pair( myString, width)
*/ */
std::ostream& operator<<(std::ostream& os, const std::pair<std::string, int>& strAndWidth); std::ostream& operator<<(std::ostream& os, const std::pair<std::string, int>& strAndWidth);
@ -317,8 +317,7 @@ namespace Action {
if (Params::instance().files_.size() > 1) { if (Params::instance().files_.size() > 1) {
std::cout << std::setw(20) << path_ << " "; std::cout << std::setw(20) << path_ << " ";
} }
std::cout << std::make_pair( label, align_) std::cout << std::pair(label, align_) << ": ";
<< ": ";
} }
int Print::printTag(const Exiv2::ExifData& exifData, int Print::printTag(const Exiv2::ExifData& exifData,

@ -379,8 +379,8 @@ namespace Exiv2 {
private: private:
// Constant data // Constant data
static const char exiv2Id_[]; // EXV identifier static constexpr char exiv2Id_[] = "Exiv2"; // EXV identifier
static const byte blank_[]; // Minimal exiv2 file static constexpr byte blank_[] = {0xff, 0x01, 'E', 'x', 'i', 'v', '2', 0xff, 0xd9}; // Minimal exiv2 file
}; // class ExvImage }; // class ExvImage

@ -464,9 +464,7 @@ namespace Exiv2 {
//! Information pertaining to the defined character sets //! Information pertaining to the defined character sets
struct CharsetTable { struct CharsetTable {
//! Constructor //! Constructor
CharsetTable(CharsetId charsetId, constexpr CharsetTable(CharsetId charsetId, const char* name, const char* code);
const char* name,
const char* code);
CharsetId charsetId_; //!< Charset id CharsetId charsetId_; //!< Charset id
const char* name_; //!< Name of the charset const char* name_; //!< Name of the charset
const char* code_; //!< Code of the charset const char* code_; //!< Code of the charset

@ -1513,7 +1513,7 @@ namespace {
bool convertStringCharsetWindows(std::string& str, const char* from, const char* to) bool convertStringCharsetWindows(std::string& str, const char* from, const char* to)
{ {
bool ret = false; bool ret = false;
const ConvFctList* p = find(convFctList, std::make_pair(from, to)); const ConvFctList* p = find(convFctList, std::pair(from, to));
std::string tmpstr = str; std::string tmpstr = str;
if (p) ret = p->convFct_(tmpstr); if (p) ret = p->convFct_(tmpstr);
#ifndef SUPPRESS_WARNINGS #ifndef SUPPRESS_WARNINGS

@ -11,6 +11,7 @@
#include "tiffcomposite_int.hpp" #include "tiffcomposite_int.hpp"
#include "tiffimage_int.hpp" #include "tiffimage_int.hpp"
#include <array>
#include <iostream> #include <iostream>
// ***************************************************************************** // *****************************************************************************
@ -136,8 +137,8 @@ namespace Exiv2 {
ExifData ed = exifData; ExifData ed = exifData;
// Delete IFDs which do not occur in TIFF images // Delete IFDs which do not occur in TIFF images
static const IfdId filteredIfds[] = { static constexpr auto filteredIfds = std::array{
panaRawId panaRawId,
}; };
for (auto&& filteredIfd : filteredIfds) { for (auto&& filteredIfd : filteredIfds) {
#ifdef EXIV2_DEBUG_MESSAGES #ifdef EXIV2_DEBUG_MESSAGES

@ -24,6 +24,7 @@
// + standard includes // + standard includes
#include <algorithm> #include <algorithm>
#include <array>
#include <cstdio> #include <cstdio>
#include <iostream> #include <iostream>
#include <utility> #include <utility>
@ -508,7 +509,7 @@ namespace Exiv2 {
// Delete IFD0 tags that are "not recorded" in compressed images // Delete IFD0 tags that are "not recorded" in compressed images
// Reference: Exif 2.2 specs, 4.6.8 Tag Support Levels, section A // Reference: Exif 2.2 specs, 4.6.8 Tag Support Levels, section A
static const char* filteredIfd0Tags[] = { static constexpr auto filteredIfd0Tags = std::array{
"Exif.Image.PhotometricInterpretation", "Exif.Image.PhotometricInterpretation",
"Exif.Image.StripOffsets", "Exif.Image.StripOffsets",
"Exif.Image.RowsPerStrip", "Exif.Image.RowsPerStrip",
@ -586,35 +587,35 @@ namespace Exiv2 {
// Delete preview tags if the preview is larger than 32kB. // Delete preview tags if the preview is larger than 32kB.
// Todo: Enhance preview classes to be able to write and delete previews and use that instead. // Todo: Enhance preview classes to be able to write and delete previews and use that instead.
// Table must be sorted by preview, the first tag in each group is the size // Table must be sorted by preview, the first tag in each group is the size
static const PreviewTags filteredPvTags[] = { static constexpr auto filteredPvTags = std::array{
{ pttLen, "Exif.Minolta.ThumbnailLength" }, PreviewTags{pttLen, "Exif.Minolta.ThumbnailLength"},
{ pttTag, "Exif.Minolta.ThumbnailOffset" }, PreviewTags{pttTag, "Exif.Minolta.ThumbnailOffset"},
{ pttLen, "Exif.Minolta.Thumbnail" }, PreviewTags{pttLen, "Exif.Minolta.Thumbnail"},
{ pttLen, "Exif.NikonPreview.JPEGInterchangeFormatLength" }, PreviewTags{pttLen, "Exif.NikonPreview.JPEGInterchangeFormatLength"},
{ pttIfd, "NikonPreview" }, PreviewTags{pttIfd, "NikonPreview"},
{ pttLen, "Exif.Olympus.ThumbnailLength" }, PreviewTags{pttLen, "Exif.Olympus.ThumbnailLength"},
{ pttTag, "Exif.Olympus.ThumbnailOffset" }, PreviewTags{pttTag, "Exif.Olympus.ThumbnailOffset"},
{ pttLen, "Exif.Olympus.ThumbnailImage" }, PreviewTags{pttLen, "Exif.Olympus.ThumbnailImage"},
{ pttLen, "Exif.Olympus.Thumbnail" }, PreviewTags{pttLen, "Exif.Olympus.Thumbnail"},
{ pttLen, "Exif.Olympus2.ThumbnailLength" }, PreviewTags{pttLen, "Exif.Olympus2.ThumbnailLength"},
{ pttTag, "Exif.Olympus2.ThumbnailOffset" }, PreviewTags{pttTag, "Exif.Olympus2.ThumbnailOffset"},
{ pttLen, "Exif.Olympus2.ThumbnailImage" }, PreviewTags{pttLen, "Exif.Olympus2.ThumbnailImage"},
{ pttLen, "Exif.Olympus2.Thumbnail" }, PreviewTags{pttLen, "Exif.Olympus2.Thumbnail"},
{ pttLen, "Exif.OlympusCs.PreviewImageLength" }, PreviewTags{pttLen, "Exif.OlympusCs.PreviewImageLength"},
{ pttTag, "Exif.OlympusCs.PreviewImageStart" }, PreviewTags{pttTag, "Exif.OlympusCs.PreviewImageStart"},
{ pttTag, "Exif.OlympusCs.PreviewImageValid" }, PreviewTags{pttTag, "Exif.OlympusCs.PreviewImageValid"},
{ pttLen, "Exif.Pentax.PreviewLength" }, PreviewTags{pttLen, "Exif.Pentax.PreviewLength"},
{ pttTag, "Exif.Pentax.PreviewOffset" }, PreviewTags{pttTag, "Exif.Pentax.PreviewOffset"},
{ pttTag, "Exif.Pentax.PreviewResolution" }, PreviewTags{pttTag, "Exif.Pentax.PreviewResolution"},
{ pttLen, "Exif.PentaxDng.PreviewLength" }, PreviewTags{pttLen, "Exif.PentaxDng.PreviewLength"},
{ pttTag, "Exif.PentaxDng.PreviewOffset" }, PreviewTags{pttTag, "Exif.PentaxDng.PreviewOffset"},
{ pttTag, "Exif.PentaxDng.PreviewResolution" }, PreviewTags{pttTag, "Exif.PentaxDng.PreviewResolution"},
{ pttLen, "Exif.SamsungPreview.JPEGInterchangeFormatLength" }, PreviewTags{pttLen, "Exif.SamsungPreview.JPEGInterchangeFormatLength"},
{ pttIfd, "SamsungPreview" }, PreviewTags{pttIfd, "SamsungPreview"},
{ pttLen, "Exif.Thumbnail.StripByteCounts" }, PreviewTags{pttLen, "Exif.Thumbnail.StripByteCounts"},
{ pttIfd, "Thumbnail" }, PreviewTags{pttIfd, "Thumbnail"},
{ pttLen, "Exif.Thumbnail.JPEGInterchangeFormatLength" }, PreviewTags{pttLen, "Exif.Thumbnail.JPEGInterchangeFormatLength"},
{ pttIfd, "Thumbnail" } PreviewTags{pttIfd, "Thumbnail"},
}; };
bool delTags = false; bool delTags = false;
for (auto&& filteredPvTag : filteredPvTags) { for (auto&& filteredPvTag : filteredPvTags) {

@ -66,41 +66,41 @@ namespace {
}; };
/// \todo Use std::unordered_map for implementing the registry. Avoid to use ImageType::none /// \todo Use std::unordered_map for implementing the registry. Avoid to use ImageType::none
const Registry registry[] = { constexpr Registry registry[] = {
//image type creation fct type check Exif mode IPTC mode XMP mode Comment mode // image type creation fct type check Exif mode IPTC mode XMP mode Comment mode
//--------------- --------------- ---------- ----------- ----------- ----------- ------------ //--------------- --------------- ---------- ----------- ----------- ----------- ------------
{ ImageType::jpeg, newJpegInstance, isJpegType, amReadWrite, amReadWrite, amReadWrite, amReadWrite }, {ImageType::jpeg, newJpegInstance, isJpegType, amReadWrite, amReadWrite, amReadWrite, amReadWrite},
{ ImageType::exv, newExvInstance, isExvType, amReadWrite, amReadWrite, amReadWrite, amReadWrite }, {ImageType::exv, newExvInstance, isExvType, amReadWrite, amReadWrite, amReadWrite, amReadWrite},
{ ImageType::cr2, newCr2Instance, isCr2Type, amReadWrite, amReadWrite, amReadWrite, amNone }, {ImageType::cr2, newCr2Instance, isCr2Type, amReadWrite, amReadWrite, amReadWrite, amNone},
{ ImageType::crw, newCrwInstance, isCrwType, amReadWrite, amNone, amNone, amReadWrite }, {ImageType::crw, newCrwInstance, isCrwType, amReadWrite, amNone, amNone, amReadWrite},
{ ImageType::mrw, newMrwInstance, isMrwType, amRead, amRead, amRead, amNone }, {ImageType::mrw, newMrwInstance, isMrwType, amRead, amRead, amRead, amNone},
{ ImageType::tiff, newTiffInstance, isTiffType, amReadWrite, amReadWrite, amReadWrite, amNone }, {ImageType::tiff, newTiffInstance, isTiffType, amReadWrite, amReadWrite, amReadWrite, amNone},
{ ImageType::webp, newWebPInstance, isWebPType, amReadWrite, amNone, amReadWrite, amNone }, {ImageType::webp, newWebPInstance, isWebPType, amReadWrite, amNone, amReadWrite, amNone},
{ ImageType::dng, newTiffInstance, isTiffType, amReadWrite, amReadWrite, amReadWrite, amNone }, {ImageType::dng, newTiffInstance, isTiffType, amReadWrite, amReadWrite, amReadWrite, amNone},
{ ImageType::nef, newTiffInstance, isTiffType, amReadWrite, amReadWrite, amReadWrite, amNone }, {ImageType::nef, newTiffInstance, isTiffType, amReadWrite, amReadWrite, amReadWrite, amNone},
{ ImageType::pef, newTiffInstance, isTiffType, amReadWrite, amReadWrite, amReadWrite, amNone }, {ImageType::pef, newTiffInstance, isTiffType, amReadWrite, amReadWrite, amReadWrite, amNone},
{ ImageType::arw, newTiffInstance, isTiffType, amRead, amRead, amRead, amNone }, {ImageType::arw, newTiffInstance, isTiffType, amRead, amRead, amRead, amNone},
{ ImageType::rw2, newRw2Instance, isRw2Type, amRead, amRead, amRead, amNone }, {ImageType::rw2, newRw2Instance, isRw2Type, amRead, amRead, amRead, amNone},
{ ImageType::sr2, newTiffInstance, isTiffType, amRead, amRead, amRead, amNone }, {ImageType::sr2, newTiffInstance, isTiffType, amRead, amRead, amRead, amNone},
{ ImageType::srw, newTiffInstance, isTiffType, amReadWrite, amReadWrite, amReadWrite, amNone }, {ImageType::srw, newTiffInstance, isTiffType, amReadWrite, amReadWrite, amReadWrite, amNone},
{ ImageType::orf, newOrfInstance, isOrfType, amReadWrite, amReadWrite, amReadWrite, amNone }, {ImageType::orf, newOrfInstance, isOrfType, amReadWrite, amReadWrite, amReadWrite, amNone},
#ifdef EXV_HAVE_LIBZ #ifdef EXV_HAVE_LIBZ
{ ImageType::png, newPngInstance, isPngType, amReadWrite, amReadWrite, amReadWrite, amReadWrite }, {ImageType::png, newPngInstance, isPngType, amReadWrite, amReadWrite, amReadWrite, amReadWrite},
#endif // EXV_HAVE_LIBZ #endif // EXV_HAVE_LIBZ
{ ImageType::pgf, newPgfInstance, isPgfType, amReadWrite, amReadWrite, amReadWrite, amReadWrite }, {ImageType::pgf, newPgfInstance, isPgfType, amReadWrite, amReadWrite, amReadWrite, amReadWrite},
{ ImageType::raf, newRafInstance, isRafType, amRead, amRead, amRead, amNone }, {ImageType::raf, newRafInstance, isRafType, amRead, amRead, amRead, amNone},
{ ImageType::eps, newEpsInstance, isEpsType, amNone, amNone, amReadWrite, amNone }, {ImageType::eps, newEpsInstance, isEpsType, amNone, amNone, amReadWrite, amNone},
{ ImageType::xmp, newXmpInstance, isXmpType, amReadWrite, amReadWrite, amReadWrite, amNone }, {ImageType::xmp, newXmpInstance, isXmpType, amReadWrite, amReadWrite, amReadWrite, amNone},
{ ImageType::gif, newGifInstance, isGifType, amNone, amNone, amNone, amNone }, {ImageType::gif, newGifInstance, isGifType, amNone, amNone, amNone, amNone},
{ ImageType::psd, newPsdInstance, isPsdType, amReadWrite, amReadWrite, amReadWrite, amNone }, {ImageType::psd, newPsdInstance, isPsdType, amReadWrite, amReadWrite, amReadWrite, amNone},
{ ImageType::tga, newTgaInstance, isTgaType, amNone, amNone, amNone, amNone }, {ImageType::tga, newTgaInstance, isTgaType, amNone, amNone, amNone, amNone},
{ ImageType::bmp, newBmpInstance, isBmpType, amNone, amNone, amNone, amNone }, {ImageType::bmp, newBmpInstance, isBmpType, amNone, amNone, amNone, amNone},
{ ImageType::jp2, newJp2Instance, isJp2Type, amReadWrite, amReadWrite, amReadWrite, amNone }, {ImageType::jp2, newJp2Instance, isJp2Type, amReadWrite, amReadWrite, amReadWrite, amNone},
#ifdef EXV_ENABLE_BMFF #ifdef EXV_ENABLE_BMFF
{ ImageType::bmff, newBmffInstance, isBmffType, amRead, amRead, amRead, amNone }, {ImageType::bmff, newBmffInstance, isBmffType, amRead, amRead, amRead, amNone},
#endif // EXV_ENABLE_BMFF #endif // EXV_ENABLE_BMFF
// End of list marker // End of list marker
{ ImageType::none, nullptr, nullptr, amNone, amNone, amNone, amNone } {ImageType::none, nullptr, nullptr, amNone, amNone, amNone, amNone},
}; };
std::string pathOfFileUrl(const std::string& url) { std::string pathOfFileUrl(const std::string& url) {

@ -18,11 +18,11 @@
#include <iostream> #include <iostream>
// JPEG-2000 box types // JPEG-2000 box types
const uint32_t kJp2BoxTypeJp2Header = 0x6a703268; // 'jp2h' static constexpr uint32_t kJp2BoxTypeJp2Header = 0x6a703268; // 'jp2h'
const uint32_t kJp2BoxTypeImageHeader = 0x69686472; // 'ihdr' static constexpr uint32_t kJp2BoxTypeImageHeader = 0x69686472; // 'ihdr'
const uint32_t kJp2BoxTypeColorHeader = 0x636f6c72; // 'colr' static constexpr uint32_t kJp2BoxTypeColorHeader = 0x636f6c72; // 'colr'
const uint32_t kJp2BoxTypeUuid = 0x75756964; // 'uuid' static constexpr uint32_t kJp2BoxTypeUuid = 0x75756964; // 'uuid'
const uint32_t kJp2BoxTypeClose = 0x6a703263; // 'jp2c' static constexpr uint32_t kJp2BoxTypeClose = 0x6a703263; // 'jp2c'
// from openjpeg-2.1.2/src/lib/openjp2/jp2.h // from openjpeg-2.1.2/src/lib/openjp2/jp2.h
/*#define JPIP_JPIP 0x6a706970*/ /*#define JPIP_JPIP 0x6a706970*/
@ -53,30 +53,31 @@ const uint32_t kJp2BoxTypeClose = 0x6a703263; // 'jp2c'
// //
// See http://www.jpeg.org/public/wg1n2600.doc for information about embedding IPTC-NAA data in JPEG-2000 files // See http://www.jpeg.org/public/wg1n2600.doc for information about embedding IPTC-NAA data in JPEG-2000 files
// See http://www.adobe.com/devnet/xmp/pdfs/xmp_specification.pdf for information about embedding XMP data in JPEG-2000 files // See http://www.adobe.com/devnet/xmp/pdfs/xmp_specification.pdf for information about embedding XMP data in JPEG-2000 files
const unsigned char kJp2UuidExif[] = "JpgTiffExif->JP2"; static constexpr unsigned char kJp2UuidExif[] = "JpgTiffExif->JP2";
const unsigned char kJp2UuidIptc[] = "\x33\xc7\xa4\xd2\xb8\x1d\x47\x23\xa0\xba\xf1\xa3\xe0\x97\xad\x38"; static constexpr unsigned char kJp2UuidIptc[] = "\x33\xc7\xa4\xd2\xb8\x1d\x47\x23\xa0\xba\xf1\xa3\xe0\x97\xad\x38";
const unsigned char kJp2UuidXmp[] = "\xbe\x7a\xcf\xcb\x97\xa9\x42\xe8\x9c\x71\x99\x94\x91\xe3\xaf\xac"; static constexpr unsigned char kJp2UuidXmp[] = "\xbe\x7a\xcf\xcb\x97\xa9\x42\xe8\x9c\x71\x99\x94\x91\xe3\xaf\xac";
// See section B.1.1 (JPEG 2000 Signature box) of JPEG-2000 specification // See section B.1.1 (JPEG 2000 Signature box) of JPEG-2000 specification
const unsigned char Jp2Signature[12] = { 0x00, 0x00, 0x00, 0x0c, 0x6a, 0x50, 0x20, 0x20, 0x0d, 0x0a, 0x87, 0x0a }; static constexpr unsigned char Jp2Signature[] = {
0x00, 0x00, 0x00, 0x0c, 0x6a, 0x50, 0x20, 0x20, 0x0d, 0x0a, 0x87, 0x0a,
const unsigned char Jp2Blank[] = { 0x00,0x00,0x00,0x0c,0x6a,0x50,0x20,0x20,0x0d,0x0a,0x87,0x0a,0x00,0x00,0x00,0x14, };
0x66,0x74,0x79,0x70,0x6a,0x70,0x32,0x20,0x00,0x00,0x00,0x00,0x6a,0x70,0x32,0x20,
0x00,0x00,0x00,0x2d,0x6a,0x70,0x32,0x68,0x00,0x00,0x00,0x16,0x69,0x68,0x64,0x72, static constexpr unsigned char Jp2Blank[] = {
0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x01,0x07,0x07,0x00,0x00,0x00,0x00, 0x00, 0x00, 0x00, 0x0c, 0x6a, 0x50, 0x20, 0x20, 0x0d, 0x0a, 0x87, 0x0a, 0x00, 0x00, 0x00, 0x14, 0x66, 0x74,
0x00,0x0f,0x63,0x6f,0x6c,0x72,0x01,0x00,0x00,0x00,0x00,0x00,0x11,0x00,0x00,0x00, 0x79, 0x70, 0x6a, 0x70, 0x32, 0x20, 0x00, 0x00, 0x00, 0x00, 0x6a, 0x70, 0x32, 0x20, 0x00, 0x00, 0x00, 0x2d,
0x00,0x6a,0x70,0x32,0x63,0xff,0x4f,0xff,0x51,0x00,0x29,0x00,0x00,0x00,0x00,0x00, 0x6a, 0x70, 0x32, 0x68, 0x00, 0x00, 0x00, 0x16, 0x69, 0x68, 0x64, 0x72, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00, 0x01, 0x00, 0x01, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x63, 0x6f, 0x6c, 0x72, 0x01, 0x00,
0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x07, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x6a, 0x70, 0x32, 0x63, 0xff, 0x4f, 0xff, 0x51, 0x00,
0x01,0x01,0xff,0x64,0x00,0x23,0x00,0x01,0x43,0x72,0x65,0x61,0x74,0x6f,0x72,0x3a, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x20,0x4a,0x61,0x73,0x50,0x65,0x72,0x20,0x56,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x31,0x2e,0x39,0x30,0x30,0x2e,0x31,0xff,0x52,0x00,0x0c,0x00,0x00,0x00,0x01,0x00, 0x01, 0x07, 0x01, 0x01, 0xff, 0x64, 0x00, 0x23, 0x00, 0x01, 0x43, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x3a,
0x05,0x04,0x04,0x00,0x01,0xff,0x5c,0x00,0x13,0x40,0x40,0x48,0x48,0x50,0x48,0x48, 0x20, 0x4a, 0x61, 0x73, 0x50, 0x65, 0x72, 0x20, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x31, 0x2e,
0x50,0x48,0x48,0x50,0x48,0x48,0x50,0x48,0x48,0x50,0xff,0x90,0x00,0x0a,0x00,0x00, 0x39, 0x30, 0x30, 0x2e, 0x31, 0xff, 0x52, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x05, 0x04, 0x04, 0x00,
0x00,0x00,0x00,0x2d,0x00,0x01,0xff,0x5d,0x00,0x14,0x00,0x40,0x40,0x00,0x00,0x00, 0x01, 0xff, 0x5c, 0x00, 0x13, 0x40, 0x40, 0x48, 0x48, 0x50, 0x48, 0x48, 0x50, 0x48, 0x48, 0x50, 0x48, 0x48,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x93,0xcf,0xb4, 0x50, 0x48, 0x48, 0x50, 0xff, 0x90, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x01, 0xff, 0x5d,
0x04,0x00,0x80,0x80,0x80,0x80,0x80,0xff,0xd9 0x00, 0x14, 0x00, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
}; 0x00, 0x00, 0xff, 0x93, 0xcf, 0xb4, 0x04, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0xff, 0xd9,
};
//! @cond IGNORE //! @cond IGNORE
struct Jp2BoxHeader struct Jp2BoxHeader

@ -1243,9 +1243,6 @@ namespace Exiv2 {
return result; return result;
} }
const char ExvImage::exiv2Id_[] = "Exiv2";
const byte ExvImage::blank_[] = { 0xff,0x01,'E','x','i','v','2',0xff,0xd9 };
ExvImage::ExvImage(BasicIo::UniquePtr io, bool create) ExvImage::ExvImage(BasicIo::UniquePtr io, bool create)
: JpegBase(ImageType::exv, std::move(io), create, blank_, sizeof(blank_)) : JpegBase(ImageType::exv, std::move(io), create, blank_, sizeof(blank_))
{ {

@ -1132,12 +1132,12 @@ namespace Exiv2::Internal {
} }
int sony2010eSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/, TiffComponent* const pRoot) int sony2010eSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/, TiffComponent* const pRoot)
{ {
static constexpr const char* models[] = { static constexpr auto models = std::array{
"SLT-A58", "SLT-A99", "ILCE-3000", "ILCE-3500", "NEX-3N", "NEX-5R", "NEX-5T", "SLT-A58", "SLT-A99", "ILCE-3000", "ILCE-3500", "NEX-3N", "NEX-5R", "NEX-5T",
"NEX-6", "VG30E", "VG900", "DSC-RX100", "DSC-RX1", "DSC-RX1R", "DSC-HX300", "NEX-6", "VG30E", "VG900", "DSC-RX100", "DSC-RX1", "DSC-RX1R", "DSC-HX300",
"DSC-HX50V", "DSC-TX30", "DSC-WX60", "DSC-WX200", "DSC-WX300", "DSC-HX50V", "DSC-TX30", "DSC-WX60", "DSC-WX200", "DSC-WX300",
}; };
return std::find(std::begin(models), std::end(models), getExifModel(pRoot)) != std::end(models) ? 0 : -1; return std::find(models.begin(), models.end(), getExifModel(pRoot)) != std::end(models) ? 0 : -1;
} }
int sony2FpSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/, TiffComponent* const pRoot) int sony2FpSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/, TiffComponent* const pRoot)

@ -8,6 +8,7 @@
#include "exif.hpp" #include "exif.hpp"
#include "i18n.h" // NLS support. #include "i18n.h" // NLS support.
#include <array>
#include <sstream> #include <sstream>
#include <cstdio> // popen to call exiftool #include <cstdio> // popen to call exiftool
@ -2137,7 +2138,7 @@ namespace Exiv2::Internal {
std::string maxAperture = getKeyString("Exif.Photo.MaxApertureValue" ,metadata); std::string maxAperture = getKeyString("Exif.Photo.MaxApertureValue" ,metadata);
std::string F1_8 = "434/256" ; std::string F1_8 = "434/256" ;
static constexpr const char* maxApertures[] = { static constexpr auto maxApertures = std::array{
"926/256", // F3.5 "926/256", // F3.5
"1024/256", // F4 "1024/256", // F4
"1110/256", // F4.5 "1110/256", // F4.5
@ -2155,7 +2156,7 @@ namespace Exiv2::Internal {
} catch (...) {} } catch (...) {}
if (model == "ILCE-6000" && if (model == "ILCE-6000" &&
std::find(std::begin(maxApertures), std::end(maxApertures), maxAperture) != std::end(maxApertures)) std::find(maxApertures.begin(), maxApertures.end(), maxAperture) != maxApertures.end())
try { try {
long focalLength = getKeyLong("Exif.Photo.FocalLength", metadata); long focalLength = getKeyLong("Exif.Photo.FocalLength", metadata);
if (focalLength > 0) { if (focalLength > 0) {

@ -10,6 +10,7 @@
#include "value.hpp" #include "value.hpp"
// + standard includes // + standard includes
#include <array>
#include <cmath> #include <cmath>
// ***************************************************************************** // *****************************************************************************
@ -2640,14 +2641,9 @@ if (!metadata) {
byte raw[] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }; byte raw[] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };
static const char* tags[] = { static constexpr auto tags = std::array{
"LensIDNumber", "LensIDNumber", "LensFStops", "MinFocalLength", "MaxFocalLength", "MaxApertureAtMinFocal",
"LensFStops", "MaxApertureAtMaxFocal", "MCUVersion",
"MinFocalLength",
"MaxFocalLength",
"MaxApertureAtMinFocal",
"MaxApertureAtMaxFocal",
"MCUVersion"
}; };
const std::string pre = std::string("Exif.") + group + std::string("."); const std::string pre = std::string("Exif.") + group + std::string(".");

@ -20,20 +20,21 @@
#include <iostream> #include <iostream>
// Signature from front of PNG file namespace {
const unsigned char pngSignature[8] = { 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A }; // Signature from front of PNG file
constexpr unsigned char pngSignature[] = {
const unsigned char pngBlank[] = { 0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52, 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A,
0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x08,0x02,0x00,0x00,0x00,0x90,0x77,0x53, };
0xde,0x00,0x00,0x00,0x01,0x73,0x52,0x47,0x42,0x00,0xae,0xce,0x1c,0xe9,0x00,0x00,
0x00,0x09,0x70,0x48,0x59,0x73,0x00,0x00,0x0b,0x13,0x00,0x00,0x0b,0x13,0x01,0x00, constexpr unsigned char pngBlank[] = {
0x9a,0x9c,0x18,0x00,0x00,0x00,0x0c,0x49,0x44,0x41,0x54,0x08,0xd7,0x63,0xf8,0xff, 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00,
0xff,0x3f,0x00,0x05,0xfe,0x02,0xfe,0xdc,0xcc,0x59,0xe7,0x00,0x00,0x00,0x00,0x49, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x02, 0x00, 0x00, 0x00, 0x90, 0x77, 0x53, 0xde, 0x00, 0x00, 0x00,
0x45,0x4e,0x44,0xae,0x42,0x60,0x82 0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xae, 0xce, 0x1c, 0xe9, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73,
0x00, 0x00, 0x0b, 0x13, 0x00, 0x00, 0x0b, 0x13, 0x01, 0x00, 0x9a, 0x9c, 0x18, 0x00, 0x00, 0x00, 0x0c, 0x49,
0x44, 0x41, 0x54, 0x08, 0xd7, 0x63, 0xf8, 0xff, 0xff, 0x3f, 0x00, 0x05, 0xfe, 0x02, 0xfe, 0xdc, 0xcc, 0x59,
0xe7, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82,
}; };
namespace
{
const auto nullComp = reinterpret_cast<const Exiv2::byte*>("\0\0"); const auto nullComp = reinterpret_cast<const Exiv2::byte*>("\0\0");
const auto typeICCP = reinterpret_cast<const Exiv2::byte*>("iCCP"); const auto typeICCP = reinterpret_cast<const Exiv2::byte*>("iCCP");
inline bool compare(const char* str, const Exiv2::DataBuf& buf, size_t length) inline bool compare(const char* str, const Exiv2::DataBuf& buf, size_t length)

@ -13,6 +13,7 @@
#include "tiffimage_int.hpp" #include "tiffimage_int.hpp"
// + standard includes // + standard includes
#include <array>
#ifdef EXIV2_DEBUG_MESSAGES #ifdef EXIV2_DEBUG_MESSAGES
#include <iostream> #include <iostream>
#endif #endif
@ -143,7 +144,7 @@ namespace Exiv2 {
} }
} }
// Remove tags not applicable for raw images // Remove tags not applicable for raw images
static const char* filteredTags[] = { static constexpr auto filteredTags = std::array{
"Exif.Photo.ComponentsConfiguration", "Exif.Photo.ComponentsConfiguration",
"Exif.Photo.CompressedBitsPerPixel", "Exif.Photo.CompressedBitsPerPixel",
"Exif.Panasonic.ColorEffect", "Exif.Panasonic.ColorEffect",
@ -171,7 +172,7 @@ namespace Exiv2 {
"Exif.Photo.Saturation", "Exif.Photo.Saturation",
"Exif.Photo.Sharpness", "Exif.Photo.Sharpness",
"Exif.Image.PrintImageMatching", "Exif.Image.PrintImageMatching",
"Exif.Image.YCbCrPositioning" "Exif.Image.YCbCrPositioning",
}; };
for (auto&& filteredTag : filteredTags) { for (auto&& filteredTag : filteredTags) {
auto pos = prevData.findKey(ExifKey(filteredTag)); auto pos = prevData.findKey(ExifKey(filteredTag));

@ -9,6 +9,7 @@
#include "tiffcomposite_int.hpp" #include "tiffcomposite_int.hpp"
#include "value.hpp" #include "value.hpp"
#include <array>
#include <cmath> #include <cmath>
// ***************************************************************************** // *****************************************************************************
@ -1118,12 +1119,12 @@ namespace Exiv2::Internal {
return os << "(" << value << ")"; return os << "(" << value << ")";
// Models that support this tag // Models that support this tag
static constexpr const char* models[] = { "ILCA-68", "ILCA-77M2", "ILCA-99M2", static constexpr auto models = std::array{
"ILCE-5000", "ILCE-5100", "ILCE-6000", "ILCE-6300", "ILCE-6500", "ILCE-7", "ILCA-68", "ILCA-77M2", "ILCA-99M2", "ILCE-5000", "ILCE-5100", "ILCE-6000", "ILCE-6300",
"ILCE-7M2", "ILCE-7R", "ILCE-7RM2", "ILCE-7S", "ILCE-7SM2", "ILCE-QX1", "ILCE-6500", "ILCE-7", "ILCE-7M2", "ILCE-7R", "ILCE-7RM2", "ILCE-7S", "ILCE-7SM2",
"DSC-HX350", "DSC-HX400V", "DSC-HX60V", "DSC-HX80", "DSC-HX90", "DSC-HX90V", "ILCE-QX1", "DSC-HX350", "DSC-HX400V", "DSC-HX60V", "DSC-HX80", "DSC-HX90", "DSC-HX90V",
"DSC-QX30", "DSC-RX0", "DSC-RX1RM2", "DSC-RX10", "DSC-RX10M2", "DSC-RX10M3", "DSC-QX30", "DSC-RX0", "DSC-RX1RM2", "DSC-RX10", "DSC-RX10M2", "DSC-RX10M3", "DSC-RX100M3",
"DSC-RX100M3", "DSC-RX100M4", "DSC-RX100M5", "DSC-WX220", "DSC-WX350", "DSC-WX500" "DSC-RX100M4", "DSC-RX100M5", "DSC-WX220", "DSC-WX350", "DSC-WX500",
}; };
std::string model = pos->toString(); std::string model = pos->toString();

@ -11,6 +11,8 @@
#include "tags_int.hpp" #include "tags_int.hpp"
#include "types.hpp" #include "types.hpp"
#include <array>
// ***************************************************************************** // *****************************************************************************
// class member definitions // class member definitions
namespace Exiv2 { namespace Exiv2 {
@ -19,29 +21,29 @@ namespace Exiv2 {
//! List of all defined Exif sections. //! List of all defined Exif sections.
constexpr SectionInfo sectionInfo[] = { constexpr auto sectionInfo = std::array{
{ sectionIdNotSet, "(UnknownSection)", N_("Unknown section") }, SectionInfo{sectionIdNotSet, "(UnknownSection)", N_("Unknown section")},
{ imgStruct, "ImageStructure", N_("Image data structure") }, SectionInfo{imgStruct, "ImageStructure", N_("Image data structure")},
{ recOffset, "RecordingOffset", N_("Recording offset") }, SectionInfo{recOffset, "RecordingOffset", N_("Recording offset")},
{ imgCharacter, "ImageCharacteristics", N_("Image data characteristics") }, SectionInfo{imgCharacter, "ImageCharacteristics", N_("Image data characteristics")},
{ otherTags, "OtherTags", N_("Other data") }, SectionInfo{otherTags, "OtherTags", N_("Other data")},
{ exifFormat, "ExifFormat", N_("Exif data structure") }, SectionInfo{exifFormat, "ExifFormat", N_("Exif data structure")},
{ exifVersion, "ExifVersion", N_("Exif version") }, SectionInfo{exifVersion, "ExifVersion", N_("Exif version")},
{ imgConfig, "ImageConfig", N_("Image configuration") }, SectionInfo{imgConfig, "ImageConfig", N_("Image configuration")},
{ userInfo, "UserInfo", N_("User information") }, SectionInfo{userInfo, "UserInfo", N_("User information")},
{ relatedFile, "RelatedFile", N_("Related file") }, SectionInfo{relatedFile, "RelatedFile", N_("Related file")},
{ dateTime, "DateTime", N_("Date and time") }, SectionInfo{dateTime, "DateTime", N_("Date and time")},
{ captureCond, "CaptureConditions", N_("Picture taking conditions") }, SectionInfo{captureCond, "CaptureConditions", N_("Picture taking conditions")},
{ gpsTags, "GPS", N_("GPS information") }, SectionInfo{gpsTags, "GPS", N_("GPS information")},
{ iopTags, "Interoperability", N_("Interoperability information") }, SectionInfo{iopTags, "Interoperability", N_("Interoperability information")},
{ mpfTags, "MPF", N_("CIPA Multi-Picture Format") }, SectionInfo{mpfTags, "MPF", N_("CIPA Multi-Picture Format")},
{ makerTags, "Makernote", N_("Vendor specific information") }, SectionInfo{makerTags, "Makernote", N_("Vendor specific information")},
{ dngTags, "DngTags", N_("Adobe DNG tags") }, SectionInfo{dngTags, "DngTags", N_("Adobe DNG tags")},
{ panaRaw, "PanasonicRaw", N_("Panasonic RAW tags") }, SectionInfo{panaRaw, "PanasonicRaw", N_("Panasonic RAW tags")},
{ tiffEp, "TIFF/EP", N_("TIFF/EP tags") }, SectionInfo{tiffEp, "TIFF/EP", N_("TIFF/EP tags")},
{ tiffPm6, "TIFF&PM6", N_("TIFF PageMaker 6.0 tags") }, SectionInfo{tiffPm6, "TIFF&PM6", N_("TIFF PageMaker 6.0 tags")},
{ adobeOpi, "AdobeOPI", N_("Adobe OPI tags") }, SectionInfo{adobeOpi, "AdobeOPI", N_("Adobe OPI tags")},
{ lastSectionId, "(LastSection)", N_("Last section") } SectionInfo{lastSectionId, "(LastSection)", N_("Last section")},
}; };
} // namespace Exiv2 } // namespace Exiv2

@ -12,6 +12,7 @@
#include "tiffimage_int.hpp" #include "tiffimage_int.hpp"
#include "types.hpp" #include "types.hpp"
#include <array>
#include <iostream> #include <iostream>
/* -------------------------------------------------------------------------- /* --------------------------------------------------------------------------
@ -54,10 +55,10 @@ namespace Exiv2 {
}; };
//! List of TIFF compression to MIME type mappings //! List of TIFF compression to MIME type mappings
constexpr MimeTypeList mimeTypeList[] = { constexpr auto mimeTypeList = std::array{
{32770, "image/x-samsung-srw"}, MimeTypeList{32770, "image/x-samsung-srw"},
{34713, "image/x-nikon-nef"}, MimeTypeList{34713, "image/x-nikon-nef"},
{65535, "image/x-pentax-pef"}, MimeTypeList{65535, "image/x-pentax-pef"},
}; };
std::string TiffImage::mimeType() const std::string TiffImage::mimeType() const
@ -68,8 +69,9 @@ namespace Exiv2 {
std::string key = "Exif." + primaryGroup() + ".Compression"; std::string key = "Exif." + primaryGroup() + ".Compression";
auto md = exifData_.findKey(ExifKey(key)); auto md = exifData_.findKey(ExifKey(key));
if (md != exifData_.end() && md->count() > 0) { if (md != exifData_.end() && md->count() > 0) {
const MimeTypeList* i = find(mimeTypeList, static_cast<int>(md->toInt64())); auto i = std::find(mimeTypeList.begin(), mimeTypeList.end(), static_cast<int>(md->toInt64()));
if (i) mimeType_ = std::string(i->mimeType_); if (i != mimeTypeList.end())
mimeType_ = std::string(i->mimeType_);
} }
return mimeType_; return mimeType_;
} }
@ -78,17 +80,11 @@ namespace Exiv2 {
{ {
if (!primaryGroup_.empty()) return primaryGroup_; if (!primaryGroup_.empty()) return primaryGroup_;
static const char* keys[] = { static constexpr auto keys = std::array{
"Exif.Image.NewSubfileType", "Exif.Image.NewSubfileType", "Exif.SubImage1.NewSubfileType", "Exif.SubImage2.NewSubfileType",
"Exif.SubImage1.NewSubfileType", "Exif.SubImage3.NewSubfileType", "Exif.SubImage4.NewSubfileType", "Exif.SubImage5.NewSubfileType",
"Exif.SubImage2.NewSubfileType", "Exif.SubImage6.NewSubfileType", "Exif.SubImage7.NewSubfileType", "Exif.SubImage8.NewSubfileType",
"Exif.SubImage3.NewSubfileType", "Exif.SubImage9.NewSubfileType",
"Exif.SubImage4.NewSubfileType",
"Exif.SubImage5.NewSubfileType",
"Exif.SubImage6.NewSubfileType",
"Exif.SubImage7.NewSubfileType",
"Exif.SubImage8.NewSubfileType",
"Exif.SubImage9.NewSubfileType"
}; };
// Find the group of the primary image, default to "Image" // Find the group of the primary image, default to "Image"
primaryGroup_ = std::string("Image"); primaryGroup_ = std::string("Image");
@ -250,8 +246,8 @@ namespace Exiv2 {
ExifData ed = exifData; ExifData ed = exifData;
// Delete IFDs which do not occur in TIFF images // Delete IFDs which do not occur in TIFF images
static const IfdId filteredIfds[] = { static constexpr auto filteredIfds = std::array{
panaRawId panaRawId,
}; };
for (auto&& filteredIfd : filteredIfds) { for (auto&& filteredIfd : filteredIfds) {
#ifdef EXIV2_DEBUG_MESSAGES #ifdef EXIV2_DEBUG_MESSAGES

@ -8,6 +8,7 @@
#include "tiffvisitor_int.hpp" #include "tiffvisitor_int.hpp"
#include "i18n.h" // NLS support. #include "i18n.h" // NLS support.
#include <array>
#include <iostream> #include <iostream>
// Shortcuts for the newTiffBinaryArray templates. // Shortcuts for the newTiffBinaryArray templates.
@ -2159,20 +2160,9 @@ namespace Exiv2::Internal {
if (!pSourceDir) if (!pSourceDir)
return; return;
const IfdId imageGroups[] = { static constexpr auto imageGroups = std::array{
ifd0Id, ifd0Id, ifd1Id, ifd2Id, ifd3Id, subImage1Id, subImage2Id, subImage3Id,
ifd1Id, subImage4Id, subImage5Id, subImage6Id, subImage7Id, subImage8Id, subImage9Id,
ifd2Id,
ifd3Id,
subImage1Id,
subImage2Id,
subImage3Id,
subImage4Id,
subImage5Id,
subImage6Id,
subImage7Id,
subImage8Id,
subImage9Id
}; };
for (auto&& imageGroup : imageGroups) { for (auto&& imageGroup : imageGroups) {

@ -441,27 +441,27 @@ namespace Exiv2::Internal {
const uint16_t nMasks = (nPoints+15)/(sizeof(uint16_t) * 8); const uint16_t nMasks = (nPoints+15)/(sizeof(uint16_t) * 8);
int nStart = 0; int nStart = 0;
/// \todo make this static static const struct
struct { {
uint16_t tag ; uint16_t tag ;
uint16_t size ; uint16_t size ;
bool bSigned; bool bSigned;
} records[] = { } records[] = {
{ 0x2600 , 1 , true }, // AFInfoSize {0x2600, 1, true}, // AFInfoSize
{ 0x2601 , 1 , true }, // AFAreaMode {0x2601, 1, true}, // AFAreaMode
{ 0x2602 , 1 , true }, // AFNumPoints {0x2602, 1, true}, // AFNumPoints
{ 0x2603 , 1 , true }, // AFValidPoints {0x2603, 1, true}, // AFValidPoints
{ 0x2604 , 1 , true }, // AFCanonImageWidth {0x2604, 1, true}, // AFCanonImageWidth
{ 0x2605 , 1 , true }, // AFCanonImageHeight {0x2605, 1, true}, // AFCanonImageHeight
{ 0x2606 , 1 , true }, // AFImageWidth" {0x2606, 1, true}, // AFImageWidth"
{ 0x2607 , 1 , true }, // AFImageHeight {0x2607, 1, true}, // AFImageHeight
{ 0x2608 , nPoints , true }, // AFAreaWidths {0x2608, nPoints, true}, // AFAreaWidths
{ 0x2609 , nPoints , true }, // AFAreaHeights {0x2609, nPoints, true}, // AFAreaHeights
{ 0x260a , nPoints , true }, // AFXPositions {0x260a, nPoints, true}, // AFXPositions
{ 0x260b , nPoints , true }, // AFYPositions {0x260b, nPoints, true}, // AFYPositions
{ 0x260c , nMasks , false }, // AFPointsInFocus {0x260c, nMasks, false}, // AFPointsInFocus
{ 0x260d , nMasks , false }, // AFPointsSelected {0x260d, nMasks, false}, // AFPointsSelected
{ 0x260e , nMasks , false }, // AFPointsUnusable {0x260e, nMasks, false}, // AFPointsUnusable
}; };
// check we have enough data! // check we have enough data!
uint16_t count = 0; uint16_t count = 0;

@ -9,6 +9,7 @@
#include "safe_op.hpp" #include "safe_op.hpp"
// + standard includes // + standard includes
#include <array>
#include <cassert> #include <cassert>
#include <cctype> #include <cctype>
#include <climits> #include <climits>
@ -39,31 +40,31 @@ namespace {
}; // struct TypeInfoTable }; // struct TypeInfoTable
//! Lookup list with information of Exiv2 types //! Lookup list with information of Exiv2 types
const TypeInfoTable typeInfoTable[] = { constexpr auto typeInfoTable = std::array{
{ Exiv2::invalidTypeId, "Invalid", 0 }, TypeInfoTable{Exiv2::invalidTypeId, "Invalid", 0},
{ Exiv2::unsignedByte, "Byte", 1 }, TypeInfoTable{Exiv2::unsignedByte, "Byte", 1},
{ Exiv2::asciiString, "Ascii", 1 }, TypeInfoTable{Exiv2::asciiString, "Ascii", 1},
{ Exiv2::unsignedShort, "Short", 2 }, TypeInfoTable{Exiv2::unsignedShort, "Short", 2},
{ Exiv2::unsignedLong, "Long", 4 }, TypeInfoTable{Exiv2::unsignedLong, "Long", 4},
{ Exiv2::unsignedRational, "Rational", 8 }, TypeInfoTable{Exiv2::unsignedRational, "Rational", 8},
{ Exiv2::signedByte, "SByte", 1 }, TypeInfoTable{Exiv2::signedByte, "SByte", 1},
{ Exiv2::undefined, "Undefined", 1 }, TypeInfoTable{Exiv2::undefined, "Undefined", 1},
{ Exiv2::signedShort, "SShort", 2 }, TypeInfoTable{Exiv2::signedShort, "SShort", 2},
{ Exiv2::signedLong, "SLong", 4 }, TypeInfoTable{Exiv2::signedLong, "SLong", 4},
{ Exiv2::signedRational, "SRational", 8 }, TypeInfoTable{Exiv2::signedRational, "SRational", 8},
{ Exiv2::tiffFloat, "Float", 4 }, TypeInfoTable{Exiv2::tiffFloat, "Float", 4},
{ Exiv2::tiffDouble, "Double", 8 }, TypeInfoTable{Exiv2::tiffDouble, "Double", 8},
{ Exiv2::tiffIfd, "Ifd", 4 }, TypeInfoTable{Exiv2::tiffIfd, "Ifd", 4},
{ Exiv2::string, "String", 1 }, TypeInfoTable{Exiv2::string, "String", 1},
{ Exiv2::date, "Date", 8 }, TypeInfoTable{Exiv2::date, "Date", 8},
{ Exiv2::time, "Time", 11 }, TypeInfoTable{Exiv2::time, "Time", 11},
{ Exiv2::comment, "Comment", 1 }, TypeInfoTable{Exiv2::comment, "Comment", 1},
{ Exiv2::directory, "Directory", 1 }, TypeInfoTable{Exiv2::directory, "Directory", 1},
{ Exiv2::xmpText, "XmpText", 1 }, TypeInfoTable{Exiv2::xmpText, "XmpText", 1},
{ Exiv2::xmpAlt, "XmpAlt", 1 }, TypeInfoTable{Exiv2::xmpAlt, "XmpAlt", 1},
{ Exiv2::xmpBag, "XmpBag", 1 }, TypeInfoTable{Exiv2::xmpBag, "XmpBag", 1},
{ Exiv2::xmpSeq, "XmpSeq", 1 }, TypeInfoTable{Exiv2::xmpSeq, "XmpSeq", 1},
{ Exiv2::langAlt, "LangAlt", 1 } TypeInfoTable{Exiv2::langAlt, "LangAlt", 1},
}; };
} // namespace } // namespace
@ -74,23 +75,24 @@ namespace Exiv2 {
const char* TypeInfo::typeName(TypeId typeId) const char* TypeInfo::typeName(TypeId typeId)
{ {
const TypeInfoTable* tit = find(typeInfoTable, typeId); auto tit = std::find(typeInfoTable.begin(), typeInfoTable.end(), typeId);
if (!tit) if (tit == typeInfoTable.end())
return nullptr; return nullptr;
return tit->name_; return tit->name_;
} }
TypeId TypeInfo::typeId(const std::string& typeName) TypeId TypeInfo::typeId(const std::string& typeName)
{ {
const TypeInfoTable* tit = find(typeInfoTable, typeName); auto tit = std::find(typeInfoTable.begin(), typeInfoTable.end(), typeName);
if (!tit) return invalidTypeId; if (tit == typeInfoTable.end())
return invalidTypeId;
return tit->typeId_; return tit->typeId_;
} }
size_t TypeInfo::typeSize(TypeId typeId) size_t TypeInfo::typeSize(TypeId typeId)
{ {
const TypeInfoTable* tit = find(typeInfoTable, typeId); auto tit = std::find(typeInfoTable.begin(), typeInfoTable.end(), typeId);
if (!tit) if (tit == typeInfoTable.end())
return 0; return 0;
return tit->size_; return tit->size_;
} }

@ -343,21 +343,19 @@ namespace Exiv2 {
return os << value_.substr(0, pos); return os << value_.substr(0, pos);
} }
CommentValue::CharsetTable::CharsetTable(CharsetId charsetId, constexpr CommentValue::CharsetTable::CharsetTable(CharsetId charsetId, const char* name, const char* code)
const char* name,
const char* code)
: charsetId_(charsetId), name_(name), code_(code) : charsetId_(charsetId), name_(name), code_(code)
{ {
} }
//! Lookup list of supported IFD type information //! Lookup list of supported IFD type information
const CommentValue::CharsetTable CommentValue::CharsetInfo::charsetTable_[] = { constexpr CommentValue::CharsetTable CommentValue::CharsetInfo::charsetTable_[] = {
CharsetTable(ascii, "Ascii", "ASCII\0\0\0"), CharsetTable(ascii, "Ascii", "ASCII\0\0\0"),
CharsetTable(jis, "Jis", "JIS\0\0\0\0\0"), CharsetTable(jis, "Jis", "JIS\0\0\0\0\0"),
CharsetTable(unicode, "Unicode", "UNICODE\0"), CharsetTable(unicode, "Unicode", "UNICODE\0"),
CharsetTable(undefined, "Undefined", "\0\0\0\0\0\0\0\0"), CharsetTable(undefined, "Undefined", "\0\0\0\0\0\0\0\0"),
CharsetTable(invalidCharsetId, "InvalidCharsetId", "\0\0\0\0\0\0\0\0"), CharsetTable(invalidCharsetId, "InvalidCharsetId", "\0\0\0\0\0\0\0\0"),
CharsetTable(lastCharsetId, "InvalidCharsetId", "\0\0\0\0\0\0\0\0") CharsetTable(lastCharsetId, "InvalidCharsetId", "\0\0\0\0\0\0\0\0"),
}; };
const char* CommentValue::CharsetInfo::name(CharsetId charsetId) const char* CommentValue::CharsetInfo::name(CharsetId charsetId)
@ -914,7 +912,7 @@ namespace Exiv2 {
static const std::regex reBasic(R"(^(\d{4})(\d{2})(\d{2}))"); static const std::regex reBasic(R"(^(\d{4})(\d{2})(\d{2}))");
std::smatch sm; std::smatch sm;
auto printWarning = [](){ auto printWarning = [] {
#ifndef SUPPRESS_WARNINGS #ifndef SUPPRESS_WARNINGS
EXV_WARNING << Error(ErrorCode::kerUnsupportedDateFormat) << "\n"; EXV_WARNING << Error(ErrorCode::kerUnsupportedDateFormat) << "\n";
#endif #endif

@ -16,6 +16,7 @@
#endif #endif
// + standard includes // + standard includes
#include <array>
#include <fstream> #include <fstream>
#include <regex> #include <regex>
#include <set> #include <set>
@ -223,11 +224,14 @@ void Exiv2::dumpLibraryInfo(std::ostream& os,const std::vector<std::regex>& keys
// add edition in brackets // add edition in brackets
// 7.10 = 2003 8.00 = 2005 etc 12.00 = 2013 13.00 = 2015 (yet the installer labels it as 14.0!) // 7.10 = 2003 8.00 = 2005 etc 12.00 = 2013 13.00 = 2015 (yet the installer labels it as 14.0!)
size_t edition = (_MSC_VER-600)/100; size_t edition = (_MSC_VER-600)/100;
const char* editions[] = { "0","1","2","3","4","5","6","2003", "2005", "2008", "2010", "2012","2013","2015","2017","2019"}; constexpr auto editions = std::array{
"0", "1", "2", "3", "4", "5", "6", "2003", "2005", "2008", "2010", "2012", "2013", "2015", "2017", "2019",
};
if ( edition == 13 && _MSC_VER >= 1910 ) edition++ ; // 2017 _MSC_VAR == 1910 if ( edition == 13 && _MSC_VER >= 1910 ) edition++ ; // 2017 _MSC_VAR == 1910
if ( edition == 14 && _MSC_VER >= 1920 ) edition++ ; // 2019 _MSC_VAR == 1920 if ( edition == 14 && _MSC_VER >= 1920 ) edition++ ; // 2019 _MSC_VAR == 1920
if ( edition > lengthof(editions) ) edition = 0 ; if (edition > editions.size())
edition = 0;
if ( edition ) { if ( edition ) {
const size_t len = ::strlen(version); const size_t len = ::strlen(version);
snprintf(version+len, sizeof(version) - len, " (%s/%s)",editions[edition],bits==64?"x64":"x86"); snprintf(version+len, sizeof(version) - len, " (%s/%s)",editions[edition],bits==64?"x64":"x86");

Loading…
Cancel
Save