Merge pull request #2125 from neheb/1

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

@ -902,7 +902,7 @@ namespace Action {
if (dontOverwrite(thumbPath)) return 0; if (dontOverwrite(thumbPath)) return 0;
if (Params::instance().verbose_) { if (Params::instance().verbose_) {
Exiv2::DataBuf buf = exifThumb.copy(); Exiv2::DataBuf buf = exifThumb.copy();
if (buf.size() != 0) { if (!buf.empty()) {
std::cout << _("Writing thumbnail") << " (" << exifThumb.mimeType() << ", " std::cout << _("Writing thumbnail") << " (" << exifThumb.mimeType() << ", "
<< buf.size() << " " << _("Bytes") << ") " << _("to file") << " " << buf.size() << " " << _("Bytes") << ") " << _("to file") << " "
<< thumbPath << std::endl; << thumbPath << std::endl;
@ -1150,7 +1150,7 @@ namespace Action {
image->readMetadata(); image->readMetadata();
// clear existing profile, assign the blob and rewrite image // clear existing profile, assign the blob and rewrite image
image->clearIccProfile(); image->clearIccProfile();
if ( iccProfileBlob.size() ) { if (!iccProfileBlob.empty()) {
image->setIccProfile(std::move(iccProfileBlob)); image->setIccProfile(std::move(iccProfileBlob));
} }
image->writeMetadata(); image->writeMetadata();

@ -1010,7 +1010,7 @@ void Params::getStdin(Exiv2::DataBuf& buf)
} }
// copy stdinBuf to buf // copy stdinBuf to buf
if ( stdinBuf.size() ) { if (!stdinBuf.empty()) {
buf.alloc(stdinBuf.size()); buf.alloc(stdinBuf.size());
buf.copyBytes(0,stdinBuf.c_data(),buf.size()); buf.copyBytes(0,stdinBuf.c_data(),buf.size());
} }

@ -36,7 +36,7 @@ namespace Exiv2 {
class EXIV2API BasicIo { class EXIV2API BasicIo {
public: public:
//! BasicIo auto_ptr type //! BasicIo auto_ptr type
typedef std::unique_ptr<BasicIo> UniquePtr; using UniquePtr = std::unique_ptr<BasicIo>;
//! Seek starting positions //! Seek starting positions
enum Position { beg, cur, end }; enum Position { beg, cur, end };

@ -245,7 +245,7 @@ namespace Exiv2 {
class EXIV2API IptcKey : public Key { class EXIV2API IptcKey : public Key {
public: public:
//! Shortcut for an %IptcKey auto pointer. //! Shortcut for an %IptcKey auto pointer.
typedef std::unique_ptr<IptcKey> UniquePtr; using UniquePtr = std::unique_ptr<IptcKey>;
//! @name Creators //! @name Creators
//@{ //@{
@ -322,10 +322,10 @@ namespace Exiv2 {
/*! /*!
@brief typedef for string:string map @brief typedef for string:string map
*/ */
typedef std::map<std::string,std::string> Dictionary; using Dictionary = std::map<std::string, std::string>;
// ***************************************************************************** // *****************************************************************************
// free functions // free functions
//! Output operator for dataSet //! Output operator for dataSet
EXIV2API std::ostream& operator<<(std::ostream& os, const DataSet& dataSet); EXIV2API std::ostream& operator<<(std::ostream& os, const DataSet& dataSet);

@ -68,7 +68,7 @@ namespace Exiv2 {
specific way. The default handler sends the log message to specific way. The default handler sends the log message to
standard error. standard error.
*/ */
typedef void (*Handler)(int, const char*); using Handler = void (*)(int, const char*);
//! @name Creators //! @name Creators
//@{ //@{
@ -290,10 +290,10 @@ namespace Exiv2 {
}; // class BasicError }; // class BasicError
//! Error class used for exceptions (std::string based) //! Error class used for exceptions (std::string based)
typedef BasicError<char> Error; using Error = BasicError<char>;
// ***************************************************************************** // *****************************************************************************
// free functions, template and inline definitions // free functions, template and inline definitions
//! Return the error message for the error with code \em code. //! Return the error message for the error with code \em code.
const char* errMsg(int code); const char* errMsg(int code);

@ -354,7 +354,7 @@ namespace Exiv2 {
}; // class ExifThumb }; // class ExifThumb
//! Container type to hold all metadata //! Container type to hold all metadata
typedef std::list<Exifdatum> ExifMetadata; using ExifMetadata = std::list<Exifdatum>;
/*! /*!
@brief A container for Exif data. This is a top-level class of the %Exiv2 @brief A container for Exif data. This is a top-level class of the %Exiv2
@ -371,9 +371,9 @@ namespace Exiv2 {
class EXIV2API ExifData { class EXIV2API ExifData {
public: public:
//! ExifMetadata iterator type //! ExifMetadata iterator type
typedef ExifMetadata::iterator iterator; using iterator = ExifMetadata::iterator;
//! ExifMetadata const iterator type //! ExifMetadata const iterator type
typedef ExifMetadata::const_iterator const_iterator; using const_iterator = ExifMetadata::const_iterator;
//! @name Manipulators //! @name Manipulators
//@{ //@{

@ -31,14 +31,12 @@ namespace Exiv2 {
}; };
//! List of native previews. This is meant to be used only by the PreviewManager. //! List of native previews. This is meant to be used only by the PreviewManager.
typedef std::vector<NativePreview> NativePreviewList; using NativePreviewList = std::vector<NativePreview>;
/*! /*!
@brief Options for printStructure @brief Options for printStructure
*/ */
typedef enum { kpsNone, kpsBasic, kpsXMP, kpsRecursive enum PrintStructureOption { kpsNone, kpsBasic, kpsXMP, kpsRecursive, kpsIccProfile, kpsIptcErase };
, kpsIccProfile , kpsIptcErase
} PrintStructureOption;
/*! /*!
@brief Abstract base class defining the interface for an image. This is @brief Abstract base class defining the interface for an image. This is
@ -53,7 +51,7 @@ namespace Exiv2 {
class EXIV2API Image { class EXIV2API Image {
public: public:
//! Image auto_ptr type //! Image auto_ptr type
typedef std::unique_ptr<Image> UniquePtr; using UniquePtr = std::unique_ptr<Image>;
//! @name Creators //! @name Creators
//@{ //@{
@ -490,9 +488,9 @@ namespace Exiv2 {
}; // class Image }; // class Image
//! Type for function pointer that creates new Image instances //! Type for function pointer that creates new Image instances
typedef Image::UniquePtr (*NewInstanceFct)(BasicIo::UniquePtr io, bool create); using NewInstanceFct = Image::UniquePtr (*)(BasicIo::UniquePtr io, bool create);
//! Type for function pointer that checks image types //! Type for function pointer that checks image types
typedef bool (*IsThisTypeFct)(BasicIo& iIo, bool advance); using IsThisTypeFct = bool (*)(BasicIo& iIo, bool advance);
/*! /*!
@brief Returns an Image instance of the specified type. @brief Returns an Image instance of the specified type.

@ -25,11 +25,10 @@ extern "C" {
#endif #endif
//! @brief typedef for prototype of handler function. //! @brief typedef for prototype of handler function.
typedef int (*ini_handler)(void* user, const char* section, using ini_handler = int (*)(void* user, const char* section, const char* name, const char* value);
const char* name, const char* value);
//! Typedef for prototype of fgets-style reader function. //! Typedef for prototype of fgets-style reader function.
typedef char* (*ini_reader)(char* str, int num, void* stream); using ini_reader = char* (*)(char* str, int num, void* stream);
/*! /*!
@brief Parse given INI-style file. May have [section]s, name=value pairs @brief Parse given INI-style file. May have [section]s, name=value pairs

@ -138,7 +138,7 @@ namespace Exiv2 {
}; // class Iptcdatum }; // class Iptcdatum
//! Container type to hold all metadata //! Container type to hold all metadata
typedef std::vector<Iptcdatum> IptcMetadata; using IptcMetadata = std::vector<Iptcdatum>;
/*! /*!
@brief A container for IPTC data. This is a top-level class of the %Exiv2 library. @brief A container for IPTC data. This is a top-level class of the %Exiv2 library.
@ -153,9 +153,9 @@ namespace Exiv2 {
class EXIV2API IptcData { class EXIV2API IptcData {
public: public:
//! IptcMetadata iterator type //! IptcMetadata iterator type
typedef IptcMetadata::iterator iterator; using iterator = IptcMetadata::iterator;
//! IptcMetadata const iterator type //! IptcMetadata const iterator type
typedef IptcMetadata::const_iterator const_iterator; using const_iterator = IptcMetadata::const_iterator;
// Use the compiler generated constructors and assignment operator // Use the compiler generated constructors and assignment operator

@ -27,7 +27,7 @@ namespace Exiv2 {
class EXIV2API Key { class EXIV2API Key {
public: public:
//! Shortcut for a %Key auto pointer. //! Shortcut for a %Key auto pointer.
typedef std::unique_ptr<Key> UniquePtr; using UniquePtr = std::unique_ptr<Key>;
//! @name Creators //! @name Creators
//@{ //@{

@ -12,11 +12,11 @@
// namespace extensions // namespace extensions
namespace Exiv2 { namespace Exiv2 {
// ***************************************************************************** // *****************************************************************************
// class definitions // class definitions
//! Type of preview image. //! Type of preview image.
typedef int PreviewId; using PreviewId = int;
/*! /*!
@brief Preview image properties. @brief Preview image properties.
@ -37,13 +37,14 @@ namespace Exiv2 {
}; };
//! Container type to hold all preview images metadata. //! Container type to hold all preview images metadata.
typedef std::vector<PreviewProperties> PreviewPropertiesList; using PreviewPropertiesList = std::vector<PreviewProperties>;
/*! /*!
@brief Class that holds preview image properties and data buffer. @brief Class that holds preview image properties and data buffer.
*/ */
class EXIV2API PreviewImage { class EXIV2API PreviewImage {
friend class PreviewManager; friend class PreviewManager;
public: public:
//! @name Constructors //! @name Constructors
//@{ //@{
@ -111,10 +112,10 @@ namespace Exiv2 {
//! Private constructor //! Private constructor
PreviewImage(PreviewProperties properties, DataBuf&& data); PreviewImage(PreviewProperties properties, DataBuf&& data);
PreviewProperties properties_; //!< Preview image properties PreviewProperties properties_; //!< Preview image properties
DataBuf preview_; //!< Preview image data DataBuf preview_; //!< Preview image data
}; // class PreviewImage }; // class PreviewImage
/*! /*!
@brief Class for extracting preview images from image metadata. @brief Class for extracting preview images from image metadata.
@ -142,9 +143,9 @@ namespace Exiv2 {
//@} //@}
private: private:
const Image& image_; const Image& image_;
}; // class PreviewManager }; // class PreviewManager
} // namespace Exiv2 } // namespace Exiv2
#endif // #ifndef PREVIEW_HPP_ #endif // #ifndef PREVIEW_HPP_

@ -198,7 +198,7 @@ namespace Exiv2 {
*/ */
static void unregisterNs(); static void unregisterNs();
//! Type for the namespace registry //! Type for the namespace registry
typedef std::map<std::string, XmpNsInfo> NsRegistry; using NsRegistry = std::map<std::string, XmpNsInfo>;
/*! /*!
@brief Get the registered namespace for a specific \em prefix from the registry. @brief Get the registered namespace for a specific \em prefix from the registry.
*/ */
@ -221,7 +221,7 @@ namespace Exiv2 {
{ {
public: public:
//! Shortcut for an %XmpKey auto pointer. //! Shortcut for an %XmpKey auto pointer.
typedef std::unique_ptr<XmpKey> UniquePtr; using UniquePtr = std::unique_ptr<XmpKey>;
//! @name Creators //! @name Creators
//@{ //@{

@ -12,53 +12,6 @@ namespace Exiv2
{ {
namespace Internal namespace Internal
{ {
// TODO: remove these custom implementations once we have C++11
template <class T>
struct remove_const
{
typedef T type;
};
template <class T>
struct remove_const<const T>
{
typedef T type;
};
template <class T>
struct remove_volatile
{
typedef T type;
};
template <class T>
struct remove_volatile<volatile T>
{
typedef T type;
};
template <class T>
struct remove_cv
{
typedef typename remove_const<typename remove_volatile<T>::type>::type type;
};
template <class T>
struct remove_pointer
{
typedef T type;
};
template <class T>
struct remove_pointer<T*>
{
typedef T type;
};
template <class T>
struct remove_pointer<T* const>
{
typedef T type;
};
/*! /*!
* Common base class of all slice implementations. * Common base class of all slice implementations.
* *
@ -133,9 +86,9 @@ namespace Exiv2
template <template <typename data_type> class storage_type, typename data_type> template <template <typename data_type> class storage_type, typename data_type>
struct ConstSliceBase : SliceBase struct ConstSliceBase : SliceBase
{ {
typedef typename storage_type<data_type>::iterator iterator; using iterator = typename storage_type<data_type>::iterator;
typedef typename storage_type<data_type>::const_iterator const_iterator; using const_iterator = typename storage_type<data_type>::const_iterator;
typedef typename storage_type<data_type>::value_type value_type; using value_type = typename storage_type<data_type>::value_type;
/*! /*!
* Default constructor, requires begin to be smaller than end, * Default constructor, requires begin to be smaller than end,
@ -220,9 +173,9 @@ namespace Exiv2
template <template <typename> class storage_type, typename data_type> template <template <typename> class storage_type, typename data_type>
struct MutableSliceBase : public ConstSliceBase<storage_type, data_type> struct MutableSliceBase : public ConstSliceBase<storage_type, data_type>
{ {
typedef typename ConstSliceBase<storage_type, data_type>::iterator iterator; using iterator = typename ConstSliceBase<storage_type, data_type>::iterator;
typedef typename ConstSliceBase<storage_type, data_type>::const_iterator const_iterator; using const_iterator = typename ConstSliceBase<storage_type, data_type>::const_iterator;
typedef typename ConstSliceBase<storage_type, data_type>::value_type value_type; using value_type = typename ConstSliceBase<storage_type, data_type>::value_type;
/*! /*!
* Forwards everything to the constructor of const_slice_base * Forwards everything to the constructor of const_slice_base
@ -248,7 +201,6 @@ namespace Exiv2
const value_type& at(size_t index) const const value_type& at(size_t index) const
{ {
// TODO: use using base_type::at once we have C++11
return base_type::at(index); return base_type::at(index);
} }
@ -291,7 +243,7 @@ namespace Exiv2
return ConstSliceBase<storage_type, const data_type>(this->storage_.data_, this->begin_, this->end_); return ConstSliceBase<storage_type, const data_type>(this->storage_.data_, this->begin_, this->end_);
} }
typedef ConstSliceBase<storage_type, data_type> base_type; using base_type = ConstSliceBase<storage_type, data_type>;
/*! /*!
* Create a mutable sub-slice with the given bounds (with respect to * Create a mutable sub-slice with the given bounds (with respect to
@ -329,11 +281,11 @@ namespace Exiv2
template <typename container> template <typename container>
struct ContainerStorage struct ContainerStorage
{ {
typedef typename container::iterator iterator; using iterator = typename container::iterator;
typedef typename container::const_iterator const_iterator; using const_iterator = typename container::const_iterator;
typedef typename Internal::remove_cv<typename container::value_type>::type value_type; using value_type = std::remove_cv_t<typename container::value_type>;
/*! /*!
* @throw std::out_of_range when end is larger than the container's * @throw std::out_of_range when end is larger than the container's
@ -400,9 +352,9 @@ namespace Exiv2
template <typename storage_type> template <typename storage_type>
struct PtrSliceStorage struct PtrSliceStorage
{ {
typedef typename remove_cv<typename remove_pointer<storage_type>::type>::type value_type; using value_type = std::remove_cv_t<std::remove_pointer_t<storage_type> >;
typedef value_type* iterator; using iterator = value_type*;
typedef const value_type* const_iterator; using const_iterator = const value_type*;
/*! /*!
* Stores ptr and checks that it is not `NULL`. The slice's bounds * Stores ptr and checks that it is not `NULL`. The slice's bounds
@ -412,8 +364,7 @@ namespace Exiv2
*/ */
PtrSliceStorage(storage_type ptr, size_t /*begin*/, size_t /*end*/) : data_(ptr) PtrSliceStorage(storage_type ptr, size_t /*begin*/, size_t /*end*/) : data_(ptr)
{ {
// TODO: change this to nullptr once we use C++11 if (!ptr) {
if (ptr == NULL) {
throw std::invalid_argument("Null pointer passed to slice constructor"); throw std::invalid_argument("Null pointer passed to slice constructor");
} }
} }
@ -502,11 +453,11 @@ namespace Exiv2
template <typename container> template <typename container>
struct Slice : public Internal::MutableSliceBase<Internal::ContainerStorage, container> struct Slice : public Internal::MutableSliceBase<Internal::ContainerStorage, container>
{ {
typedef typename container::iterator iterator; using iterator = typename container::iterator;
typedef typename container::const_iterator const_iterator; using const_iterator = typename container::const_iterator;
typedef typename Internal::remove_cv<typename container::value_type>::type value_type; using value_type = std::remove_cv_t<typename container::value_type>;
/*! /*!
* @brief Construct a slice of the container `cont` starting at `begin` * @brief Construct a slice of the container `cont` starting at `begin`
@ -560,11 +511,11 @@ namespace Exiv2
template <typename container> template <typename container>
struct Slice<const container> : public Internal::ConstSliceBase<Internal::ContainerStorage, const container> struct Slice<const container> : public Internal::ConstSliceBase<Internal::ContainerStorage, const container>
{ {
typedef typename container::iterator iterator; using iterator = typename container::iterator;
typedef typename container::const_iterator const_iterator; using const_iterator = typename container::const_iterator;
typedef typename Internal::remove_cv<typename container::value_type>::type value_type; using value_type = std::remove_cv_t<typename container::value_type>;
Slice(const container& cont, size_t begin, size_t end) Slice(const container& cont, size_t begin, size_t end)
: Internal::ConstSliceBase<Internal::ContainerStorage, const container>(cont, begin, end) : Internal::ConstSliceBase<Internal::ContainerStorage, const container>(cont, begin, end)

@ -24,12 +24,12 @@ namespace Exiv2 {
// type definitions // type definitions
//! Type for a function pointer for functions interpreting the tag value //! Type for a function pointer for functions interpreting the tag value
typedef std::ostream& (*PrintFct)(std::ostream&, const Value&, const ExifData* pExifData); using PrintFct = std::ostream& (*)(std::ostream&, const Value&, const ExifData* pExifData);
//! A function returning a tag list. //! A function returning a tag list.
typedef const TagInfo* (*TagListFct)(); using TagListFct = const TagInfo* (*)();
// ***************************************************************************** // *****************************************************************************
// class definitions // class definitions
//! The details of an Exif group. Groups include IFDs and binary arrays. //! The details of an Exif group. Groups include IFDs and binary arrays.
struct EXIV2API GroupInfo { struct EXIV2API GroupInfo {
@ -106,7 +106,7 @@ namespace Exiv2 {
class EXIV2API ExifKey : public Key { class EXIV2API ExifKey : public Key {
public: public:
//! Shortcut for an %ExifKey auto pointer. //! Shortcut for an %ExifKey auto pointer.
typedef std::unique_ptr<ExifKey> UniquePtr; using UniquePtr = std::unique_ptr<ExifKey>;
//! @name Creators //! @name Creators
//@{ //@{

@ -19,9 +19,11 @@
/*! /*!
@brief Macro to make calls to member functions through a pointer more readable. @brief Macro to make calls to member functions through a pointer more readable.
See the C++ FAQ LITE, item See the C++ FAQ LITE, item
<a href="http://www.parashift.com/c++-faq-lite/pointers-to-members.html#faq-33.5" title="[33.5] How can I avoid syntax errors when calling a member function using a pointer-to-member-function?">[33.5] How can I avoid syntax errors when calling a member function using a pointer-to-member-function?</a>. <a href="http://www.parashift.com/c++-faq-lite/pointers-to-members.html#faq-33.5" title="[33.5] How can I avoid
syntax errors when calling a member function using a pointer-to-member-function?">[33.5] How can I avoid syntax errors
when calling a member function using a pointer-to-member-function?</a>.
*/ */
#define EXV_CALL_MEMBER_FN(object,ptrToMember) ((object).*(ptrToMember)) #define EXV_CALL_MEMBER_FN(object, ptrToMember) ((object).*(ptrToMember))
// ***************************************************************************** // *****************************************************************************
// forward declarations // forward declarations
@ -31,35 +33,32 @@ struct tm;
// namespace extensions // namespace extensions
namespace Exiv2 { namespace Exiv2 {
// ***************************************************************************** // *****************************************************************************
// type definitions // type definitions
//! 1 byte unsigned integer type. //! 1 byte unsigned integer type.
typedef uint8_t byte; using byte = uint8_t;
//! 8 byte unsigned rational type. //! 8 byte unsigned rational type.
typedef std::pair<uint32_t, uint32_t> URational; using URational = std::pair<uint32_t, uint32_t>;
//! 8 byte signed rational type. //! 8 byte signed rational type.
typedef std::pair<int32_t, int32_t> Rational; using Rational = std::pair<int32_t, int32_t>;
//! Type to express the byte order (little or big endian) //! Type to express the byte order (little or big endian)
enum ByteOrder enum ByteOrder {
{
invalidByteOrder, invalidByteOrder,
littleEndian, littleEndian,
bigEndian, bigEndian,
}; };
//! Type to indicate write method used by TIFF parsers //! Type to indicate write method used by TIFF parsers
enum WriteMethod enum WriteMethod {
{
wmIntrusive, wmIntrusive,
wmNonIntrusive, wmNonIntrusive,
}; };
//! An identifier for each type of metadata //! An identifier for each type of metadata
enum MetadataId enum MetadataId {
{
mdNone = 0, mdNone = 0,
mdExif = 1, mdExif = 1,
mdIptc = 2, mdIptc = 2,
@ -69,8 +68,7 @@ namespace Exiv2 {
}; };
//! An identifier for each mode of metadata support //! An identifier for each mode of metadata support
enum AccessMode enum AccessMode {
{
amNone = 0, amNone = 0,
amRead = 1, amRead = 1,
amWrite = 2, amWrite = 2,
@ -84,41 +82,41 @@ namespace Exiv2 {
See Value::create. 0x0000 to 0xffff are reserved for TIFF (Exif) types. See Value::create. 0x0000 to 0xffff are reserved for TIFF (Exif) types.
*/ */
enum TypeId { enum TypeId {
unsignedByte = 1, //!< Exif BYTE type, 8-bit unsigned integer. unsignedByte = 1, //!< Exif BYTE type, 8-bit unsigned integer.
asciiString = 2, //!< Exif ASCII type, 8-bit byte. asciiString = 2, //!< Exif ASCII type, 8-bit byte.
unsignedShort = 3, //!< Exif SHORT type, 16-bit (2-byte) unsigned integer. unsignedShort = 3, //!< Exif SHORT type, 16-bit (2-byte) unsigned integer.
unsignedLong = 4, //!< Exif LONG type, 32-bit (4-byte) unsigned integer. unsignedLong = 4, //!< Exif LONG type, 32-bit (4-byte) unsigned integer.
unsignedRational = 5, //!< Exif RATIONAL type, two LONGs: numerator and denominator of a fraction. unsignedRational = 5, //!< Exif RATIONAL type, two LONGs: numerator and denominator of a fraction.
signedByte = 6, //!< Exif SBYTE type, an 8-bit signed (twos-complement) integer. signedByte = 6, //!< Exif SBYTE type, an 8-bit signed (twos-complement) integer.
undefined = 7, //!< Exif UNDEFINED type, an 8-bit byte that may contain anything. undefined = 7, //!< Exif UNDEFINED type, an 8-bit byte that may contain anything.
signedShort = 8, //!< Exif SSHORT type, a 16-bit (2-byte) signed (twos-complement) integer. signedShort = 8, //!< Exif SSHORT type, a 16-bit (2-byte) signed (twos-complement) integer.
signedLong = 9, //!< Exif SLONG type, a 32-bit (4-byte) signed (twos-complement) integer. signedLong = 9, //!< Exif SLONG type, a 32-bit (4-byte) signed (twos-complement) integer.
signedRational =10, //!< Exif SRATIONAL type, two SLONGs: numerator and denominator of a fraction. signedRational = 10, //!< Exif SRATIONAL type, two SLONGs: numerator and denominator of a fraction.
tiffFloat =11, //!< TIFF FLOAT type, single precision (4-byte) IEEE format. tiffFloat = 11, //!< TIFF FLOAT type, single precision (4-byte) IEEE format.
tiffDouble =12, //!< TIFF DOUBLE type, double precision (8-byte) IEEE format. tiffDouble = 12, //!< TIFF DOUBLE type, double precision (8-byte) IEEE format.
tiffIfd =13, //!< TIFF IFD type, 32-bit (4-byte) unsigned integer. tiffIfd = 13, //!< TIFF IFD type, 32-bit (4-byte) unsigned integer.
unsignedLongLong =16, //!< Exif LONG LONG type, 64-bit (8-byte) unsigned integer. unsignedLongLong = 16, //!< Exif LONG LONG type, 64-bit (8-byte) unsigned integer.
signedLongLong =17, //!< Exif LONG LONG type, 64-bit (8-byte) signed integer. signedLongLong = 17, //!< Exif LONG LONG type, 64-bit (8-byte) signed integer.
tiffIfd8 =18, //!< TIFF IFD type, 64-bit (8-byte) unsigned integer. tiffIfd8 = 18, //!< TIFF IFD type, 64-bit (8-byte) unsigned integer.
string =0x10000, //!< IPTC string type. string = 0x10000, //!< IPTC string type.
date =0x10001, //!< IPTC date type. date = 0x10001, //!< IPTC date type.
time =0x10002, //!< IPTC time type. time = 0x10002, //!< IPTC time type.
comment =0x10003, //!< %Exiv2 type for the Exif user comment. comment = 0x10003, //!< %Exiv2 type for the Exif user comment.
directory =0x10004, //!< %Exiv2 type for a CIFF directory. directory = 0x10004, //!< %Exiv2 type for a CIFF directory.
xmpText =0x10005, //!< XMP text type. xmpText = 0x10005, //!< XMP text type.
xmpAlt =0x10006, //!< XMP alternative type. xmpAlt = 0x10006, //!< XMP alternative type.
xmpBag =0x10007, //!< XMP bag type. xmpBag = 0x10007, //!< XMP bag type.
xmpSeq =0x10008, //!< XMP sequence type. xmpSeq = 0x10008, //!< XMP sequence type.
langAlt =0x10009, //!< XMP language alternative type. langAlt = 0x10009, //!< XMP language alternative type.
invalidTypeId =0x1fffe, //!< Invalid type id. invalidTypeId = 0x1fffe, //!< Invalid type id.
lastTypeId =0x1ffff //!< Last type id. lastTypeId = 0x1ffff //!< Last type id.
}; };
//! Container for binary data //! Container for binary data
typedef std::vector<byte> Blob; using Blob = std::vector<byte>;
// ***************************************************************************** // *****************************************************************************
// class definitions // class definitions
//! Type information lookup functions. Implemented as a static class. //! Type information lookup functions. Implemented as a static class.
class EXIV2API TypeInfo { class EXIV2API TypeInfo {
@ -136,7 +134,6 @@ namespace Exiv2 {
static TypeId typeId(const std::string& typeName); static TypeId typeId(const std::string& typeName);
//! Return the size in bytes of one element of this type //! Return the size in bytes of one element of this type
static size_t typeSize(TypeId typeId); static size_t typeSize(TypeId typeId);
}; };
/*! /*!
@ -210,9 +207,9 @@ namespace Exiv2 {
//! Returns a (read-only) C-style string pointer. //! Returns a (read-only) C-style string pointer.
const char* c_str(size_t offset = 0) const; const char* c_str(size_t offset = 0) const;
bool empty() const {return pData_.empty(); } bool empty() const { return pData_.empty(); }
private: private:
std::vector<byte> pData_; std::vector<byte> pData_;
}; };
@ -232,15 +229,14 @@ namespace Exiv2 {
//! Overload of makeSlice for `const DataBuf`, returning an immutable Slice //! Overload of makeSlice for `const DataBuf`, returning an immutable Slice
EXIV2API Slice<const byte*> makeSlice(const DataBuf& buf, size_t begin, size_t end); EXIV2API Slice<const byte*> makeSlice(const DataBuf& buf, size_t begin, size_t end);
// ***************************************************************************** // *****************************************************************************
// free functions // free functions
//! Read a 2 byte unsigned short value from the data buffer //! Read a 2 byte unsigned short value from the data buffer
EXIV2API uint16_t getUShort(const byte* buf, ByteOrder byteOrder); EXIV2API uint16_t getUShort(const byte* buf, ByteOrder byteOrder);
//! Read a 2 byte unsigned short value from a Slice //! Read a 2 byte unsigned short value from a Slice
template <typename T> template <typename T>
uint16_t getUShort(const Slice<T>& buf, ByteOrder byteOrder) uint16_t getUShort(const Slice<T>& buf, ByteOrder byteOrder) {
{
if (byteOrder == littleEndian) { if (byteOrder == littleEndian) {
return static_cast<byte>(buf.at(1)) << 8 | static_cast<byte>(buf.at(0)); return static_cast<byte>(buf.at(1)) << 8 | static_cast<byte>(buf.at(0));
} }
@ -324,16 +320,14 @@ namespace Exiv2 {
stream, prefixed with the position in the buffer adjusted by stream, prefixed with the position in the buffer adjusted by
offset. offset.
*/ */
EXIV2API void hexdump(std::ostream& os, const byte* buf, long len, long offset =0); EXIV2API void hexdump(std::ostream& os, const byte* buf, long len, long offset = 0);
/*! /*!
@brief Return true if str is a hex number starting with prefix followed @brief Return true if str is a hex number starting with prefix followed
by size hex digits, false otherwise. If size is 0, any number of by size hex digits, false otherwise. If size is 0, any number of
digits is allowed and all are checked. digits is allowed and all are checked.
*/ */
EXIV2API bool isHex(const std::string& str, EXIV2API bool isHex(const std::string& str, size_t size = 0, const std::string& prefix = "");
size_t size =0,
const std::string& prefix ="");
/*! /*!
@brief Converts a string in the form "%Y:%m:%d %H:%M:%S", e.g., @brief Converts a string in the form "%Y:%m:%d %H:%M:%S", e.g.,
@ -414,8 +408,8 @@ namespace Exiv2 {
*/ */
EXIV2API Rational floatToRationalCast(float f); EXIV2API Rational floatToRationalCast(float f);
// ***************************************************************************** // *****************************************************************************
// template and inline definitions // template and inline definitions
/*! /*!
@brief Find an element that matches \em key in the array \em src. @brief Find an element that matches \em key in the array \em src.
@ -461,22 +455,21 @@ namespace Exiv2 {
} }
@endcode @endcode
*/ */
template<typename T, typename K, int N> template <typename T, typename K, int N>
const T* find(T (&src)[N], const K& key) const T* find(T (&src)[N], const K& key) {
{
const T* rc = std::find(src, src + N, key); const T* rc = std::find(src, src + N, key);
return rc == src + N ? nullptr : rc; return rc == src + N ? nullptr : rc;
} }
//! Template used in the COUNTOF macro to determine the size of an array //! Template used in the COUNTOF macro to determine the size of an array
template <typename T, int N> char (&sizer(T (&)[N]))[N]; template <typename T, int N>
char (&sizer(T (&)[N]))[N];
//! Macro to determine the size of an array //! Macro to determine the size of an array
#define EXV_COUNTOF(a) (sizeof(Exiv2::sizer(a))) #define EXV_COUNTOF(a) (sizeof(Exiv2::sizer(a)))
//! Utility function to convert the argument of any type to a string //! Utility function to convert the argument of any type to a string
template<typename T> template <typename T>
std::string toString(const T& arg) std::string toString(const T& arg) {
{
std::ostringstream os; std::ostringstream os;
os << arg; os << arg;
return os.str(); return os.str();
@ -493,9 +486,8 @@ namespace Exiv2 {
@return Returns the converted value and sets \em ok to \c true if the @return Returns the converted value and sets \em ok to \c true if the
conversion was successful or \c false if not. conversion was successful or \c false if not.
*/ */
template<typename T> template <typename T>
T stringTo(const std::string& s, bool& ok) T stringTo(const std::string& s, bool& ok) {
{
std::istringstream is(s); std::istringstream is(s);
T tmp = T(); T tmp = T();
ok = bool(is >> tmp); ok = bool(is >> tmp);
@ -512,7 +504,7 @@ namespace Exiv2 {
and returns \c true if it is "true", "t" or "1", and \c false if it is and returns \c true if it is "true", "t" or "1", and \c false if it is
"false", "f" or "0". "false", "f" or "0".
*/ */
template<> template <>
bool stringTo<bool>(const std::string& s, bool& ok); bool stringTo<bool>(const std::string& s, bool& ok);
/*! /*!
@ -524,8 +516,7 @@ namespace Exiv2 {
anyway... anyway...
*/ */
template <typename IntType> template <typename IntType>
IntType gcd(IntType n, IntType m) IntType gcd(IntType n, IntType m) {
{
// Avoid repeated construction // Avoid repeated construction
IntType zero(0); IntType zero(0);
@ -545,16 +536,14 @@ namespace Exiv2 {
// As n and m are now positive, we can be sure that %= returns a // As n and m are now positive, we can be sure that %= returns a
// positive value (the standard guarantees this for built-in types, // positive value (the standard guarantees this for built-in types,
// and we require it of user-defined types). // and we require it of user-defined types).
for(;;) { for (;;) {
if(m == zero) if (m == zero) return n;
return n;
n %= m; n %= m;
if(n == zero) if (n == zero) return m;
return m;
m %= n; m %= n;
} }
} }
} // namespace Exiv2 } // namespace Exiv2
#endif // #ifndef TYPES_HPP_ #endif // #ifndef TYPES_HPP_

@ -32,7 +32,7 @@ namespace Exiv2 {
class EXIV2API Value { class EXIV2API Value {
public: public:
//! Shortcut for a %Value auto pointer. //! Shortcut for a %Value auto pointer.
typedef std::unique_ptr<Value> UniquePtr; using UniquePtr = std::unique_ptr<Value>;
//! @name Creators //! @name Creators
//@{ //@{
@ -240,7 +240,7 @@ namespace Exiv2 {
class EXIV2API DataValue : public Value { class EXIV2API DataValue : public Value {
public: public:
//! Shortcut for a %DataValue auto pointer. //! Shortcut for a %DataValue auto pointer.
typedef std::unique_ptr<DataValue> UniquePtr; using UniquePtr = std::unique_ptr<DataValue>;
explicit DataValue(TypeId typeId =undefined); explicit DataValue(TypeId typeId =undefined);
@ -294,7 +294,7 @@ namespace Exiv2 {
DataValue* clone_() const override; DataValue* clone_() const override;
//! Type used to store the data. //! Type used to store the data.
typedef std::vector<byte> ValueType; using ValueType = std::vector<byte>;
// DATA // DATA
ValueType value_; //!< Stores the data value ValueType value_; //!< Stores the data value
@ -309,7 +309,7 @@ namespace Exiv2 {
class EXIV2API StringValueBase : public Value { class EXIV2API StringValueBase : public Value {
public: public:
//! Shortcut for a %StringValueBase auto pointer. //! Shortcut for a %StringValueBase auto pointer.
typedef std::unique_ptr<StringValueBase> UniquePtr; using UniquePtr = std::unique_ptr<StringValueBase>;
//! @name Creators //! @name Creators
//@{ //@{
@ -378,7 +378,7 @@ namespace Exiv2 {
class EXIV2API StringValue : public StringValueBase { class EXIV2API StringValue : public StringValueBase {
public: public:
//! Shortcut for a %StringValue auto pointer. //! Shortcut for a %StringValue auto pointer.
typedef std::unique_ptr<StringValue> UniquePtr; using UniquePtr = std::unique_ptr<StringValue>;
//! @name Creators //! @name Creators
//@{ //@{
@ -410,7 +410,7 @@ namespace Exiv2 {
class EXIV2API AsciiValue : public StringValueBase { class EXIV2API AsciiValue : public StringValueBase {
public: public:
//! Shortcut for a %AsciiValue auto pointer. //! Shortcut for a %AsciiValue auto pointer.
typedef std::unique_ptr<AsciiValue> UniquePtr; using UniquePtr = std::unique_ptr<AsciiValue>;
//! @name Creators //! @name Creators
//@{ //@{
@ -498,7 +498,7 @@ namespace Exiv2 {
}; // class CharsetInfo }; // class CharsetInfo
//! Shortcut for a %CommentValue auto pointer. //! Shortcut for a %CommentValue auto pointer.
typedef std::unique_ptr<CommentValue> UniquePtr; using UniquePtr = std::unique_ptr<CommentValue>;
//! @name Creators //! @name Creators
//@{ //@{
@ -582,7 +582,7 @@ namespace Exiv2 {
class EXIV2API XmpValue : public Value { class EXIV2API XmpValue : public Value {
public: public:
//! Shortcut for a %XmpValue auto pointer. //! Shortcut for a %XmpValue auto pointer.
typedef std::unique_ptr<XmpValue> UniquePtr; using UniquePtr = std::unique_ptr<XmpValue>;
//! XMP array types. //! XMP array types.
enum XmpArrayType { xaNone, xaAlt, xaBag, xaSeq }; enum XmpArrayType { xaNone, xaAlt, xaBag, xaSeq };
@ -652,7 +652,7 @@ namespace Exiv2 {
class EXIV2API XmpTextValue : public XmpValue { class EXIV2API XmpTextValue : public XmpValue {
public: public:
//! Shortcut for a %XmpTextValue auto pointer. //! Shortcut for a %XmpTextValue auto pointer.
typedef std::unique_ptr<XmpTextValue> UniquePtr; using UniquePtr = std::unique_ptr<XmpTextValue>;
//! @name Creators //! @name Creators
//@{ //@{
@ -741,7 +741,7 @@ namespace Exiv2 {
class EXIV2API XmpArrayValue : public XmpValue { class EXIV2API XmpArrayValue : public XmpValue {
public: public:
//! Shortcut for a %XmpArrayValue auto pointer. //! Shortcut for a %XmpArrayValue auto pointer.
typedef std::unique_ptr<XmpArrayValue> UniquePtr; using UniquePtr = std::unique_ptr<XmpArrayValue>;
//! @name Creators //! @name Creators
//@{ //@{
@ -831,7 +831,7 @@ namespace Exiv2 {
class EXIV2API LangAltValue : public XmpValue { class EXIV2API LangAltValue : public XmpValue {
public: public:
//! Shortcut for a %LangAltValue auto pointer. //! Shortcut for a %LangAltValue auto pointer.
typedef std::unique_ptr<LangAltValue> UniquePtr; using UniquePtr = std::unique_ptr<LangAltValue>;
//! @name Creators //! @name Creators
//@{ //@{
@ -901,7 +901,7 @@ namespace Exiv2 {
public: public:
//! Type used to store language alternative arrays. //! Type used to store language alternative arrays.
typedef std::map<std::string, std::string,LangAltValueComparator> ValueType; using ValueType = std::map<std::string, std::string, LangAltValueComparator>;
// DATA // DATA
/*! /*!
@brief Map to store the language alternative values. The language @brief Map to store the language alternative values. The language
@ -920,7 +920,7 @@ namespace Exiv2 {
class EXIV2API DateValue : public Value { class EXIV2API DateValue : public Value {
public: public:
//! Shortcut for a %DateValue auto pointer. //! Shortcut for a %DateValue auto pointer.
typedef std::unique_ptr<DateValue> UniquePtr; using UniquePtr = std::unique_ptr<DateValue>;
//! @name Creators //! @name Creators
//@{ //@{
@ -1011,7 +1011,7 @@ namespace Exiv2 {
class EXIV2API TimeValue : public Value { class EXIV2API TimeValue : public Value {
public: public:
//! Shortcut for a %TimeValue auto pointer. //! Shortcut for a %TimeValue auto pointer.
typedef std::unique_ptr<TimeValue> UniquePtr; using UniquePtr = std::unique_ptr<TimeValue>;
//! @name Creators //! @name Creators
//@{ //@{
@ -1132,7 +1132,7 @@ namespace Exiv2 {
class ValueType : public Value { class ValueType : public Value {
public: public:
//! Shortcut for a %ValueType\<T\> auto pointer. //! Shortcut for a %ValueType\<T\> auto pointer.
typedef std::unique_ptr<ValueType<T> > UniquePtr; using UniquePtr = std::unique_ptr<ValueType<T> >;
//! @name Creators //! @name Creators
//@{ //@{
@ -1198,11 +1198,11 @@ namespace Exiv2 {
//@} //@}
//! Container for values //! Container for values
typedef std::vector<T> ValueList; using ValueList = std::vector<T>;
//! Iterator type defined for convenience. //! Iterator type defined for convenience.
typedef typename std::vector<T>::iterator iterator; using iterator = typename std::vector<T>::iterator;
//! Const iterator type defined for convenience. //! Const iterator type defined for convenience.
typedef typename std::vector<T>::const_iterator const_iterator; using const_iterator = typename std::vector<T>::const_iterator;
// DATA // DATA
/*! /*!
@ -1281,24 +1281,24 @@ namespace Exiv2 {
}; // class ValueType }; // class ValueType
//! Unsigned short value type //! Unsigned short value type
typedef ValueType<uint16_t> UShortValue; using UShortValue = ValueType<uint16_t>;
//! Unsigned long value type //! Unsigned long value type
typedef ValueType<uint32_t> ULongValue; using ULongValue = ValueType<uint32_t>;
//! Unsigned rational value type //! Unsigned rational value type
typedef ValueType<URational> URationalValue; using URationalValue = ValueType<URational>;
//! Signed short value type //! Signed short value type
typedef ValueType<int16_t> ShortValue; using ShortValue = ValueType<int16_t>;
//! Signed long value type //! Signed long value type
typedef ValueType<int32_t> LongValue; using LongValue = ValueType<int32_t>;
//! Signed rational value type //! Signed rational value type
typedef ValueType<Rational> RationalValue; using RationalValue = ValueType<Rational>;
//! Float value type //! Float value type
typedef ValueType<float> FloatValue; using FloatValue = ValueType<float>;
//! Double value type //! Double value type
typedef ValueType<double> DoubleValue; using DoubleValue = ValueType<double>;
// ***************************************************************************** // *****************************************************************************
// free functions, template and inline definitions // free functions, template and inline definitions
/*! /*!
@brief Read a value of type T from the data buffer. @brief Read a value of type T from the data buffer.

@ -133,7 +133,7 @@ namespace Exiv2 {
}; // class Xmpdatum }; // class Xmpdatum
//! Container type to hold all metadata //! Container type to hold all metadata
typedef std::vector<Xmpdatum> XmpMetadata; using XmpMetadata = std::vector<Xmpdatum>;
/*! /*!
@brief A container for XMP data. This is a top-level class of @brief A container for XMP data. This is a top-level class of
@ -151,9 +151,9 @@ namespace Exiv2 {
XmpData() = default; XmpData() = default;
//! XmpMetadata iterator type //! XmpMetadata iterator type
typedef XmpMetadata::iterator iterator; using iterator = XmpMetadata::iterator;
//! XmpMetadata const iterator type //! XmpMetadata const iterator type
typedef XmpMetadata::const_iterator const_iterator; using const_iterator = XmpMetadata::const_iterator;
//! @name Manipulators //! @name Manipulators
//@{ //@{
@ -305,7 +305,7 @@ namespace Exiv2 {
@param pLockData Pointer to the pLockData passed to initialize() @param pLockData Pointer to the pLockData passed to initialize()
@param lockUnlock Indicates whether to lock (true) or unlock (false) @param lockUnlock Indicates whether to lock (true) or unlock (false)
*/ */
typedef void (*XmpLockFct)(void* pLockData, bool lockUnlock); using XmpLockFct = void (*)(void* pLockData, bool lockUnlock);
/*! /*!
@brief Initialize the XMP Toolkit. @brief Initialize the XMP Toolkit.

@ -269,12 +269,12 @@ namespace Jzon
Node *GetCopy() const override; Node *GetCopy() const override;
private: private:
typedef std::vector<NamedNodePtr> ChildList; using ChildList = std::vector<NamedNodePtr>;
ChildList children; ChildList children;
}; };
class JzonAPI Array : public Node class JzonAPI Array : public Node
{ {
public: public:
class iterator : public std::iterator<std::input_iterator_tag, Node> class iterator : public std::iterator<std::input_iterator_tag, Node>
{ {
@ -336,12 +336,12 @@ namespace Jzon
Node *GetCopy() const override; Node *GetCopy() const override;
private: private:
typedef std::vector<Node*> ChildList; using ChildList = std::vector<Node *>;
ChildList children; ChildList children;
}; };
class JzonAPI FileWriter class JzonAPI FileWriter
{ {
public: public:
FileWriter(std::string filename); FileWriter(std::string filename);
~FileWriter() = default; ~FileWriter() = default;

@ -29,7 +29,7 @@
static const Exiv2::TagInfo* findTag(const Exiv2::TagInfo* pList,uint16_t tag) static const Exiv2::TagInfo* findTag(const Exiv2::TagInfo* pList,uint16_t tag)
{ {
while ( pList->tag_ != 0xffff && pList->tag_ != tag ) pList++; while ( pList->tag_ != 0xffff && pList->tag_ != tag ) pList++;
return pList->tag_ != 0xffff ? pList : NULL; return pList->tag_ != 0xffff ? pList : nullptr;
} }

@ -230,7 +230,7 @@ std::string Position::toExifTimeStamp(std::string& t)
sscanf(arg,"%d%c%d%c%d%c%d%c%d%c%d",&YY,&a,&MM,&b,&DD,&c,&HH,&d,&mm,&e,&SS1); sscanf(arg,"%d%c%d%c%d%c%d%c%d%c%d",&YY,&a,&MM,&b,&DD,&c,&HH,&d,&mm,&e,&SS1);
} }
snprintf(result,sizeof(result),"%d/1 %d/1 %d/1",HH,mm,SS1); snprintf(result,sizeof(result),"%d/1 %d/1 %d/1",HH,mm,SS1);
return std::string(result); return result;
} }
std::string Position::toExifString(double d) std::string Position::toExifString(double d)
@ -238,7 +238,7 @@ std::string Position::toExifString(double d)
char result[200]; char result[200];
d *= 100; d *= 100;
snprintf(result, sizeof(result), "%d/100", abs(static_cast<int>(d))); snprintf(result, sizeof(result), "%d/100", abs(static_cast<int>(d)));
return std::string(result); return result;
} }
std::string Position::toExifString(double d,bool bRational,bool bLat) std::string Position::toExifString(double d,bool bRational,bool bLat)
@ -259,7 +259,7 @@ std::string Position::toExifString(double d,bool bRational,bool bLat)
snprintf(result,sizeof(result),"%d/1 %d/1 %d/1" ,deg,min,sec); snprintf(result,sizeof(result),"%d/1 %d/1 %d/1" ,deg,min,sec);
else else
snprintf(result,sizeof(result),"%03d%s%02d'%02d\"%s" ,deg,gDeg,min,sec,NSEW); snprintf(result,sizeof(result),"%03d%s%02d'%02d\"%s" ,deg,gDeg,min,sec,NSEW);
return std::string(result); return result;
} }
std::string Position::toString() const std::string Position::toString() const
@ -268,7 +268,7 @@ std::string Position::toString() const
std::string sLat = Position::toExifString(lat_,false,true ); std::string sLat = Position::toExifString(lat_,false,true );
std::string sLon = Position::toExifString(lon_,false,false); std::string sLon = Position::toExifString(lon_,false,false);
snprintf(result,sizeof(result),"%s %s %-8.3f",sLon.c_str(),sLat.c_str(),ele_); snprintf(result,sizeof(result),"%s %s %-8.3f",sLon.c_str(),sLat.c_str(),ele_);
return std::string(result); return result;
} }
// defaults // defaults

@ -375,7 +375,8 @@ namespace Exiv2 {
if (hKernel) { if (hKernel) {
ReplaceFileA_t pfcn_ReplaceFileA = (ReplaceFileA_t)GetProcAddress(hKernel, "ReplaceFileA"); ReplaceFileA_t pfcn_ReplaceFileA = (ReplaceFileA_t)GetProcAddress(hKernel, "ReplaceFileA");
if (pfcn_ReplaceFileA) { if (pfcn_ReplaceFileA) {
BOOL ret = pfcn_ReplaceFileA(pf, fileIo->path().c_str(), NULL, REPLACEFILE_IGNORE_MERGE_ERRORS, NULL, NULL); BOOL ret = pfcn_ReplaceFileA(pf, fileIo->path().c_str(), nullptr,
REPLACEFILE_IGNORE_MERGE_ERRORS, nullptr, nullptr);
if (ret == 0) { if (ret == 0) {
if (GetLastError() == ERROR_FILE_NOT_FOUND) { if (GetLastError() == ERROR_FILE_NOT_FOUND) {
fs::rename(fileIo->path().c_str(), pf); fs::rename(fileIo->path().c_str(), pf);
@ -1834,7 +1835,8 @@ namespace Exiv2 {
size_t curlWriter(char* data, size_t size, size_t nmemb, size_t curlWriter(char* data, size_t size, size_t nmemb,
std::string* writerData) std::string* writerData)
{ {
if (writerData == NULL) return 0; if (writerData == nullptr)
return 0;
writerData->append(data, size*nmemb); writerData->append(data, size*nmemb);
return size * nmemb; return size * nmemb;
} }

@ -345,11 +345,10 @@ namespace Exiv2::Internal {
append(blob, reinterpret_cast<const byte*>(signature_), 8); append(blob, reinterpret_cast<const byte*>(signature_), 8);
o += 8; o += 8;
// Pad as needed // Pad as needed
if (pPadding_.empty() == false) { if (!pPadding_.empty()) {
assert(padded_ == offset_ - o); assert(padded_ == offset_ - o);
append(blob, pPadding_.data(), padded_); append(blob, pPadding_.data(), padded_);
} } else {
else {
for (uint32_t i = o; i < offset_; ++i) { for (uint32_t i = o; i < offset_; ++i) {
blob.push_back(0); blob.push_back(0);
++o; ++o;
@ -1063,12 +1062,11 @@ namespace Exiv2::Internal {
// Try the undecoded tag // Try the undecoded tag
encodeBasic(image, pCrwMapping, pHead); encodeBasic(image, pCrwMapping, pHead);
} }
if (buf.size() > 0) { if (!buf.empty()) {
// Write the number of shorts to the beginning of buf // Write the number of shorts to the beginning of buf
buf.write_uint16(0, static_cast<uint16_t>(buf.size()), pHead->byteOrder()); buf.write_uint16(0, static_cast<uint16_t>(buf.size()), pHead->byteOrder());
pHead->add(pCrwMapping->crwTagId_, pCrwMapping->crwDir_, std::move(buf)); pHead->add(pCrwMapping->crwTagId_, pCrwMapping->crwDir_, std::move(buf));
} } else {
else {
pHead->remove(pCrwMapping->crwTagId_, pCrwMapping->crwDir_); pHead->remove(pCrwMapping->crwTagId_, pCrwMapping->crwDir_);
} }
} // CrwMap::encodeArray } // CrwMap::encodeArray
@ -1154,10 +1152,9 @@ namespace Exiv2::Internal {
ExifThumbC exifThumb(image.exifData()); ExifThumbC exifThumb(image.exifData());
DataBuf buf = exifThumb.copy(); DataBuf buf = exifThumb.copy();
if (buf.size() != 0) { if (!buf.empty()) {
pHead->add(pCrwMapping->crwTagId_, pCrwMapping->crwDir_, std::move(buf)); pHead->add(pCrwMapping->crwTagId_, pCrwMapping->crwDir_, std::move(buf));
} } else {
else {
pHead->remove(pCrwMapping->crwTagId_, pCrwMapping->crwDir_); pHead->remove(pCrwMapping->crwTagId_, pCrwMapping->crwDir_);
} }
} // CrwMap::encode0x2008 } // CrwMap::encode0x2008

@ -434,7 +434,7 @@ namespace Exiv2 {
size_t ExifThumbC::writeFile(const std::string& path) const size_t ExifThumbC::writeFile(const std::string& path) const
{ {
auto thumbnail = Thumbnail::create(exifData_); auto thumbnail = Thumbnail::create(exifData_);
if (!thumbnail.get()) if (!thumbnail)
return 0; return 0;
std::string name = path + thumbnail->extension(); std::string name = path + thumbnail->extension();
@ -448,7 +448,7 @@ namespace Exiv2 {
const char* ExifThumbC::mimeType() const const char* ExifThumbC::mimeType() const
{ {
auto thumbnail = Thumbnail::create(exifData_); auto thumbnail = Thumbnail::create(exifData_);
if (!thumbnail.get()) if (!thumbnail)
return ""; return "";
return thumbnail->mimeType(); return thumbnail->mimeType();
} }

@ -354,28 +354,28 @@ namespace Exiv2 {
{ {
std::string ret("unknown"); std::string ret("unknown");
#if defined(WIN32) #if defined(WIN32)
HANDLE processHandle = NULL; HANDLE processHandle = nullptr;
processHandle = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, GetCurrentProcessId()); processHandle = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, GetCurrentProcessId());
if (processHandle != NULL) { if (processHandle) {
TCHAR filename[MAX_PATH]; TCHAR filename[MAX_PATH];
if (GetModuleFileNameEx(processHandle, NULL, filename, MAX_PATH) != 0) { if (GetModuleFileNameEx(processHandle, nullptr, filename, MAX_PATH) != 0) {
ret = filename; ret = filename;
} }
CloseHandle(processHandle); CloseHandle(processHandle);
} }
#elif defined(__APPLE__) #elif defined(__APPLE__)
#ifdef EXV_HAVE_LIBPROC_H #ifdef EXV_HAVE_LIBPROC_H
const int pid = getpid(); const int pid = getpid();
char pathbuf[PROC_PIDPATHINFO_MAXSIZE]; char pathbuf[PROC_PIDPATHINFO_MAXSIZE];
if (proc_pidpath (pid, pathbuf, sizeof(pathbuf)) > 0) { if (proc_pidpath (pid, pathbuf, sizeof(pathbuf)) > 0) {
ret = pathbuf; ret = pathbuf;
} }
#endif #endif
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__)
unsigned int n; unsigned int n;
char buffer[PATH_MAX] = {}; char buffer[PATH_MAX] = {};
struct procstat* procstat = procstat_open_sysctl(); struct procstat* procstat = procstat_open_sysctl();
struct kinfo_proc* procs = procstat ? procstat_getprocs(procstat, KERN_PROC_PID, getpid(), &n) : NULL; struct kinfo_proc* procs = procstat ? procstat_getprocs(procstat, KERN_PROC_PID, getpid(), &n) : nullptr;
if ( procs ) { if ( procs ) {
procstat_getpathname(procstat, procs, buffer, PATH_MAX); procstat_getpathname(procstat, procs, buffer, PATH_MAX);
ret = std::string(buffer); ret = std::string(buffer);
@ -383,7 +383,7 @@ namespace Exiv2 {
// release resources // release resources
if ( procs ) procstat_freeprocs(procstat, procs); if ( procs ) procstat_freeprocs(procstat, procs);
if ( procstat ) procstat_close(procstat); if ( procstat ) procstat_close(procstat);
#elif defined(__sun__) #elif defined(__sun__)
// https://stackoverflow.com/questions/47472762/on-solaris-how-to-get-the-full-path-of-executable-of-running-process-programatic // https://stackoverflow.com/questions/47472762/on-solaris-how-to-get-the-full-path-of-executable-of-running-process-programatic
const char* proc = Internal::stringFormat("/proc/%d/path/a.out",getpid()).c_str(); const char* proc = Internal::stringFormat("/proc/%d/path/a.out",getpid()).c_str();
char path[500]; char path[500];
@ -392,7 +392,7 @@ namespace Exiv2 {
path[l]=0; path[l]=0;
ret = path; ret = path;
} }
#elif defined(__unix__) #elif defined(__unix__)
// http://stackoverflow.com/questions/606041/how-do-i-get-the-path-of-a-process-in-unix-linux // http://stackoverflow.com/questions/606041/how-do-i-get-the-path-of-a-process-in-unix-linux
char path[500]; char path[500];
ssize_t l = readlink ("/proc/self/exe", path,sizeof(path)-1); ssize_t l = readlink ("/proc/self/exe", path,sizeof(path)-1);
@ -400,7 +400,7 @@ namespace Exiv2 {
path[l]=0; path[l]=0;
ret = path; ret = path;
} }
#endif #endif
const size_t idxLastSeparator = ret.find_last_of(EXV_SEPARATOR_STR); const size_t idxLastSeparator = ret.find_last_of(EXV_SEPARATOR_STR);
return ret.substr(0, idxLastSeparator); return ret.substr(0, idxLastSeparator);

@ -9,5 +9,5 @@ std::string string_from_unterminated(const char* data, size_t data_length)
return {}; return {};
} }
const size_t StringLength = strnlen(data, data_length); const size_t StringLength = strnlen(data, data_length);
return std::string(data, StringLength); return {data, StringLength};
} }

@ -845,8 +845,7 @@ static void boxes_check(size_t b,size_t m)
// Update Iptc data to a new UUID box // Update Iptc data to a new UUID box
DataBuf rawIptc = IptcParser::encode(iptcData_); DataBuf rawIptc = IptcParser::encode(iptcData_);
if (rawIptc.size() > 0) if (!rawIptc.empty()) {
{
DataBuf boxData(8 + 16 + rawIptc.size()); DataBuf boxData(8 + 16 + rawIptc.size());
ul2Data(boxDataSize, static_cast<uint32_t>(boxData.size()), Exiv2::bigEndian); ul2Data(boxDataSize, static_cast<uint32_t>(boxData.size()), Exiv2::bigEndian);
ul2Data(boxUUIDtype, kJp2BoxTypeUuid, Exiv2::bigEndian); ul2Data(boxUUIDtype, kJp2BoxTypeUuid, Exiv2::bigEndian);

@ -419,7 +419,7 @@ namespace Exiv2 {
} }
DataBuf profile(Safe::add(iccProfile_.size(), icc_size)); DataBuf profile(Safe::add(iccProfile_.size(), icc_size));
if ( iccProfile_.size() ) { if (!iccProfile_.empty()) {
profile.copyBytes(0, iccProfile_.c_data(), iccProfile_.size()); profile.copyBytes(0, iccProfile_.c_data(), iccProfile_.size());
} }
profile.copyBytes(iccProfile_.size(), buf.c_data(2+14), icc_size); profile.copyBytes(iccProfile_.size(), buf.c_data(2+14), icc_size);
@ -606,7 +606,7 @@ namespace Exiv2 {
enforce(start <= size, kerInvalidXmpText); enforce(start <= size, kerInvalidXmpText);
out.write(reinterpret_cast<const char*>(&xmp[start]), size - start); out.write(reinterpret_cast<const char*>(&xmp[start]), size - start);
done = !bExtXMP; done = !bExtXMP;
} else if (option == kpsIccProfile && signature.compare(iccId_) == 0) { } else if (option == kpsIccProfile && signature == iccId_) {
// extract ICCProfile // extract ICCProfile
if (size >= 16) { if (size >= 16) {
out.write(buf.c_str(16), size - 16); out.write(buf.c_str(16), size - 16);
@ -1058,7 +1058,7 @@ namespace Exiv2 {
uint8_t pad[2]; uint8_t pad[2];
pad[0] = static_cast<uint8_t>(chunk + 1); pad[0] = static_cast<uint8_t>(chunk + 1);
pad[1] = static_cast<uint8_t>(chunks); pad[1] = static_cast<uint8_t>(chunks);
outIo.write((const byte*)iccId_, 12); outIo.write(reinterpret_cast<const byte*>(iccId_), 12);
outIo.write((const byte*)pad, 2); outIo.write((const byte*)pad, 2);
if (outIo.write(iccProfile_.c_data(chunk * chunk_size), bytes) != bytes) if (outIo.write(iccProfile_.c_data(chunk * chunk_size), bytes) != bytes)
throw Error(kerImageWriteFailed); throw Error(kerImageWriteFailed);

@ -81,7 +81,7 @@ namespace Exiv2::Internal {
#if defined(_MSC_VER) || defined(__MINGW__) #if defined(_MSC_VER) || defined(__MINGW__)
char buffer[1024]; char buffer[1024];
if (SUCCEEDED(SHGetFolderPathA(NULL, CSIDL_PROFILE, NULL, 0, buffer))) { if (SUCCEEDED(SHGetFolderPathA(nullptr, CSIDL_PROFILE, nullptr, 0, buffer))) {
currentPath = buffer; currentPath = buffer;
} }
#else #else

@ -240,7 +240,7 @@ namespace Exiv2::Internal {
if (keySize >= 21 && memcmp("Raw profile type iptc", key, 21) == 0 && pImage->iptcData().empty()) { if (keySize >= 21 && memcmp("Raw profile type iptc", key, 21) == 0 && pImage->iptcData().empty()) {
DataBuf psData = readRawProfile(arr, false); DataBuf psData = readRawProfile(arr, false);
if (psData.size() > 0) { if (!psData.empty()) {
Blob iptcBlob; Blob iptcBlob;
const byte* record = nullptr; const byte* record = nullptr;
uint32_t sizeIptc = 0; uint32_t sizeIptc = 0;
@ -303,7 +303,7 @@ namespace Exiv2::Internal {
// We look if an Adobe XMP string exist. // We look if an Adobe XMP string exist.
if (keySize >= 17 && memcmp("XML:com.adobe.xmp", key, 17) == 0 && pImage->xmpData().empty()) { if (keySize >= 17 && memcmp("XML:com.adobe.xmp", key, 17) == 0 && pImage->xmpData().empty()) {
if (arr.size() > 0) { if (!arr.empty()) {
std::string& xmpPacket = pImage->xmpPacket(); std::string& xmpPacket = pImage->xmpPacket();
xmpPacket.assign(arr.c_str(), arr.size()); xmpPacket.assign(arr.c_str(), arr.size());
std::string::size_type idx = xmpPacket.find_first_of('<'); std::string::size_type idx = xmpPacket.find_first_of('<');
@ -425,7 +425,7 @@ namespace Exiv2::Internal {
} }
} while (zlibResult == Z_BUF_ERROR); } while (zlibResult == Z_BUF_ERROR);
return std::string(arr.c_str(), arr.size()); return {arr.c_str(), arr.size()};
} // PngChunk::zlibCompress } // PngChunk::zlibCompress

@ -39,8 +39,8 @@ const unsigned char pngBlank[] = { 0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,
namespace namespace
{ {
const auto nullComp = (const Exiv2::byte*)"\0\0"; const auto nullComp = reinterpret_cast<const Exiv2::byte*>("\0\0");
const auto typeICCP = (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)
{ {
assert(strlen(str) <= length); assert(strlen(str) <= length);
@ -342,7 +342,7 @@ namespace Exiv2 {
#if EXIV2_DEBUG_MESSAGES #if EXIV2_DEBUG_MESSAGES
std::cerr << Exiv2::Internal::binaryToString(makeSlice(parsedBuf.c_data(), parsedBuf.size()>50?50:parsedBuf.size(),0)) << std::endl; std::cerr << Exiv2::Internal::binaryToString(makeSlice(parsedBuf.c_data(), parsedBuf.size()>50?50:parsedBuf.size(),0)) << std::endl;
#endif #endif
if ( parsedBuf.size() ) { if (!parsedBuf.empty()) {
if ( bExif ) { if ( bExif ) {
// create memio object with the data, then print the structure // create memio object with the data, then print the structure
MemIo p(parsedBuf.c_data(6), parsedBuf.size()-6); MemIo p(parsedBuf.c_data(6), parsedBuf.size()-6);
@ -354,7 +354,7 @@ namespace Exiv2 {
} }
} }
if ( bSoft && dataBuf.size() > 0) { if (bSoft && !dataBuf.empty()) {
DataBuf s(dataBuf.size()+1); // allocate buffer with an extra byte DataBuf s(dataBuf.size()+1); // allocate buffer with an extra byte
s.copyBytes(0,dataBuf.c_data(),dataBuf.size());// copy in the dataBuf s.copyBytes(0,dataBuf.c_data(),dataBuf.size());// copy in the dataBuf
s.write_uint8(dataBuf.size(), 0); // nul terminate it s.write_uint8(dataBuf.size(), 0); // nul terminate it
@ -621,8 +621,7 @@ namespace Exiv2 {
{ {
// Update IPTC data to a new PNG chunk // Update IPTC data to a new PNG chunk
DataBuf newPsData = Photoshop::setIptcIrb(nullptr, 0, iptcData_); DataBuf newPsData = Photoshop::setIptcIrb(nullptr, 0, iptcData_);
if (newPsData.size() > 0) if (!newPsData.empty()) {
{
std::string rawIptc(newPsData.c_str(), newPsData.size()); std::string rawIptc(newPsData.c_str(), newPsData.size());
std::string chunk = PngChunk::makeMetadataChunk(rawIptc, mdIptc); std::string chunk = PngChunk::makeMetadataChunk(rawIptc, mdIptc);
if (outIo.write(reinterpret_cast<const byte*>(chunk.data()), chunk.size()) != chunk.size()) { if (outIo.write(reinterpret_cast<const byte*>(chunk.data()), chunk.size()) != chunk.size()) {
@ -642,7 +641,7 @@ namespace Exiv2 {
// calculate CRC // calculate CRC
uLong tmp = crc32(0L, Z_NULL, 0); uLong tmp = crc32(0L, Z_NULL, 0);
tmp = crc32(tmp, typeICCP, 4); tmp = crc32(tmp, typeICCP, 4);
tmp = crc32(tmp, (const Bytef*)profileName_.data(), nameLength); tmp = crc32(tmp, reinterpret_cast<const Bytef*>(profileName_.data()), nameLength);
tmp = crc32(tmp, nullComp, 2); tmp = crc32(tmp, nullComp, 2);
tmp = crc32(tmp, compressed.c_data(), static_cast<uint32_t>(compressed.size())); tmp = crc32(tmp, compressed.c_data(), static_cast<uint32_t>(compressed.size()));
byte crc[4]; byte crc[4];
@ -682,22 +681,17 @@ namespace Exiv2 {
} else if (!strcmp(szChunk, "tEXt") || !strcmp(szChunk, "zTXt") || !strcmp(szChunk, "iTXt") || } else if (!strcmp(szChunk, "tEXt") || !strcmp(szChunk, "zTXt") || !strcmp(szChunk, "iTXt") ||
!strcmp(szChunk, "iCCP")) { !strcmp(szChunk, "iCCP")) {
DataBuf key = PngChunk::keyTXTChunk(chunkBuf, true); DataBuf key = PngChunk::keyTXTChunk(chunkBuf, true);
if (key.empty() == false && ( if (!key.empty() &&
compare("Raw profile type exif", key, 21) || (compare("Raw profile type exif", key, 21) || compare("Raw profile type APP1", key, 21) ||
compare("Raw profile type APP1", key, 21) || compare("Raw profile type iptc", key, 21) || compare("Raw profile type xmp", key, 20) ||
compare("Raw profile type iptc", key, 21) || compare("XML:com.adobe.xmp", key, 17) ||
compare("Raw profile type xmp", key, 20) || compare("icc", key, 3) || // see test/data/imagemagick.png
compare("XML:com.adobe.xmp", key, 17) || compare("ICC", key, 3) || compare("Description", key, 11))) {
compare("icc", key, 3) || // see test/data/imagemagick.png
compare("ICC", key, 3) ||
compare("Description", key, 11)))
{
#ifdef EXIV2_DEBUG_MESSAGES #ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Exiv2::PngImage::doWriteMetadata: strip " << szChunk std::cout << "Exiv2::PngImage::doWriteMetadata: strip " << szChunk
<< " chunk (length: " << dataOffset << ")" << std::endl; << " chunk (length: " << dataOffset << ")" << std::endl;
#endif #endif
} else } else {
{
#ifdef EXIV2_DEBUG_MESSAGES #ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Exiv2::PngImage::doWriteMetadata: write " << szChunk std::cout << "Exiv2::PngImage::doWriteMetadata: write " << szChunk
<< " chunk (length: " << dataOffset << ")" << std::endl; << " chunk (length: " << dataOffset << ")" << std::endl;

@ -1129,6 +1129,6 @@ namespace Exiv2 {
buf = loader->getData(); buf = loader->getData();
} }
return PreviewImage(properties, std::move(buf)); return {properties, std::move(buf)};
} }
} // namespace Exiv2 } // namespace Exiv2

@ -250,7 +250,7 @@ namespace Exiv2 {
throw Error(kerFailedToReadImageData); throw Error(kerFailedToReadImageData);
ByteOrder bo = ExifParser::decode(exifData_, rawExif.c_data(), rawExif.size()); ByteOrder bo = ExifParser::decode(exifData_, rawExif.c_data(), rawExif.size());
setByteOrder(bo); setByteOrder(bo);
if (rawExif.size() > 0 && byteOrder() == invalidByteOrder) { if (!rawExif.empty() && byteOrder() == invalidByteOrder) {
#ifndef SUPPRESS_WARNINGS #ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Failed to decode Exif metadata.\n"; EXV_WARNING << "Failed to decode Exif metadata.\n";
#endif #endif
@ -579,7 +579,7 @@ namespace Exiv2 {
if (iptcData.count() > 0) { if (iptcData.count() > 0) {
DataBuf rawIptc = IptcParser::encode(iptcData); DataBuf rawIptc = IptcParser::encode(iptcData);
if (rawIptc.size() > 0) { if (!rawIptc.empty()) {
#ifdef EXIV2_DEBUG_MESSAGES #ifdef EXIV2_DEBUG_MESSAGES
std::cerr << std::hex << "write: resourceId: " << kPhotoshopResourceID_IPTC_NAA << "\n"; std::cerr << std::hex << "write: resourceId: " << kPhotoshopResourceID_IPTC_NAA << "\n";
std::cerr << std::dec << "Writing IPTC_NAA: size: " << rawIptc.size() << "\n"; std::cerr << std::dec << "Writing IPTC_NAA: size: " << rawIptc.size() << "\n";

@ -1391,7 +1391,7 @@ namespace Exiv2::Internal {
cryptFct = sonyTagEncipher; cryptFct = sonyTagEncipher;
} }
DataBuf buf = cryptFct(tag(), mio.mmap(), static_cast<uint32_t>(mio.size()), pRoot_); DataBuf buf = cryptFct(tag(), mio.mmap(), static_cast<uint32_t>(mio.size()), pRoot_);
if ( buf.size()) { if (!buf.empty()) {
mio.seek(0,Exiv2::FileIo::beg); mio.seek(0,Exiv2::FileIo::beg);
mio.write(buf.c_data(), buf.size()); mio.write(buf.c_data(), buf.size());
} }
@ -1522,7 +1522,7 @@ namespace Exiv2::Internal {
if (component->tag() == 0x014a) { if (component->tag() == 0x014a) {
// Hack: delay writing of sub-IFD image data to get the order correct // Hack: delay writing of sub-IFD image data to get the order correct
#ifndef SUPPRESS_WARNINGS #ifndef SUPPRESS_WARNINGS
if (pSubIfd != 0) { if (pSubIfd) {
EXV_ERROR << "Multiple sub-IFD image data tags found\n"; EXV_ERROR << "Multiple sub-IFD image data tags found\n";
} }
#endif #endif

@ -2043,7 +2043,7 @@ namespace Exiv2::Internal {
} }
auto rootDir = parse(pData, size, root, pHeader); auto rootDir = parse(pData, size, root, pHeader);
if (nullptr != rootDir.get()) { if (rootDir) {
TiffDecoder decoder(exifData, TiffDecoder decoder(exifData,
iptcData, iptcData,
xmpData, xmpData,
@ -2081,7 +2081,7 @@ namespace Exiv2::Internal {
auto parsedTree = parse(pData, size, root, pHeader); auto parsedTree = parse(pData, size, root, pHeader);
PrimaryGroups primaryGroups; PrimaryGroups primaryGroups;
findPrimaryGroups(primaryGroups, parsedTree.get()); findPrimaryGroups(primaryGroups, parsedTree.get());
if (nullptr != parsedTree.get()) { if (parsedTree) {
// Attempt to update existing TIFF components based on metadata entries // Attempt to update existing TIFF components based on metadata entries
TiffEncoder encoder(exifData, TiffEncoder encoder(exifData,
iptcData, iptcData,
@ -2096,14 +2096,14 @@ namespace Exiv2::Internal {
} }
if (writeMethod == wmIntrusive) { if (writeMethod == wmIntrusive) {
auto createdTree = TiffCreator::create(root, ifdIdNotSet); auto createdTree = TiffCreator::create(root, ifdIdNotSet);
if (nullptr != parsedTree.get()) { if (parsedTree) {
// Copy image tags from the original image to the composite // Copy image tags from the original image to the composite
TiffCopier copier(createdTree.get(), root, pHeader, &primaryGroups); TiffCopier copier(createdTree.get(), root, pHeader, &primaryGroups);
parsedTree->accept(copier); parsedTree->accept(copier);
} }
// Add entries from metadata to composite // Add entries from metadata to composite
TiffEncoder encoder(exifData, iptcData, xmpData, createdTree.get(), parsedTree.get() == nullptr, TiffEncoder encoder(exifData, iptcData, xmpData, createdTree.get(), parsedTree == nullptr, &primaryGroups,
&primaryGroups, pHeader, findEncoderFct); pHeader, findEncoderFct);
encoder.add(createdTree.get(), parsedTree.get(), root); encoder.add(createdTree.get(), parsedTree.get(), root);
// Write binary representation from the composite tree // Write binary representation from the composite tree
DataBuf header = pHeader->write(); DataBuf header = pHeader->write();

@ -599,7 +599,7 @@ namespace Exiv2::Internal {
if (pos != exifData_.end()) { if (pos != exifData_.end()) {
irbKey.setIdx(pos->idx()); irbKey.setIdx(pos->idx());
} }
if (rawIptc.size() != 0 && (del || pos == exifData_.end())) { if (!rawIptc.empty() && (del || pos == exifData_.end())) {
auto value = Value::create(unsignedLong); auto value = Value::create(unsignedLong);
DataBuf buf; DataBuf buf;
if (rawIptc.size() % 4 != 0) { if (rawIptc.size() % 4 != 0) {
@ -622,7 +622,7 @@ namespace Exiv2::Internal {
pos->value().copy(irbBuf.data(), invalidByteOrder); pos->value().copy(irbBuf.data(), invalidByteOrder);
irbBuf = Photoshop::setIptcIrb(irbBuf.c_data(), irbBuf.size(), iptcData_); irbBuf = Photoshop::setIptcIrb(irbBuf.c_data(), irbBuf.size(), iptcData_);
exifData_.erase(pos); exifData_.erase(pos);
if (irbBuf.size() != 0) { if (!irbBuf.empty()) {
auto value = Value::create(unsignedByte); auto value = Value::create(unsignedByte);
value->read(irbBuf.data(), static_cast<long>(irbBuf.size()), invalidByteOrder); value->read(irbBuf.data(), static_cast<long>(irbBuf.size()), invalidByteOrder);
Exifdatum iptcDatum(irbKey, value.get()); Exifdatum iptcDatum(irbKey, value.get());
@ -815,7 +815,7 @@ namespace Exiv2::Internal {
if (cryptFct != nullptr) { if (cryptFct != nullptr) {
const byte* pData = object->pData(); const byte* pData = object->pData();
DataBuf buf = cryptFct(object->tag(), pData, size, pRoot_); DataBuf buf = cryptFct(object->tag(), pData, size, pRoot_);
if (buf.size() > 0) { if (!buf.empty()) {
pData = buf.c_data(); pData = buf.c_data();
size = static_cast<int32_t>(buf.size()); size = static_cast<int32_t>(buf.size());
} }
@ -930,7 +930,7 @@ namespace Exiv2::Internal {
std::cerr << "Writing data area for " << key << "\n"; std::cerr << "Writing data area for " << key << "\n";
#endif #endif
DataBuf buf = object->pValue()->dataArea(); DataBuf buf = object->pValue()->dataArea();
if ( buf.size() > 0 ) { if (!buf.empty()) {
memcpy(object->pDataArea_, buf.c_data(), buf.size()); memcpy(object->pDataArea_, buf.c_data(), buf.size());
if (object->sizeDataArea_ > static_cast<size_t>(buf.size())) { if (object->sizeDataArea_ > static_cast<size_t>(buf.size())) {
memset(object->pDataArea_ + buf.size(), memset(object->pDataArea_ + buf.size(),
@ -1588,7 +1588,7 @@ namespace Exiv2::Internal {
} }
} }
auto v = Value::create(typeId); auto v = Value::create(typeId);
enforce(v.get() != nullptr, kerCorruptedMetadata); enforce(v != nullptr, kerCorruptedMetadata);
v->read(pData, size, byteOrder()); v->read(pData, size, byteOrder());
object->setValue(std::move(v)); object->setValue(std::move(v));
@ -1639,7 +1639,8 @@ namespace Exiv2::Internal {
std::shared_ptr<DataBuf> buf = std::make_shared<DataBuf>( std::shared_ptr<DataBuf> buf = std::make_shared<DataBuf>(
cryptFct(object->tag(), pData, size, pRoot_) cryptFct(object->tag(), pData, size, pRoot_)
); );
if (buf->size() > 0) object->setData(buf); if (!buf->empty())
object->setData(buf);
} }
const ArrayDef* defs = object->def(); const ArrayDef* defs = object->def();
@ -1689,7 +1690,7 @@ namespace Exiv2::Internal {
if (bo == invalidByteOrder) bo = byteOrder(); if (bo == invalidByteOrder) bo = byteOrder();
TypeId typeId = toTypeId(object->elDef()->tiffType_, object->tag(), object->group()); TypeId typeId = toTypeId(object->elDef()->tiffType_, object->tag(), object->group());
auto v = Value::create(typeId); auto v = Value::create(typeId);
enforce(v.get() != nullptr, kerCorruptedMetadata); enforce(v != nullptr, kerCorruptedMetadata);
v->read(pData, size, bo); v->read(pData, size, bo);
object->setValue(std::move(v)); object->setValue(std::move(v));

@ -155,8 +155,8 @@ static std::vector<std::string> getLoadedLibraries()
if ( isatty(STDIN_FILENO) ) { if ( isatty(STDIN_FILENO) ) {
unsigned int n; unsigned int n;
struct procstat* procstat = procstat_open_sysctl(); struct procstat* procstat = procstat_open_sysctl();
struct kinfo_proc* procs = procstat ? procstat_getprocs(procstat, KERN_PROC_PID, getpid(), &n) : NULL; struct kinfo_proc* procs = procstat ? procstat_getprocs(procstat, KERN_PROC_PID, getpid(), &n) : nullptr;
struct filestat_list* files = procs ? procstat_getfiles(procstat, procs, true) : NULL; struct filestat_list* files = procs ? procstat_getfiles(procstat, procs, true) : nullptr;
if ( files ) { if ( files ) {
filestat* entry; filestat* entry;
STAILQ_FOREACH(entry, files, next) { STAILQ_FOREACH(entry, files, next) {
@ -194,7 +194,7 @@ static std::vector<std::string> getLoadedLibraries()
} }
#endif #endif
if (libs.empty()) if (libs.empty())
libs.push_back("unknown"); libs.emplace_back("unknown");
return libs; return libs;
} }

@ -570,28 +570,28 @@ namespace Exiv2 {
pLockData_ = pLockData; pLockData_ = pLockData;
initialized_ = SXMPMeta::Initialize(); initialized_ = SXMPMeta::Initialize();
#ifdef EXV_ADOBE_XMPSDK #ifdef EXV_ADOBE_XMPSDK
SXMPMeta::RegisterNamespace("http://ns.adobe.com/lightroom/1.0/", "lr",NULL); SXMPMeta::RegisterNamespace("http://ns.adobe.com/lightroom/1.0/", "lr", nullptr);
SXMPMeta::RegisterNamespace("http://rs.tdwg.org/dwc/index.htm", "dwc",NULL); SXMPMeta::RegisterNamespace("http://rs.tdwg.org/dwc/index.htm", "dwc", nullptr);
SXMPMeta::RegisterNamespace("http://purl.org/dc/terms/", "dcterms",NULL); SXMPMeta::RegisterNamespace("http://purl.org/dc/terms/", "dcterms", nullptr);
SXMPMeta::RegisterNamespace("http://www.digikam.org/ns/1.0/", "digiKam",NULL); SXMPMeta::RegisterNamespace("http://www.digikam.org/ns/1.0/", "digiKam", nullptr);
SXMPMeta::RegisterNamespace("http://www.digikam.org/ns/kipi/1.0/", "kipi",NULL); SXMPMeta::RegisterNamespace("http://www.digikam.org/ns/kipi/1.0/", "kipi", nullptr);
SXMPMeta::RegisterNamespace("http://ns.microsoft.com/photo/1.0/", "MicrosoftPhoto",NULL); SXMPMeta::RegisterNamespace("http://ns.microsoft.com/photo/1.0/", "MicrosoftPhoto", nullptr);
SXMPMeta::RegisterNamespace("http://ns.acdsee.com/iptc/1.0/", "acdsee",NULL); SXMPMeta::RegisterNamespace("http://ns.acdsee.com/iptc/1.0/", "acdsee", nullptr);
SXMPMeta::RegisterNamespace("http://iptc.org/std/Iptc4xmpExt/2008-02-29/", "iptcExt",NULL); SXMPMeta::RegisterNamespace("http://iptc.org/std/Iptc4xmpExt/2008-02-29/", "iptcExt", nullptr);
SXMPMeta::RegisterNamespace("http://ns.useplus.org/ldf/xmp/1.0/", "plus",NULL); SXMPMeta::RegisterNamespace("http://ns.useplus.org/ldf/xmp/1.0/", "plus", nullptr);
SXMPMeta::RegisterNamespace("http://ns.iview-multimedia.com/mediapro/1.0/", "mediapro",NULL); SXMPMeta::RegisterNamespace("http://ns.iview-multimedia.com/mediapro/1.0/", "mediapro", nullptr);
SXMPMeta::RegisterNamespace("http://ns.microsoft.com/expressionmedia/1.0/", "expressionmedia",NULL); SXMPMeta::RegisterNamespace("http://ns.microsoft.com/expressionmedia/1.0/", "expressionmedia", nullptr);
SXMPMeta::RegisterNamespace("http://ns.microsoft.com/photo/1.2/", "MP",NULL); SXMPMeta::RegisterNamespace("http://ns.microsoft.com/photo/1.2/", "MP", nullptr);
SXMPMeta::RegisterNamespace("http://ns.microsoft.com/photo/1.2/t/RegionInfo#", "MPRI",NULL); SXMPMeta::RegisterNamespace("http://ns.microsoft.com/photo/1.2/t/RegionInfo#", "MPRI", nullptr);
SXMPMeta::RegisterNamespace("http://ns.microsoft.com/photo/1.2/t/Region#", "MPReg",NULL); SXMPMeta::RegisterNamespace("http://ns.microsoft.com/photo/1.2/t/Region#", "MPReg", nullptr);
SXMPMeta::RegisterNamespace("http://ns.google.com/photos/1.0/panorama/", "GPano",NULL); SXMPMeta::RegisterNamespace("http://ns.google.com/photos/1.0/panorama/", "GPano", nullptr);
SXMPMeta::RegisterNamespace("http://www.metadataworkinggroup.com/schemas/regions/", "mwg-rs",NULL); SXMPMeta::RegisterNamespace("http://www.metadataworkinggroup.com/schemas/regions/", "mwg-rs", nullptr);
SXMPMeta::RegisterNamespace("http://www.metadataworkinggroup.com/schemas/keywords/", "mwg-kw",NULL); SXMPMeta::RegisterNamespace("http://www.metadataworkinggroup.com/schemas/keywords/", "mwg-kw", nullptr);
SXMPMeta::RegisterNamespace("http://ns.adobe.com/xmp/sType/Area#", "stArea",NULL); SXMPMeta::RegisterNamespace("http://ns.adobe.com/xmp/sType/Area#", "stArea", nullptr);
SXMPMeta::RegisterNamespace("http://cipa.jp/exif/1.0/", "exifEX",NULL); SXMPMeta::RegisterNamespace("http://cipa.jp/exif/1.0/", "exifEX", nullptr);
SXMPMeta::RegisterNamespace("http://ns.adobe.com/camera-raw-saved-settings/1.0/", "crss",NULL); SXMPMeta::RegisterNamespace("http://ns.adobe.com/camera-raw-saved-settings/1.0/", "crss", nullptr);
SXMPMeta::RegisterNamespace("http://www.audio/", "audio",NULL); SXMPMeta::RegisterNamespace("http://www.audio/", "audio", nullptr);
SXMPMeta::RegisterNamespace("http://www.video/", "video",NULL); SXMPMeta::RegisterNamespace("http://www.video/", "video", nullptr);
#else #else
SXMPMeta::RegisterNamespace("http://ns.adobe.com/lightroom/1.0/", "lr"); SXMPMeta::RegisterNamespace("http://ns.adobe.com/lightroom/1.0/", "lr");
SXMPMeta::RegisterNamespace("http://rs.tdwg.org/dwc/index.htm", "dwc"); SXMPMeta::RegisterNamespace("http://rs.tdwg.org/dwc/index.htm", "dwc");
@ -700,7 +700,7 @@ namespace Exiv2 {
AutoLock autoLock(xmpLockFct_, pLockData_); AutoLock autoLock(xmpLockFct_, pLockData_);
SXMPMeta::DeleteNamespace(ns.c_str()); SXMPMeta::DeleteNamespace(ns.c_str());
#ifdef EXV_ADOBE_XMPSDK #ifdef EXV_ADOBE_XMPSDK
SXMPMeta::RegisterNamespace(ns.c_str(), prefix.c_str(),NULL); SXMPMeta::RegisterNamespace(ns.c_str(), prefix.c_str(), nullptr);
#else #else
SXMPMeta::RegisterNamespace(ns.c_str(), prefix.c_str()); SXMPMeta::RegisterNamespace(ns.c_str(), prefix.c_str());
#endif #endif
@ -794,7 +794,7 @@ namespace Exiv2 {
} }
val->value_[propValue] = text; val->value_[propValue] = text;
} }
xmpData.add(*key.get(), val.get()); xmpData.add(*key, val.get());
continue; continue;
} }
if ( XMP_PropIsArray(opt) if ( XMP_PropIsArray(opt)
@ -825,7 +825,7 @@ namespace Exiv2 {
printNode(schemaNs, propPath, propValue, opt); printNode(schemaNs, propPath, propValue, opt);
val->read(propValue); val->read(propValue);
} }
xmpData.add(*key.get(), val.get()); xmpData.add(*key, val.get());
continue; continue;
} }
} }
@ -835,12 +835,12 @@ namespace Exiv2 {
// Create a metadatum with only XMP options // Create a metadatum with only XMP options
val->setXmpArrayType(xmpArrayType(opt)); val->setXmpArrayType(xmpArrayType(opt));
val->setXmpStruct(xmpStruct(opt)); val->setXmpStruct(xmpStruct(opt));
xmpData.add(*key.get(), val.get()); xmpData.add(*key, val.get());
continue; continue;
} }
if (XMP_PropIsSimple(opt) || XMP_PropIsQualifier(opt)) { if (XMP_PropIsSimple(opt) || XMP_PropIsQualifier(opt)) {
val->read(propValue); val->read(propValue);
xmpData.add(*key.get(), val.get()); xmpData.add(*key, val.get());
continue; continue;
} }
// Don't let any node go by unnoticed // Don't let any node go by unnoticed

Loading…
Cancel
Save