Merge pull request #2177 from neheb/1

clang-tidy and manual stuff
main
Luis Díaz Más 3 years ago committed by GitHub
commit 6e9eca445a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -262,7 +262,7 @@ class EXIV2API Error : public std::exception {
}
//! Virtual destructor. (Needed because of throw())
~Error() noexcept override;
~Error() noexcept override = default;
//@}
//! @name Accessors

@ -123,7 +123,7 @@ class Position {
virtual ~Position() = default;
// instance methods
bool good() const {
[[nodiscard]] bool good() const {
return time_ || lon_ || lat_ || ele_;
}
std::string getTimeString() {
@ -131,22 +131,22 @@ class Position {
times_ = getExifTime(time_);
return times_;
}
time_t getTime() const {
[[nodiscard]] time_t getTime() const {
return time_;
}
std::string toString() const;
[[nodiscard]] std::string toString() const;
// getters/setters
double lat() const {
[[nodiscard]] double lat() const {
return lat_;
}
double lon() const {
[[nodiscard]] double lon() const {
return lon_;
}
double ele() const {
[[nodiscard]] double ele() const {
return ele_;
}
int delta() const {
[[nodiscard]] int delta() const {
return delta_;
}
void delta(int delta) {

@ -25,16 +25,15 @@ int main() {
if (reader.ParseError() < 0) {
std::cerr << "Can't load '" << ini << "'" << std::endl;
return EXIT_FAILURE;
} else {
std::cout << "Config loaded from : '" << ini << "' "
<< "version=" << reader.GetInteger("protocol", "version", -1)
<< ", name=" << reader.Get("user", "name", "UNKNOWN")
<< ", email=" << reader.Get("user", "email", "UNKNOWN") << ", pi=" << reader.GetReal("user", "pi", -1)
<< ", active=" << reader.GetBoolean("user", "active", true) << std::endl;
std::cout << "169=" << reader.Get("canon", "169", "UNDEFINED")
<< ", 170=" << reader.Get("canon", "170", "UNDEFINED") << std::endl;
}
std::cout << "Config loaded from : '" << ini << "' "
<< "version=" << reader.GetInteger("protocol", "version", -1)
<< ", name=" << reader.Get("user", "name", "UNKNOWN")
<< ", email=" << reader.Get("user", "email", "UNKNOWN") << ", pi=" << reader.GetReal("user", "pi", -1)
<< ", active=" << reader.GetBoolean("user", "active", true) << std::endl;
std::cout << "169=" << reader.Get("canon", "169", "UNDEFINED") << ", 170=" << reader.Get("canon", "170", "UNDEFINED")
<< std::endl;
return EXIT_SUCCESS;
}

@ -619,19 +619,19 @@ class EXIV2API BlockMap {
size_ = num;
}
bool isNone() const {
[[nodiscard]] bool isNone() const {
return type_ == bNone;
}
bool isKnown() const {
[[nodiscard]] bool isKnown() const {
return type_ == bKnown;
}
byte* getData() const {
[[nodiscard]] byte* getData() const {
return data_;
}
size_t getSize() const {
[[nodiscard]] size_t getSize() const {
return size_;
}
@ -1525,7 +1525,7 @@ HttpIo::HttpIo(const std::string& url, size_t blockSize) {
class CurlIo::CurlImpl : public Impl {
public:
//! Constructor
CurlImpl(const std::string& path, size_t blockSize);
CurlImpl(const std::string& url, size_t blockSize);
//! Destructor. Cleans up the curl pointer and releases all managed memory.
~CurlImpl() override;

@ -527,7 +527,7 @@ void BmffImage::parseXmp(uint64_t length, uint64_t start) {
long restore = io_->tell();
io_->seek(static_cast<long>(start), BasicIo::beg);
size_t lengthSizeT = static_cast<size_t>(length);
auto lengthSizeT = static_cast<size_t>(length);
DataBuf xmp(lengthSizeT + 1);
xmp.write_uint8(lengthSizeT, 0); // ensure xmp is null terminated!
if (io_->read(xmp.data(), lengthSizeT) != lengthSizeT)

@ -26,8 +26,8 @@
#endif
#ifdef EXV_HAVE_ICONV
#include <errno.h>
#include <iconv.h>
#include <cerrno>
#endif
// Adobe XMP Toolkit
@ -262,7 +262,7 @@ class Converter {
//! @name Accessors
//@{
//! Get the value of the erase flag, see also setErase(bool on).
bool erase() const {
[[nodiscard]] bool erase() const {
return erase_;
}
//@}
@ -1527,7 +1527,7 @@ bool asciiToUtf8(std::string& /*str*/) {
return true;
}
using ConvFct = bool (*)(std::string& str);
using ConvFct = std::function<bool(std::string&)>;
struct ConvFctList {
bool operator==(const std::pair<const char*, const char*>& fromTo) const {

@ -17,7 +17,6 @@
// *****************************************************************************
// class member definitions
namespace Exiv2 {
using namespace Internal;
Cr2Image::Cr2Image(BasicIo::UniquePtr io, bool /*create*/) :
Image(ImageType::cr2, mdExif | mdIptc | mdXmp, std::move(io)) {
@ -87,7 +86,7 @@ void Cr2Image::writeMetadata() {
if (isCr2Type(*io_, false)) {
pData = io_->mmap(true);
size = io_->size();
Cr2Header cr2Header;
Internal::Cr2Header cr2Header;
if (0 == cr2Header.read(pData, 16)) {
bo = cr2Header.byteOrder();
}
@ -101,9 +100,9 @@ void Cr2Image::writeMetadata() {
} // Cr2Image::writeMetadata
ByteOrder Cr2Parser::decode(ExifData& exifData, IptcData& iptcData, XmpData& xmpData, const byte* pData, size_t size) {
Cr2Header cr2Header;
return TiffParserWorker::decode(exifData, iptcData, xmpData, pData, size, Tag::root, TiffMapping::findDecoder,
&cr2Header);
Internal::Cr2Header cr2Header;
return Internal::TiffParserWorker::decode(exifData, iptcData, xmpData, pData, size, Internal::Tag::root,
Internal::TiffMapping::findDecoder, &cr2Header);
}
WriteMethod Cr2Parser::encode(BasicIo& io, const byte* pData, size_t size, ByteOrder byteOrder,
@ -113,20 +112,20 @@ WriteMethod Cr2Parser::encode(BasicIo& io, const byte* pData, size_t size, ByteO
// Delete IFDs which do not occur in TIFF images
static constexpr auto filteredIfds = std::array{
panaRawId,
Internal::panaRawId,
};
for (auto&& filteredIfd : filteredIfds) {
#ifdef EXIV2_DEBUG_MESSAGES
std::cerr << "Warning: Exif IFD " << filteredIfd << " not encoded\n";
#endif
ed.erase(std::remove_if(ed.begin(), ed.end(), FindExifdatum(filteredIfd)), ed.end());
ed.erase(std::remove_if(ed.begin(), ed.end(), Internal::FindExifdatum(filteredIfd)), ed.end());
}
Cr2Header header(byteOrder);
OffsetWriter offsetWriter;
offsetWriter.setOrigin(OffsetWriter::cr2RawIfdOffset, Cr2Header::offset2addr(), byteOrder);
return TiffParserWorker::encode(io, pData, size, ed, iptcData, xmpData, Tag::root, TiffMapping::findEncoder, &header,
&offsetWriter);
auto header = Internal::Cr2Header(byteOrder);
Internal::OffsetWriter offsetWriter;
offsetWriter.setOrigin(Internal::OffsetWriter::cr2RawIfdOffset, Internal::Cr2Header::offset2addr(), byteOrder);
return Internal::TiffParserWorker::encode(io, pData, size, ed, iptcData, xmpData, Internal::Tag::root,
Internal::TiffMapping::findEncoder, &header, &offsetWriter);
}
// *************************************************************************
@ -146,7 +145,7 @@ bool isCr2Type(BasicIo& iIo, bool advance) {
if (iIo.error() || iIo.eof()) {
return false;
}
Cr2Header header;
Internal::Cr2Header header;
bool rc = header.read(buf, len);
if (!advance || !rc) {
iIo.seek(-len, BasicIo::cur);

@ -18,7 +18,6 @@
// *****************************************************************************
// class member definitions
namespace Exiv2 {
using namespace Internal;
CrwImage::CrwImage(BasicIo::UniquePtr io, bool /*create*/) : Image(ImageType::crw, mdExif | mdComment, std::move(io)) {
} // CrwImage::CrwImage
@ -102,12 +101,12 @@ void CrwImage::writeMetadata() {
void CrwParser::decode(CrwImage* pCrwImage, const byte* pData, size_t size) {
// Parse the image, starting with a CIFF header component
CiffHeader header;
Internal::CiffHeader header;
header.read(pData, size);
header.decode(*pCrwImage);
// a hack to get absolute offset of preview image inside CRW structure
CiffComponent* preview = header.findComponent(0x2007, 0x0000);
auto preview = header.findComponent(0x2007, 0x0000);
if (preview) {
(pCrwImage->exifData())["Exif.Image2.JPEGInterchangeFormat"] = uint32_t(preview->pData() - pData);
(pCrwImage->exifData())["Exif.Image2.JPEGInterchangeFormatLength"] = static_cast<uint32_t>(preview->size());
@ -116,14 +115,14 @@ void CrwParser::decode(CrwImage* pCrwImage, const byte* pData, size_t size) {
void CrwParser::encode(Blob& blob, const byte* pData, size_t size, const CrwImage* pCrwImage) {
// Parse image, starting with a CIFF header component
CiffHeader header;
Internal::CiffHeader header;
if (size != 0) {
header.read(pData, size);
}
// Encode Exif tags from image into the CRW parse tree and write the
// structure to the binary image blob
CrwMap::encode(&header, *pCrwImage);
Internal::CrwMap::encode(&header, *pCrwImage);
header.write(blob);
}
@ -147,7 +146,7 @@ bool isCrwType(BasicIo& iIo, bool advance) {
if (!(('I' == tmpBuf[0] && 'I' == tmpBuf[1]) || ('M' == tmpBuf[0] && 'M' == tmpBuf[1]))) {
result = false;
}
if (result && std::memcmp(tmpBuf + 6, CiffHeader::signature(), 8) != 0) {
if (result && std::memcmp(tmpBuf + 6, Internal::CiffHeader::signature(), 8) != 0) {
result = false;
}
if (!advance || !result)

@ -22,10 +22,7 @@ class RotationMap {
private:
//! Helper structure for the mapping list
struct OmList {
uint16_t orientation; //!< Exif orientation value
int32_t degrees; //!< CRW Rotation degrees
};
using OmList = std::pair<uint16_t, int32_t>;
// DATA
static const OmList omList_[];
}; // class RotationMap
@ -350,7 +347,7 @@ size_t CiffDirectory::doWrite(Blob& blob, ByteOrder byteOrder, size_t offset) {
for (auto&& component : components_) {
dirOffset = component->write(blob, byteOrder, dirOffset);
}
const uint32_t dirStart = static_cast<uint32_t>(dirOffset);
const auto dirStart = static_cast<uint32_t>(dirOffset);
// Number of directory entries
byte buf[4];
@ -520,7 +517,7 @@ CiffComponent* CiffDirectory::doFindComponent(uint16_t crwTagId, uint16_t crwDir
void CiffHeader::add(uint16_t crwTagId, uint16_t crwDir, DataBuf&& buf) {
CrwDirs crwDirs;
CrwMap::loadStack(crwDirs, crwDir);
[[maybe_unused]] uint16_t rootDirectory = crwDirs.top().crwDir_;
[[maybe_unused]] auto [rootDirectory, _] = crwDirs.top();
crwDirs.pop();
if (!pRootDir_) {
pRootDir_ = std::make_unique<CiffDirectory>();
@ -553,18 +550,18 @@ CiffComponent* CiffDirectory::doAdd(CrwDirs& crwDirs, uint16_t crwTagId) {
set value
*/
if (!crwDirs.empty()) {
CrwSubDir csd = crwDirs.top();
auto [dir, parent] = crwDirs.top();
crwDirs.pop();
// Find the directory
for (auto&& component : components_) {
if (component->tag() == csd.crwDir_) {
if (component->tag() == dir) {
cc_ = component;
break;
}
}
if (!cc_) {
// Directory doesn't exist yet, add it
m_ = std::make_unique<CiffDirectory>(csd.crwDir_, csd.parent_);
m_ = std::make_unique<CiffDirectory>(dir, parent);
cc_ = m_.get();
add(std::move(m_));
}
@ -592,7 +589,6 @@ void CiffHeader::remove(uint16_t crwTagId, uint16_t crwDir) {
if (pRootDir_) {
CrwDirs crwDirs;
CrwMap::loadStack(crwDirs, crwDir);
[[maybe_unused]] uint16_t rootDirectory = crwDirs.top().crwDir_;
crwDirs.pop();
pRootDir_->remove(crwDirs, crwTagId);
}
@ -608,11 +604,11 @@ void CiffComponent::doRemove(CrwDirs& /*crwDirs*/, uint16_t /*crwTagId*/) {
void CiffDirectory::doRemove(CrwDirs& crwDirs, uint16_t crwTagId) {
if (!crwDirs.empty()) {
CrwSubDir csd = crwDirs.top();
auto [dir, _] = crwDirs.top();
crwDirs.pop();
// Find the directory
for (auto i = components_.begin(); i != components_.end(); ++i) {
if ((*i)->tag() == csd.crwDir_) {
if ((*i)->tag() == dir) {
// Recursive call to next lower level directory
(*i)->remove(crwDirs, crwTagId);
if ((*i)->empty())
@ -743,8 +739,8 @@ void CrwMap::decodeArray(const CiffComponent& ciffComponent, const CrwMapping* p
if (ifdId == canonSiId) {
// Exif.Photo.FNumber
float f = fnumber(canonEv(aperture));
Rational r = floatToRationalCast(f);
URational ur(r.first, r.second);
auto [r, s] = floatToRationalCast(f);
auto ur = URational(r, s);
URationalValue fn;
fn.value_.push_back(ur);
image.exifData().add(ExifKey("Exif.Photo.FNumber"), &fn);
@ -835,9 +831,10 @@ void CrwMap::decodeBasic(const CiffComponent& ciffComponent, const CrwMapping* p
void CrwMap::loadStack(CrwDirs& crwDirs, uint16_t crwDir) {
for (auto&& crw : crwSubDir_) {
if (crw.crwDir_ == crwDir) {
auto&& [dir, parent] = crw;
if (dir == crwDir) {
crwDirs.push(crw);
crwDir = crw.parent_;
crwDir = parent;
}
}
} // CrwMap::loadStack

@ -20,7 +20,7 @@ namespace Exiv2::Internal {
class CiffHeader;
class CiffComponent;
struct CrwMapping;
struct CrwSubDir;
using CrwSubDir = std::pair<uint16_t, uint16_t>;
// *****************************************************************************
// type definitions
@ -486,12 +486,6 @@ class CiffHeader {
}; // class CiffHeader
//! Structure for the CIFF directory hierarchy
struct CrwSubDir {
uint16_t crwDir_; //!< Directory tag
uint16_t parent_; //!< Parent directory tag
}; // struct CrwSubDir
/*!
@brief Structure for a mapping table for conversion of CIFF entries to
image metadata and vice versa.

@ -153,9 +153,6 @@ Error::Error(ErrorCode code) : code_(code) {
setMsg(0);
}
Error::~Error() noexcept {
}
ErrorCode Error::code() const noexcept {
return code_;
}

@ -77,17 +77,17 @@ class Thumbnail {
@brief Return the thumbnail image in a %DataBuf. The caller owns the
data buffer and %DataBuf ensures that it will be deleted.
*/
virtual Exiv2::DataBuf copy(const Exiv2::ExifData& exifData) const = 0;
[[nodiscard]] virtual Exiv2::DataBuf copy(const Exiv2::ExifData& exifData) const = 0;
/*!
@brief Return the MIME type of the thumbnail ("image/tiff" or
"image/jpeg").
*/
virtual const char* mimeType() const = 0;
[[nodiscard]] virtual const char* mimeType() const = 0;
/*!
@brief Return the file extension for the format of the thumbnail
(".tif", ".jpg").
*/
virtual const char* extension() const = 0;
[[nodiscard]] virtual const char* extension() const = 0;
//@}
}; // class Thumbnail
@ -101,9 +101,9 @@ class TiffThumbnail : public Thumbnail {
//! @name Accessors
//@{
Exiv2::DataBuf copy(const Exiv2::ExifData& exifData) const override;
const char* mimeType() const override;
const char* extension() const override;
[[nodiscard]] Exiv2::DataBuf copy(const Exiv2::ExifData& exifData) const override;
[[nodiscard]] const char* mimeType() const override;
[[nodiscard]] const char* extension() const override;
//@}
}; // class TiffThumbnail
@ -117,9 +117,9 @@ class JpegThumbnail : public Thumbnail {
//! @name Accessors
//@{
Exiv2::DataBuf copy(const Exiv2::ExifData& exifData) const override;
const char* mimeType() const override;
const char* extension() const override;
[[nodiscard]] Exiv2::DataBuf copy(const Exiv2::ExifData& exifData) const override;
[[nodiscard]] const char* mimeType() const override;
[[nodiscard]] const char* extension() const override;
//@}
}; // class JpegThumbnail

@ -11,6 +11,9 @@
#include "http.hpp"
#include <array>
#include <chrono>
#include <cinttypes>
#include <thread>
////////////////////////////////////////
// platform specific code
@ -23,12 +26,12 @@
#define closesocket close
#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <unistd.h>
#include <cerrno>
#define fopen_S(f, n, o) f = fopen(n, o)
#define WINAPI
@ -41,13 +44,6 @@ using DWORD = unsigned long;
static int WSAGetLastError() {
return errno;
}
static void Sleep(int millisecs) {
const struct timespec rqtp = {0, millisecs * 1000000};
struct timespec rmtp;
nanosleep(&rqtp, &rmtp);
}
#endif
////////////////////////////////////////
@ -70,8 +66,8 @@ static constexpr std::array<const char*, 2> blankLines{
"\n\n", // this is commonly sent by CGI scripts
};
static constexpr int snooze = 0;
static int sleep_ = 1000;
static constexpr auto snooze = std::chrono::milliseconds::zero();
static auto sleep_ = std::chrono::milliseconds(1000);
static int forgive(int n, int& err) {
err = WSAGetLastError();
@ -245,12 +241,13 @@ int Exiv2::http(Exiv2::Dictionary& request, Exiv2::Dictionary& response, std::st
////////////////////////////////////
// send the header (we'll have to wait for the connection by the non-blocking socket)
while (sleep_ >= 0 && send(sockfd, buffer, n, 0) == SOCKET_ERROR /* && WSAGetLastError() == WSAENOTCONN */) {
Sleep(snooze);
while (sleep_ >= std::chrono::milliseconds::zero() &&
send(sockfd, buffer, n, 0) == SOCKET_ERROR /* && WSAGetLastError() == WSAENOTCONN */) {
std::this_thread::sleep_for(snooze);
sleep_ -= snooze;
}
if (sleep_ < 0)
if (sleep_ < std::chrono::milliseconds::zero())
return error(errors, "error - timeout connecting to server = %s port = %s wsa_error = %d", servername, port,
WSAGetLastError());
@ -330,16 +327,16 @@ int Exiv2::http(Exiv2::Dictionary& request, Exiv2::Dictionary& response, std::st
}
n = forgive(recv(sockfd, buffer + end, static_cast<int>(buff_l - end), 0), err);
if (!n) {
Sleep(snooze);
std::this_thread::sleep_for(snooze);
sleep_ -= snooze;
if (sleep_ < 0)
if (sleep_ < std::chrono::milliseconds::zero())
n = FINISH;
}
}
if (n != FINISH || !OK(status)) {
snprintf(buffer, sizeof buffer, "wsa_error = %d,n = %d,sleep_ = %d status = %d", WSAGetLastError(), n, sleep_,
status);
snprintf(buffer, sizeof buffer, "wsa_error = %d,n = %d,sleep_ = %d status = %d", WSAGetLastError(), n,
int(sleep_.count()), status);
error(errors, buffer, nullptr, nullptr, 0);
} else if (bSearching && OK(status)) {
if (end) {

@ -38,11 +38,7 @@ static inline bool inRange2(int value, int lo1, int hi1, int lo2, int hi2) {
bool Photoshop::isIrb(const byte* pPsData, size_t sizePsData) {
if (sizePsData < 4)
return false;
for (auto&& i : irbId_) {
if (memcmp(pPsData, i, 4) == 0)
return true;
}
return false;
return std::any_of(irbId_.begin(), irbId_.end(), [pPsData](auto id) { return memcmp(pPsData, id, 4) == 0; });
}
bool Photoshop::valid(const byte* pPsData, size_t sizePsData) {

@ -178,7 +178,7 @@ void PgfImage::doWriteMetadata(BasicIo& outIo) {
throw Error(ErrorCode::kerImageWriteFailed);
// Write new Header size.
uint32_t newHeaderSize = static_cast<uint32_t>(header.size() + imgSize);
auto newHeaderSize = static_cast<uint32_t>(header.size() + imgSize);
DataBuf buffer(4);
std::copy_n(&newHeaderSize, 4, buffer.data());
byteSwap_(buffer, 0, bSwap_);

@ -58,15 +58,15 @@ class Loader {
static UniquePtr create(PreviewId id, const Image& image);
//! Check if a preview image with given params exists in the image
virtual bool valid() const {
[[nodiscard]] virtual bool valid() const {
return valid_;
}
//! Get properties of a preview image with given params
virtual PreviewProperties getProperties() const;
[[nodiscard]] virtual PreviewProperties getProperties() const;
//! Get a buffer that contains the preview image
virtual DataBuf getData() const = 0;
[[nodiscard]] virtual DataBuf getData() const = 0;
//! Read preview image dimensions when they are not available directly
virtual bool readDimensions() {
@ -119,10 +119,10 @@ class LoaderNative : public Loader {
LoaderNative(PreviewId id, const Image& image, int parIdx);
//! Get properties of a preview image with given params
PreviewProperties getProperties() const override;
[[nodiscard]] PreviewProperties getProperties() const override;
//! Get a buffer that contains the preview image
DataBuf getData() const override;
[[nodiscard]] DataBuf getData() const override;
//! Read preview image dimensions
bool readDimensions() override;
@ -142,10 +142,10 @@ class LoaderExifJpeg : public Loader {
LoaderExifJpeg(PreviewId id, const Image& image, int parIdx);
//! Get properties of a preview image with given params
PreviewProperties getProperties() const override;
[[nodiscard]] PreviewProperties getProperties() const override;
//! Get a buffer that contains the preview image
DataBuf getData() const override;
[[nodiscard]] DataBuf getData() const override;
//! Read preview image dimensions
bool readDimensions() override;
@ -175,10 +175,10 @@ class LoaderExifDataJpeg : public Loader {
LoaderExifDataJpeg(PreviewId id, const Image& image, int parIdx);
//! Get properties of a preview image with given params
PreviewProperties getProperties() const override;
[[nodiscard]] PreviewProperties getProperties() const override;
//! Get a buffer that contains the preview image
DataBuf getData() const override;
[[nodiscard]] DataBuf getData() const override;
//! Read preview image dimensions
bool readDimensions() override;
@ -207,10 +207,10 @@ class LoaderTiff : public Loader {
LoaderTiff(PreviewId id, const Image& image, int parIdx);
//! Get properties of a preview image with given params
PreviewProperties getProperties() const override;
[[nodiscard]] PreviewProperties getProperties() const override;
//! Get a buffer that contains the preview image
DataBuf getData() const override;
[[nodiscard]] DataBuf getData() const override;
protected:
//! Name of the group that contains the preview image
@ -243,10 +243,10 @@ class LoaderXmpJpeg : public Loader {
LoaderXmpJpeg(PreviewId id, const Image& image, int parIdx);
//! Get properties of a preview image with given params
PreviewProperties getProperties() const override;
[[nodiscard]] PreviewProperties getProperties() const override;
//! Get a buffer that contains the preview image
DataBuf getData() const override;
[[nodiscard]] DataBuf getData() const override;
//! Read preview image dimensions
bool readDimensions() override;

@ -168,7 +168,7 @@ struct ExifKey::Impl {
//! @name Accessors
//@{
//! Return the name of the tag
std::string tagName() const;
[[nodiscard]] std::string tagName() const;
//@}
// DATA

@ -213,10 +213,7 @@ struct TagDetails {
@brief Helper structure for lookup tables for translations of bitmask
values to human readable labels.
*/
struct TagDetailsBitmask {
uint32_t mask_; //!< Bitmask value
const char* label_; //!< Description of the tag value
}; // struct TagDetailsBitmask
using TagDetailsBitmask = std::pair<uint32_t, const char*>;
/*!
@brief Helper structure for lookup tables for translations of controlled
@ -271,20 +268,20 @@ template <int N, const TagDetailsBitmask (&array)[N]>
std::ostream& printTagBitmask(std::ostream& os, const Value& value, const ExifData*) {
const auto val = value.toUint32();
if (val == 0 && N > 0) {
const TagDetailsBitmask* td = *(&array);
if (td->mask_ == 0)
return os << exvGettext(td->label_);
auto [mask, label] = *array;
if (mask == 0)
return os << exvGettext(label);
}
bool sep = false;
for (int i = 0; i < N; ++i) {
// *& acrobatics is a workaround for a MSVC 7.1 bug
const TagDetailsBitmask* td = *(&array) + i;
auto [mask, label] = *(array + i);
if (val & td->mask_) {
if (val & mask) {
if (sep) {
os << ", " << exvGettext(td->label_);
os << ", " << exvGettext(label);
} else {
os << exvGettext(td->label_);
os << exvGettext(label);
sep = true;
}
}

@ -1073,7 +1073,7 @@ uint32_t TiffIfdMakernote::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, in
uint32_t /*dataIdx*/, uint32_t& imageIdx) {
mnOffset_ = static_cast<uint32_t>(offset);
setImageByteOrder(byteOrder);
uint32_t len = static_cast<uint32_t>(writeHeader(ioWrapper, this->byteOrder()));
auto len = static_cast<uint32_t>(writeHeader(ioWrapper, this->byteOrder()));
len += ifd_.write(ioWrapper, this->byteOrder(), offset - baseOffset() + len, uint32_t(-1), uint32_t(-1), imageIdx);
return len;
} // TiffIfdMakernote::doWrite

@ -134,17 +134,11 @@ class TiffHeader : public TiffHeaderBase {
*/
struct TiffImgTagStruct {
//! Search key for TIFF image tag structure.
struct Key {
//! Constructor
Key(uint16_t t, IfdId g) : t_(t), g_(g) {
}
uint16_t t_; //!< %Tag
IfdId g_; //!< %Group
};
using Key = std::pair<uint16_t, IfdId>;
//! Comparison operator to compare a TiffImgTagStruct with a TiffImgTagStruct::Key
bool operator==(const Key& key) const {
return key.g_ == group_ && key.t_ == tag_;
auto [t, g] = key;
return g == group_ && t == tag_;
}
// DATA
@ -158,17 +152,12 @@ struct TiffImgTagStruct {
*/
struct TiffGroupStruct {
//! Search key for TIFF group structure.
struct Key {
//! Constructor
Key(uint32_t e, IfdId g) : e_(e), g_(g) {
}
uint32_t e_; //!< Extended tag
IfdId g_; //!< %Group
};
using Key = std::pair<uint32_t, IfdId>;
//! Comparison operator to compare a TiffGroupStruct with a TiffGroupStruct::Key
bool operator==(const Key& key) const {
return key.g_ == group_ && (Tag::all == extendedTag_ || key.e_ == extendedTag_);
auto [e, g] = key;
return g == group_ && (Tag::all == extendedTag_ || e == extendedTag_);
}
//! Return the tag corresponding to the extended tag
[[nodiscard]] uint16_t tag() const {

@ -843,7 +843,7 @@ size_t DateValue::copy(byte* buf, ByteOrder /*byteOrder*/) const {
// sprintf wants to add the null terminator, so use oversized buffer
char temp[9];
size_t wrote = static_cast<size_t>(snprintf(temp, sizeof(temp), "%04d%02d%02d", date_.year, date_.month, date_.day));
auto wrote = static_cast<size_t>(snprintf(temp, sizeof(temp), "%04d%02d%02d", date_.year, date_.month, date_.day));
std::memcpy(buf, temp, wrote);
return wrote;
}

@ -232,7 +232,8 @@ Exiv2::XmpKey::UniquePtr makeXmpKey(const std::string& schemaNs, const std::stri
//! Helper class used to serialize critical sections
class AutoLock {
public:
AutoLock(Exiv2::XmpParser::XmpLockFct xmpLockFct, void* pLockData) : xmpLockFct_(xmpLockFct), pLockData_(pLockData) {
AutoLock(Exiv2::XmpParser::XmpLockFct xmpLockFct, void* pLockData) :
xmpLockFct_(std::move(xmpLockFct)), pLockData_(pLockData) {
if (xmpLockFct_)
xmpLockFct_(pLockData_, true);
}
@ -510,7 +511,7 @@ void* XmpParser::pLockData_ = nullptr;
#ifdef EXV_HAVE_XMP_TOOLKIT
bool XmpParser::initialize(XmpParser::XmpLockFct xmpLockFct, void* pLockData) {
if (!initialized_) {
xmpLockFct_ = xmpLockFct;
xmpLockFct_ = std::move(xmpLockFct);
pLockData_ = pLockData;
initialized_ = SXMPMeta::Initialize();
#ifdef EXV_ADOBE_XMPSDK

@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include <gtest/gtest.h>
#include <stdint.h>
#include <cstdint>
#include <exiv2/exiv2.hpp>
#include "slice.hpp"
#include "types.hpp"

Loading…
Cancel
Save