Update .clang-format file & apply clang-format to whole project
This commit is contained in:
+880
-877
File diff suppressed because it is too large
Load Diff
+131
-144
@@ -12,168 +12,155 @@
|
||||
|
||||
// *****************************************************************************
|
||||
// namespace extensions
|
||||
namespace Exiv2
|
||||
{
|
||||
EXIV2API bool enableBMFF(bool enable = true);
|
||||
namespace Exiv2 {
|
||||
EXIV2API bool enableBMFF(bool enable = true);
|
||||
}
|
||||
|
||||
#ifdef EXV_ENABLE_BMFF
|
||||
namespace Exiv2
|
||||
{
|
||||
struct Iloc
|
||||
{
|
||||
explicit Iloc(uint32_t ID = 0, uint32_t start = 0, uint32_t length = 0)
|
||||
: ID_(ID), start_(start), length_(length){};
|
||||
virtual ~Iloc() = default;
|
||||
namespace Exiv2 {
|
||||
struct Iloc {
|
||||
explicit Iloc(uint32_t ID = 0, uint32_t start = 0, uint32_t length = 0) : ID_(ID), start_(start), length_(length){};
|
||||
virtual ~Iloc() = default;
|
||||
|
||||
uint32_t ID_;
|
||||
uint32_t start_;
|
||||
uint32_t length_;
|
||||
uint32_t ID_;
|
||||
uint32_t start_;
|
||||
uint32_t length_;
|
||||
|
||||
std::string toString() const;
|
||||
}; // class Iloc
|
||||
std::string toString() const;
|
||||
}; // class Iloc
|
||||
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
|
||||
/*!
|
||||
@brief Class to access BMFF images.
|
||||
*/
|
||||
class EXIV2API BmffImage : public Image
|
||||
{
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor to open a BMFF image. Since the
|
||||
constructor can not return a result, callers should check the
|
||||
good() method after object construction to determine success
|
||||
or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
@param create Specifies if an existing image should be read (false)
|
||||
or if a new file should be created (true).
|
||||
*/
|
||||
BmffImage(BasicIo::UniquePtr io, bool create);
|
||||
//@}
|
||||
/*!
|
||||
@brief Class to access BMFF images.
|
||||
*/
|
||||
class EXIV2API BmffImage : public Image {
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor to open a BMFF image. Since the
|
||||
constructor can not return a result, callers should check the
|
||||
good() method after object construction to determine success
|
||||
or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
@param create Specifies if an existing image should be read (false)
|
||||
or if a new file should be created (true).
|
||||
*/
|
||||
BmffImage(BasicIo::UniquePtr io, bool create);
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/*!
|
||||
@brief parse embedded tiff file (Exif metadata)
|
||||
@param root_tag root of parse tree Tag::root, Tag::cmt2 etc.
|
||||
@param length tiff block length
|
||||
@param start offset in file (default, io_->tell())
|
||||
@
|
||||
*/
|
||||
void parseTiff(uint32_t root_tag, uint64_t length);
|
||||
void parseTiff(uint32_t root_tag, uint64_t length,uint64_t start);
|
||||
//@}
|
||||
//@{
|
||||
/*!
|
||||
@brief parse embedded tiff file (Exif metadata)
|
||||
@param root_tag root of parse tree Tag::root, Tag::cmt2 etc.
|
||||
@param length tiff block length
|
||||
@param start offset in file (default, io_->tell())
|
||||
@
|
||||
*/
|
||||
void parseTiff(uint32_t root_tag, uint64_t length);
|
||||
void parseTiff(uint32_t root_tag, uint64_t length, uint64_t start);
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/*!
|
||||
@brief parse embedded xmp/xml
|
||||
@param length xmp block length
|
||||
@param start offset in file
|
||||
@
|
||||
*/
|
||||
void parseXmp(uint64_t length,uint64_t start);
|
||||
//@}
|
||||
//@{
|
||||
/*!
|
||||
@brief parse embedded xmp/xml
|
||||
@param length xmp block length
|
||||
@param start offset in file
|
||||
@
|
||||
*/
|
||||
void parseXmp(uint64_t length, uint64_t start);
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/*!
|
||||
@brief Parse a Canon PRVW or THMB box and add an entry to the set
|
||||
of native previews.
|
||||
@param data Buffer containing the box
|
||||
@param out Logging stream
|
||||
@param bTrace Controls logging
|
||||
@param width_offset Index of image width field in data
|
||||
@param height_offset Index of image height field in data
|
||||
@param size_offset Index of image size field in data
|
||||
@param relative_position Location of the start of image data in the file,
|
||||
relative to the current file position indicator.
|
||||
*/
|
||||
void parseCr3Preview(DataBuf &data,
|
||||
std::ostream &out,
|
||||
bool bTrace,
|
||||
uint8_t version,
|
||||
size_t width_offset,
|
||||
size_t height_offset,
|
||||
size_t size_offset,
|
||||
size_t relative_position);
|
||||
//@}
|
||||
//@{
|
||||
/*!
|
||||
@brief Parse a Canon PRVW or THMB box and add an entry to the set
|
||||
of native previews.
|
||||
@param data Buffer containing the box
|
||||
@param out Logging stream
|
||||
@param bTrace Controls logging
|
||||
@param width_offset Index of image width field in data
|
||||
@param height_offset Index of image height field in data
|
||||
@param size_offset Index of image size field in data
|
||||
@param relative_position Location of the start of image data in the file,
|
||||
relative to the current file position indicator.
|
||||
*/
|
||||
void parseCr3Preview(DataBuf& data, std::ostream& out, bool bTrace, uint8_t version, size_t width_offset,
|
||||
size_t height_offset, size_t size_offset, size_t relative_position);
|
||||
//@}
|
||||
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void readMetadata() override /* override */;
|
||||
void writeMetadata() override /* override */;
|
||||
void setComment(std::string_view comment) override /* override */;
|
||||
void printStructure(std::ostream& out, Exiv2::PrintStructureOption option, int depth) override;
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void readMetadata() override /* override */;
|
||||
void writeMetadata() override /* override */;
|
||||
void setComment(std::string_view comment) override /* override */;
|
||||
void printStructure(std::ostream& out, Exiv2::PrintStructureOption option, int depth) override;
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override /* override */;
|
||||
uint32_t pixelWidth() const override;
|
||||
uint32_t pixelHeight() const override;
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override /* override */;
|
||||
uint32_t pixelWidth() const override;
|
||||
uint32_t pixelHeight() const override;
|
||||
//@}
|
||||
|
||||
Exiv2::ByteOrder endian_{Exiv2::bigEndian};
|
||||
Exiv2::ByteOrder endian_{Exiv2::bigEndian};
|
||||
|
||||
private:
|
||||
void openOrThrow();
|
||||
/*!
|
||||
@brief recursiveBoxHandler
|
||||
@throw Error if we visit a box more than once
|
||||
@param pbox_end The end location of the parent box. Boxes are
|
||||
nested, so we must not read beyond this.
|
||||
@return address of next box
|
||||
@warning This function should only be called by readMetadata()
|
||||
*/
|
||||
long boxHandler(std::ostream& out, Exiv2::PrintStructureOption option,
|
||||
const long pbox_end, int depth);
|
||||
std::string indent(int i)
|
||||
{
|
||||
return std::string(2*i,' ');
|
||||
}
|
||||
private:
|
||||
void openOrThrow();
|
||||
/*!
|
||||
@brief recursiveBoxHandler
|
||||
@throw Error if we visit a box more than once
|
||||
@param pbox_end The end location of the parent box. Boxes are
|
||||
nested, so we must not read beyond this.
|
||||
@return address of next box
|
||||
@warning This function should only be called by readMetadata()
|
||||
*/
|
||||
long boxHandler(std::ostream& out, Exiv2::PrintStructureOption option, const long pbox_end, int depth);
|
||||
std::string indent(int i) {
|
||||
return std::string(2 * i, ' ');
|
||||
}
|
||||
|
||||
uint32_t fileType_{0};
|
||||
std::set<uint64_t> visits_;
|
||||
uint64_t visits_max_{0};
|
||||
uint16_t unknownID_{0xffff};
|
||||
uint16_t exifID_{0xffff};
|
||||
uint16_t xmpID_{0};
|
||||
std::map<uint32_t, Iloc> ilocs_;
|
||||
bool bReadMetadata_{false};
|
||||
//@}
|
||||
uint32_t fileType_{0};
|
||||
std::set<uint64_t> visits_;
|
||||
uint64_t visits_max_{0};
|
||||
uint16_t unknownID_{0xffff};
|
||||
uint16_t exifID_{0xffff};
|
||||
uint16_t xmpID_{0};
|
||||
std::map<uint32_t, Iloc> ilocs_;
|
||||
bool bReadMetadata_{false};
|
||||
//@}
|
||||
|
||||
/*!
|
||||
@brief box utilities
|
||||
*/
|
||||
static std::string toAscii(long n);
|
||||
std::string boxName(uint32_t box);
|
||||
static bool superBox(uint32_t box);
|
||||
static bool fullBox(uint32_t box);
|
||||
static std::string uuidName(Exiv2::DataBuf& uuid);
|
||||
/*!
|
||||
@brief box utilities
|
||||
*/
|
||||
static std::string toAscii(long n);
|
||||
std::string boxName(uint32_t box);
|
||||
static bool superBox(uint32_t box);
|
||||
static bool fullBox(uint32_t box);
|
||||
static std::string uuidName(Exiv2::DataBuf& uuid);
|
||||
|
||||
}; // class BmffImage
|
||||
}; // class BmffImage
|
||||
|
||||
// *****************************************************************************
|
||||
// template, inline and free functions
|
||||
// *****************************************************************************
|
||||
// template, inline and free functions
|
||||
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new BMFF instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newBmffInstance(BasicIo::UniquePtr io, bool create);
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new BMFF instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newBmffInstance(BasicIo::UniquePtr io, bool create);
|
||||
|
||||
//! Check if the file iIo is a BMFF image.
|
||||
EXIV2API bool isBmffType(BasicIo& iIo, bool advance);
|
||||
//! Check if the file iIo is a BMFF image.
|
||||
EXIV2API bool isBmffType(BasicIo& iIo, bool advance);
|
||||
} // namespace Exiv2
|
||||
#endif // EXV_ENABLE_BMFF
|
||||
#endif // EXV_ENABLE_BMFF
|
||||
|
||||
+58
-59
@@ -17,79 +17,78 @@
|
||||
// *****************************************************************************
|
||||
// namespace extensions
|
||||
namespace Exiv2 {
|
||||
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
|
||||
/*!
|
||||
@brief Class to access Windows bitmaps. This is just a stub - we only
|
||||
read width and height.
|
||||
*/
|
||||
class EXIV2API BmpImage : public Image {
|
||||
public:
|
||||
//! @name NOT Implemented
|
||||
//@{
|
||||
//! Copy constructor
|
||||
BmpImage(const BmpImage& rhs) = delete;
|
||||
//! Assignment operator
|
||||
BmpImage& operator=(const BmpImage& rhs) = delete;
|
||||
//@}
|
||||
/*!
|
||||
@brief Class to access Windows bitmaps. This is just a stub - we only
|
||||
read width and height.
|
||||
*/
|
||||
class EXIV2API BmpImage : public Image {
|
||||
public:
|
||||
//! @name NOT Implemented
|
||||
//@{
|
||||
//! Copy constructor
|
||||
BmpImage(const BmpImage& rhs) = delete;
|
||||
//! Assignment operator
|
||||
BmpImage& operator=(const BmpImage& rhs) = delete;
|
||||
//@}
|
||||
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor to open a Windows bitmap image. Since the
|
||||
constructor can not return a result, callers should check the
|
||||
good() method after object construction to determine success
|
||||
or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
*/
|
||||
explicit BmpImage(BasicIo::UniquePtr io);
|
||||
//@}
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor to open a Windows bitmap image. Since the
|
||||
constructor can not return a result, callers should check the
|
||||
good() method after object construction to determine success
|
||||
or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
*/
|
||||
explicit BmpImage(BasicIo::UniquePtr io);
|
||||
//@}
|
||||
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void readMetadata() override;
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void readMetadata() override;
|
||||
|
||||
/// @throws Error(ErrorCode::kerWritingImageFormatUnsupported).
|
||||
void writeMetadata() override;
|
||||
/// @throws Error(ErrorCode::kerWritingImageFormatUnsupported).
|
||||
void writeMetadata() override;
|
||||
|
||||
/// @throws Error(ErrorCode::kerInvalidSettingForImage)
|
||||
void setExifData(const ExifData& exifData) override;
|
||||
/// @throws Error(ErrorCode::kerInvalidSettingForImage)
|
||||
void setExifData(const ExifData& exifData) override;
|
||||
|
||||
/// @throws Error(ErrorCode::kerInvalidSettingForImage)
|
||||
void setIptcData(const IptcData& iptcData) override;
|
||||
/// @throws Error(ErrorCode::kerInvalidSettingForImage)
|
||||
void setIptcData(const IptcData& iptcData) override;
|
||||
|
||||
/// @throws Error(ErrorCode::kerInvalidSettingForImage)
|
||||
void setComment(std::string_view comment) override;
|
||||
//@}
|
||||
/// @throws Error(ErrorCode::kerInvalidSettingForImage)
|
||||
void setComment(std::string_view comment) override;
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override;
|
||||
//@}
|
||||
}; // class BmpImage
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override;
|
||||
//@}
|
||||
}; // class BmpImage
|
||||
|
||||
// *****************************************************************************
|
||||
// template, inline and free functions
|
||||
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new BmpImage instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newBmpInstance(BasicIo::UniquePtr io, bool create);
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new BmpImage instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newBmpInstance(BasicIo::UniquePtr io, bool create);
|
||||
|
||||
//! Check if the file iIo is a Windows Bitmap image.
|
||||
EXIV2API bool isBmpType(BasicIo& iIo, bool advance);
|
||||
//! Check if the file iIo is a Windows Bitmap image.
|
||||
EXIV2API bool isBmpType(BasicIo& iIo, bool advance);
|
||||
|
||||
} // namespace Exiv2
|
||||
} // namespace Exiv2
|
||||
|
||||
#endif // #ifndef BMPIMAGE_HPP_
|
||||
#endif // #ifndef BMPIMAGE_HPP_
|
||||
|
||||
+36
-36
@@ -4,12 +4,12 @@
|
||||
#define _CONFIG_H_
|
||||
|
||||
///// Start of Visual Studio Support /////
|
||||
#ifdef _MSC_VER
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#pragma warning(disable : 4996) // Disable warnings about 'deprecated' standard functions
|
||||
#pragma warning(disable : 4251) // Disable warnings from std templates about exporting interfaces
|
||||
#pragma warning(disable : 4996) // Disable warnings about 'deprecated' standard functions
|
||||
#pragma warning(disable : 4251) // Disable warnings from std templates about exporting interfaces
|
||||
|
||||
#endif // _MSC_VER
|
||||
#endif // _MSC_VER
|
||||
///// End of Visual Studio Support /////
|
||||
|
||||
#include "exv_conf.h"
|
||||
@@ -17,32 +17,32 @@
|
||||
|
||||
///// Start of platform macros /////////
|
||||
#if defined(__MINGW32__) || defined(__MINGW64__)
|
||||
# ifndef __MING__
|
||||
# define __MING__ 1
|
||||
# endif
|
||||
# ifndef __MINGW__
|
||||
# define __MINGW__ 1
|
||||
# endif
|
||||
#ifndef __MING__
|
||||
#define __MING__ 1
|
||||
#endif
|
||||
#ifndef __MINGW__
|
||||
#define __MINGW__ 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __CYGWIN__
|
||||
# if defined(__CYGWIN32__) || defined(__CYGWIN64__)
|
||||
# define __CYGWIN__ 1
|
||||
# endif
|
||||
#if defined(__CYGWIN32__) || defined(__CYGWIN64__)
|
||||
#define __CYGWIN__ 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __LITTLE_ENDIAN__
|
||||
# if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__)
|
||||
# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
# define __LITTLE_ENDIAN__ 1
|
||||
# endif
|
||||
# endif
|
||||
#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__)
|
||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
#define __LITTLE_ENDIAN__ 1
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __LITTLE_ENDIAN__
|
||||
# if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW__)
|
||||
# define __LITTLE_ENDIAN__ 1
|
||||
# endif
|
||||
#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW__)
|
||||
#define __LITTLE_ENDIAN__ 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -50,26 +50,26 @@
|
||||
you must -library=stdcxx4 along with these inclusions below
|
||||
*/
|
||||
#if defined(OS_SOLARIS)
|
||||
# include <string.h>
|
||||
# include <strings.h>
|
||||
# include <math.h>
|
||||
# if defined(__cplusplus)
|
||||
# include <ios>
|
||||
# include <fstream>
|
||||
# endif
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#if defined(__cplusplus)
|
||||
#include <fstream>
|
||||
#include <ios>
|
||||
#endif
|
||||
#endif
|
||||
///// End of platform macros /////////
|
||||
|
||||
///// Path separator macros /////
|
||||
#ifndef EXV_SEPARATOR_STR
|
||||
# if defined(WIN32) && !defined(__CYGWIN__)
|
||||
# define EXV_SEPARATOR_STR "\\"
|
||||
# define EXV_SEPARATOR_CHR '\\'
|
||||
# else
|
||||
# define EXV_SEPARATOR_STR "/"
|
||||
# define EXV_SEPARATOR_CHR '/'
|
||||
# endif
|
||||
#if defined(WIN32) && !defined(__CYGWIN__)
|
||||
#define EXV_SEPARATOR_STR "\\"
|
||||
#define EXV_SEPARATOR_CHR '\\'
|
||||
#else
|
||||
#define EXV_SEPARATOR_STR "/"
|
||||
#define EXV_SEPARATOR_CHR '/'
|
||||
#endif
|
||||
#endif
|
||||
//////////////////////////////////////
|
||||
|
||||
#endif // _CONFIG_H_
|
||||
#endif // _CONFIG_H_
|
||||
|
||||
+54
-55
@@ -24,75 +24,74 @@
|
||||
// *****************************************************************************
|
||||
// namespace extensions
|
||||
namespace Exiv2 {
|
||||
|
||||
// *****************************************************************************
|
||||
// class declarations
|
||||
class ExifData;
|
||||
class IptcData;
|
||||
class XmpData;
|
||||
class ExifData;
|
||||
class IptcData;
|
||||
class XmpData;
|
||||
|
||||
// *****************************************************************************
|
||||
// free functions, template and inline definitions
|
||||
|
||||
//! Convert (copy) Exif tags to XMP properties.
|
||||
EXIV2API void copyExifToXmp(const ExifData& exifData, XmpData& xmpData);
|
||||
//! Convert (move) Exif tags to XMP properties, remove converted Exif tags.
|
||||
EXIV2API void moveExifToXmp(ExifData& exifData, XmpData& xmpData);
|
||||
//! Convert (copy) Exif tags to XMP properties.
|
||||
EXIV2API void copyExifToXmp(const ExifData& exifData, XmpData& xmpData);
|
||||
//! Convert (move) Exif tags to XMP properties, remove converted Exif tags.
|
||||
EXIV2API void moveExifToXmp(ExifData& exifData, XmpData& xmpData);
|
||||
|
||||
//! Convert (copy) XMP properties to Exif tags.
|
||||
EXIV2API void copyXmpToExif(const XmpData& xmpData, ExifData& exifData);
|
||||
//! Convert (move) XMP properties to Exif tags, remove converted XMP properties.
|
||||
EXIV2API void moveXmpToExif(XmpData& xmpData, ExifData& exifData);
|
||||
//! Convert (copy) XMP properties to Exif tags.
|
||||
EXIV2API void copyXmpToExif(const XmpData& xmpData, ExifData& exifData);
|
||||
//! Convert (move) XMP properties to Exif tags, remove converted XMP properties.
|
||||
EXIV2API void moveXmpToExif(XmpData& xmpData, ExifData& exifData);
|
||||
|
||||
//! Detect which metadata are newer and perform a copy in appropriate direction.
|
||||
EXIV2API void syncExifWithXmp(ExifData& exifData, XmpData& xmpData);
|
||||
//! Detect which metadata are newer and perform a copy in appropriate direction.
|
||||
EXIV2API void syncExifWithXmp(ExifData& exifData, XmpData& xmpData);
|
||||
|
||||
//! Convert (copy) IPTC datasets to XMP properties.
|
||||
EXIV2API void copyIptcToXmp(const IptcData& iptcData, XmpData& xmpData, const char* iptcCharset = nullptr);
|
||||
//! Convert (move) IPTC datasets to XMP properties, remove converted IPTC datasets.
|
||||
EXIV2API void moveIptcToXmp(IptcData& iptcData, XmpData& xmpData, const char* iptcCharset = nullptr);
|
||||
//! Convert (copy) IPTC datasets to XMP properties.
|
||||
EXIV2API void copyIptcToXmp(const IptcData& iptcData, XmpData& xmpData, const char* iptcCharset = nullptr);
|
||||
//! Convert (move) IPTC datasets to XMP properties, remove converted IPTC datasets.
|
||||
EXIV2API void moveIptcToXmp(IptcData& iptcData, XmpData& xmpData, const char* iptcCharset = nullptr);
|
||||
|
||||
//! Convert (copy) XMP properties to IPTC datasets.
|
||||
EXIV2API void copyXmpToIptc(const XmpData& xmpData, IptcData& iptcData);
|
||||
//! Convert (move) XMP properties to IPTC tags, remove converted XMP properties.
|
||||
EXIV2API void moveXmpToIptc(XmpData& xmpData, IptcData& iptcData);
|
||||
//! Convert (copy) XMP properties to IPTC datasets.
|
||||
EXIV2API void copyXmpToIptc(const XmpData& xmpData, IptcData& iptcData);
|
||||
//! Convert (move) XMP properties to IPTC tags, remove converted XMP properties.
|
||||
EXIV2API void moveXmpToIptc(XmpData& xmpData, IptcData& iptcData);
|
||||
|
||||
/*!
|
||||
@brief Convert character encoding of \em str from \em from to \em to.
|
||||
If the function succeeds, \em str contains the result string.
|
||||
/*!
|
||||
@brief Convert character encoding of \em str from \em from to \em to.
|
||||
If the function succeeds, \em str contains the result string.
|
||||
|
||||
This function uses the iconv library, if the %Exiv2 library was compiled
|
||||
with iconv support. Otherwise, on Windows, it uses Windows functions to
|
||||
support a limited number of conversions and fails with a warning if an
|
||||
unsupported conversion is attempted. If the function is called but %Exiv2
|
||||
was not compiled with iconv support and can't use Windows functions, it
|
||||
fails with a warning.
|
||||
This function uses the iconv library, if the %Exiv2 library was compiled
|
||||
with iconv support. Otherwise, on Windows, it uses Windows functions to
|
||||
support a limited number of conversions and fails with a warning if an
|
||||
unsupported conversion is attempted. If the function is called but %Exiv2
|
||||
was not compiled with iconv support and can't use Windows functions, it
|
||||
fails with a warning.
|
||||
|
||||
The conversions supported on Windows without iconv are:
|
||||
The conversions supported on Windows without iconv are:
|
||||
|
||||
<TABLE>
|
||||
<TR><TD><B>from</B></TD><TD><B>to</B></TD></TR>
|
||||
<TR><TD>UTF-8</TD> <TD>UCS-2BE</TD></TR>
|
||||
<TR><TD>UTF-8</TD> <TD>UCS-2LE</TD></TR>
|
||||
<TR><TD>UCS-2BE</TD> <TD>UTF-8</TD></TR>
|
||||
<TR><TD>UCS-2BE</TD> <TD>UCS-2LE</TD></TR>
|
||||
<TR><TD>UCS-2LE</TD> <TD>UTF-8</TD></TR>
|
||||
<TR><TD>UCS-2LE</TD> <TD>UCS-2BE</TD></TR>
|
||||
<TR><TD>ISO-8859-1</TD><TD>UTF-8</TD></TR>
|
||||
<TR><TD>ASCII</TD> <TD>UTF-8</TD></TR>
|
||||
</TABLE>
|
||||
<TABLE>
|
||||
<TR><TD><B>from</B></TD><TD><B>to</B></TD></TR>
|
||||
<TR><TD>UTF-8</TD> <TD>UCS-2BE</TD></TR>
|
||||
<TR><TD>UTF-8</TD> <TD>UCS-2LE</TD></TR>
|
||||
<TR><TD>UCS-2BE</TD> <TD>UTF-8</TD></TR>
|
||||
<TR><TD>UCS-2BE</TD> <TD>UCS-2LE</TD></TR>
|
||||
<TR><TD>UCS-2LE</TD> <TD>UTF-8</TD></TR>
|
||||
<TR><TD>UCS-2LE</TD> <TD>UCS-2BE</TD></TR>
|
||||
<TR><TD>ISO-8859-1</TD><TD>UTF-8</TD></TR>
|
||||
<TR><TD>ASCII</TD> <TD>UTF-8</TD></TR>
|
||||
</TABLE>
|
||||
|
||||
@param str The string to convert. It is updated to the converted string,
|
||||
which may have a different size. If the function call fails,
|
||||
the string is not modified.
|
||||
@param from Charset in which the input string is encoded as a name
|
||||
understood by \c iconv_open(3).
|
||||
@param to Charset to convert the string to as a name
|
||||
understood by \c iconv_open(3).
|
||||
@return Return \c true if the conversion was successful, else \c false.
|
||||
*/
|
||||
EXIV2API bool convertStringCharset(std::string& str, const char* from, const char* to);
|
||||
@param str The string to convert. It is updated to the converted string,
|
||||
which may have a different size. If the function call fails,
|
||||
the string is not modified.
|
||||
@param from Charset in which the input string is encoded as a name
|
||||
understood by \c iconv_open(3).
|
||||
@param to Charset to convert the string to as a name
|
||||
understood by \c iconv_open(3).
|
||||
@return Return \c true if the conversion was successful, else \c false.
|
||||
*/
|
||||
EXIV2API bool convertStringCharset(std::string& str, const char* from, const char* to);
|
||||
|
||||
} // namespace Exiv2
|
||||
} // namespace Exiv2
|
||||
|
||||
#endif // #ifndef CONVERT_HPP_
|
||||
#endif // #ifndef CONVERT_HPP_
|
||||
|
||||
+88
-101
@@ -17,120 +17,107 @@
|
||||
// *****************************************************************************
|
||||
// namespace extensions
|
||||
namespace Exiv2 {
|
||||
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
|
||||
/*!
|
||||
@brief Class to access raw Canon CR2 images. Exif metadata
|
||||
is supported directly, IPTC is read from the Exif data, if present.
|
||||
*/
|
||||
class EXIV2API Cr2Image : public Image {
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor that can either open an existing CR2 image or create
|
||||
a new image from scratch. If a new image is to be created, any
|
||||
existing data is overwritten. Since the constructor can not return
|
||||
a result, callers should check the good() method after object
|
||||
construction to determine success or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
@param create Specifies if an existing image should be read (false)
|
||||
or if a new file should be created (true).
|
||||
*/
|
||||
Cr2Image(BasicIo::UniquePtr io, bool create);
|
||||
//@}
|
||||
/*!
|
||||
@brief Class to access raw Canon CR2 images. Exif metadata
|
||||
is supported directly, IPTC is read from the Exif data, if present.
|
||||
*/
|
||||
class EXIV2API Cr2Image : public Image {
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor that can either open an existing CR2 image or create
|
||||
a new image from scratch. If a new image is to be created, any
|
||||
existing data is overwritten. Since the constructor can not return
|
||||
a result, callers should check the good() method after object
|
||||
construction to determine success or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
@param create Specifies if an existing image should be read (false)
|
||||
or if a new file should be created (true).
|
||||
*/
|
||||
Cr2Image(BasicIo::UniquePtr io, bool create);
|
||||
//@}
|
||||
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void readMetadata() override;
|
||||
void writeMetadata() override;
|
||||
/*!
|
||||
@brief Print out the structure of image file.
|
||||
@throw Error if reading of the file fails or the image data is
|
||||
not valid (does not look like data of the specific image type).
|
||||
@warning This function is not thread safe and intended for exiv2 -pS for debugging.
|
||||
*/
|
||||
void printStructure(std::ostream& out, PrintStructureOption option, int depth) override;
|
||||
/*!
|
||||
@brief Not supported. CR2 format does not contain a comment.
|
||||
Calling this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setComment(std::string_view comment) override;
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void readMetadata() override;
|
||||
void writeMetadata() override;
|
||||
/*!
|
||||
@brief Print out the structure of image file.
|
||||
@throw Error if reading of the file fails or the image data is
|
||||
not valid (does not look like data of the specific image type).
|
||||
@warning This function is not thread safe and intended for exiv2 -pS for debugging.
|
||||
*/
|
||||
void printStructure(std::ostream& out, PrintStructureOption option, int depth) override;
|
||||
/*!
|
||||
@brief Not supported. CR2 format does not contain a comment.
|
||||
Calling this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setComment(std::string_view comment) override;
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override;
|
||||
uint32_t pixelWidth() const override;
|
||||
uint32_t pixelHeight() const override;
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override;
|
||||
uint32_t pixelWidth() const override;
|
||||
uint32_t pixelHeight() const override;
|
||||
//@}
|
||||
|
||||
//! @name NOT implemented
|
||||
//@{
|
||||
//! Copy constructor
|
||||
Cr2Image(const Cr2Image& rhs) = delete;
|
||||
//! Assignment operator
|
||||
Cr2Image& operator=(const Cr2Image& rhs) = delete;
|
||||
//@}
|
||||
//! @name NOT implemented
|
||||
//@{
|
||||
//! Copy constructor
|
||||
Cr2Image(const Cr2Image& rhs) = delete;
|
||||
//! Assignment operator
|
||||
Cr2Image& operator=(const Cr2Image& rhs) = delete;
|
||||
//@}
|
||||
|
||||
}; // class Cr2Image
|
||||
}; // class Cr2Image
|
||||
|
||||
/*!
|
||||
@brief Stateless parser class for data in CR2 format. Images use this
|
||||
class to decode and encode CR2 data.
|
||||
See class TiffParser for details.
|
||||
*/
|
||||
class EXIV2API Cr2Parser {
|
||||
public:
|
||||
/*!
|
||||
@brief Decode metadata from a buffer \em pData of length \em size
|
||||
with data in CR2 format to the provided metadata containers.
|
||||
See TiffParser::decode().
|
||||
*/
|
||||
static ByteOrder decode(
|
||||
ExifData& exifData,
|
||||
IptcData& iptcData,
|
||||
XmpData& xmpData,
|
||||
const byte* pData,
|
||||
size_t size
|
||||
);
|
||||
/*!
|
||||
@brief Encode metadata from the provided metadata to CR2 format.
|
||||
See TiffParser::encode().
|
||||
*/
|
||||
static WriteMethod encode(BasicIo& io,
|
||||
const byte* pData,
|
||||
size_t size,
|
||||
ByteOrder byteOrder,
|
||||
const ExifData& exifData,
|
||||
const IptcData& iptcData,
|
||||
const XmpData& xmpData
|
||||
);
|
||||
/*!
|
||||
@brief Stateless parser class for data in CR2 format. Images use this
|
||||
class to decode and encode CR2 data.
|
||||
See class TiffParser for details.
|
||||
*/
|
||||
class EXIV2API Cr2Parser {
|
||||
public:
|
||||
/*!
|
||||
@brief Decode metadata from a buffer \em pData of length \em size
|
||||
with data in CR2 format to the provided metadata containers.
|
||||
See TiffParser::decode().
|
||||
*/
|
||||
static ByteOrder decode(ExifData& exifData, IptcData& iptcData, XmpData& xmpData, const byte* pData, size_t size);
|
||||
/*!
|
||||
@brief Encode metadata from the provided metadata to CR2 format.
|
||||
See TiffParser::encode().
|
||||
*/
|
||||
static WriteMethod encode(BasicIo& io, const byte* pData, size_t size, ByteOrder byteOrder, const ExifData& exifData,
|
||||
const IptcData& iptcData, const XmpData& xmpData);
|
||||
|
||||
}; // class Cr2Parser
|
||||
}; // class Cr2Parser
|
||||
|
||||
// *****************************************************************************
|
||||
// template, inline and free functions
|
||||
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new Cr2Image instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newCr2Instance(BasicIo::UniquePtr io, bool create);
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new Cr2Image instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newCr2Instance(BasicIo::UniquePtr io, bool create);
|
||||
|
||||
//! Check if the file iIo is a CR2 image.
|
||||
EXIV2API bool isCr2Type(BasicIo& iIo, bool advance);
|
||||
//! Check if the file iIo is a CR2 image.
|
||||
EXIV2API bool isCr2Type(BasicIo& iIo, bool advance);
|
||||
|
||||
} // namespace Exiv2
|
||||
} // namespace Exiv2
|
||||
|
||||
#endif // #ifndef CR2IMAGE_HPP_
|
||||
#endif // #ifndef CR2IMAGE_HPP_
|
||||
|
||||
+97
-101
@@ -3,7 +3,8 @@
|
||||
/*!
|
||||
@brief Class CrwImage to access Canon CRW images.<BR>
|
||||
References:<BR>
|
||||
<a href="http://www.sno.phy.queensu.ca/~phil/exiftool/canon_raw.html">The Canon RAW (CRW) File Format</a> by Phil Harvey
|
||||
<a href="http://www.sno.phy.queensu.ca/~phil/exiftool/canon_raw.html">The Canon RAW (CRW) File Format</a> by
|
||||
Phil Harvey
|
||||
@author Andreas Huggel (ahu)
|
||||
<a href="mailto:ahuggel@gmx.net">ahuggel@gmx.net</a>
|
||||
@date 28-Aug-05, ahu: created
|
||||
@@ -20,127 +21,122 @@
|
||||
// *****************************************************************************
|
||||
// namespace extensions
|
||||
namespace Exiv2 {
|
||||
|
||||
// *****************************************************************************
|
||||
// class declarations
|
||||
class ExifData;
|
||||
class IptcData;
|
||||
class ExifData;
|
||||
class IptcData;
|
||||
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
|
||||
/*!
|
||||
@brief Class to access raw Canon CRW images. Only Exif metadata and a
|
||||
comment are supported. CRW format does not contain IPTC metadata.
|
||||
*/
|
||||
class EXIV2API CrwImage : public Image {
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor that can either open an existing CRW image or create
|
||||
a new image from scratch. If a new image is to be created, any
|
||||
existing data is overwritten. Since the constructor can not return
|
||||
a result, callers should check the good() method after object
|
||||
construction to determine success or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
@param create Specifies if an existing image should be read (false)
|
||||
or if a new file should be created (true).
|
||||
*/
|
||||
CrwImage(BasicIo::UniquePtr io, bool create);
|
||||
//@}
|
||||
/*!
|
||||
@brief Class to access raw Canon CRW images. Only Exif metadata and a
|
||||
comment are supported. CRW format does not contain IPTC metadata.
|
||||
*/
|
||||
class EXIV2API CrwImage : public Image {
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor that can either open an existing CRW image or create
|
||||
a new image from scratch. If a new image is to be created, any
|
||||
existing data is overwritten. Since the constructor can not return
|
||||
a result, callers should check the good() method after object
|
||||
construction to determine success or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
@param create Specifies if an existing image should be read (false)
|
||||
or if a new file should be created (true).
|
||||
*/
|
||||
CrwImage(BasicIo::UniquePtr io, bool create);
|
||||
//@}
|
||||
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void readMetadata() override;
|
||||
void writeMetadata() override;
|
||||
/*!
|
||||
@brief Not supported. CRW format does not contain IPTC metadata.
|
||||
Calling this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setIptcData(const IptcData& iptcData) override;
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void readMetadata() override;
|
||||
void writeMetadata() override;
|
||||
/*!
|
||||
@brief Not supported. CRW format does not contain IPTC metadata.
|
||||
Calling this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setIptcData(const IptcData& iptcData) override;
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override;
|
||||
uint32_t pixelWidth() const override;
|
||||
uint32_t pixelHeight() const override;
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override;
|
||||
uint32_t pixelWidth() const override;
|
||||
uint32_t pixelHeight() const override;
|
||||
//@}
|
||||
|
||||
//! @name NOT Implemented
|
||||
//@{
|
||||
//! Copy constructor
|
||||
CrwImage(const CrwImage& rhs) = delete;
|
||||
//! Assignment operator
|
||||
CrwImage& operator=(const CrwImage& rhs) = delete;
|
||||
//@}
|
||||
//! @name NOT Implemented
|
||||
//@{
|
||||
//! Copy constructor
|
||||
CrwImage(const CrwImage& rhs) = delete;
|
||||
//! Assignment operator
|
||||
CrwImage& operator=(const CrwImage& rhs) = delete;
|
||||
//@}
|
||||
|
||||
}; // class CrwImage
|
||||
}; // class CrwImage
|
||||
|
||||
/*!
|
||||
Stateless parser class for Canon CRW images (Ciff format).
|
||||
*/
|
||||
class EXIV2API CrwParser {
|
||||
public:
|
||||
/*!
|
||||
@brief Decode metadata from a Canon CRW image in data buffer \em pData
|
||||
of length \em size into \em crwImage.
|
||||
/*!
|
||||
Stateless parser class for Canon CRW images (Ciff format).
|
||||
*/
|
||||
class EXIV2API CrwParser {
|
||||
public:
|
||||
/*!
|
||||
@brief Decode metadata from a Canon CRW image in data buffer \em pData
|
||||
of length \em size into \em crwImage.
|
||||
|
||||
This is the entry point to access image data in Ciff format. The
|
||||
parser uses classes CiffHeader, CiffEntry, CiffDirectory.
|
||||
This is the entry point to access image data in Ciff format. The
|
||||
parser uses classes CiffHeader, CiffEntry, CiffDirectory.
|
||||
|
||||
@param pCrwImage Pointer to the %Exiv2 CRW image to hold the metadata
|
||||
read from the buffer.
|
||||
@param pData Pointer to the data buffer. Must point to the data of
|
||||
a CRW image; no checks are performed.
|
||||
@param size Length of the data buffer.
|
||||
@param pCrwImage Pointer to the %Exiv2 CRW image to hold the metadata
|
||||
read from the buffer.
|
||||
@param pData Pointer to the data buffer. Must point to the data of
|
||||
a CRW image; no checks are performed.
|
||||
@param size Length of the data buffer.
|
||||
|
||||
@throw Error If the data buffer cannot be parsed.
|
||||
*/
|
||||
static void decode(CrwImage* pCrwImage, const byte* pData, size_t size);
|
||||
/*!
|
||||
@brief Encode metadata from the CRW image into a data buffer (the
|
||||
binary CRW image).
|
||||
@throw Error If the data buffer cannot be parsed.
|
||||
*/
|
||||
static void decode(CrwImage* pCrwImage, const byte* pData, size_t size);
|
||||
/*!
|
||||
@brief Encode metadata from the CRW image into a data buffer (the
|
||||
binary CRW image).
|
||||
|
||||
@param blob Data buffer for the binary image (target).
|
||||
@param pData Pointer to the binary image data buffer. Must
|
||||
point to data in CRW format; no checks are
|
||||
performed.
|
||||
@param size Length of the data buffer.
|
||||
@param pCrwImage Pointer to the %Exiv2 CRW image with the metadata to
|
||||
encode.
|
||||
@param blob Data buffer for the binary image (target).
|
||||
@param pData Pointer to the binary image data buffer. Must
|
||||
point to data in CRW format; no checks are
|
||||
performed.
|
||||
@param size Length of the data buffer.
|
||||
@param pCrwImage Pointer to the %Exiv2 CRW image with the metadata to
|
||||
encode.
|
||||
|
||||
@throw Error If the metadata from the CRW image cannot be encoded.
|
||||
*/
|
||||
static void encode(Blob& blob,
|
||||
const byte* pData,
|
||||
size_t size,
|
||||
const CrwImage* pCrwImage
|
||||
);
|
||||
@throw Error If the metadata from the CRW image cannot be encoded.
|
||||
*/
|
||||
static void encode(Blob& blob, const byte* pData, size_t size, const CrwImage* pCrwImage);
|
||||
|
||||
}; // class CrwParser
|
||||
}; // class CrwParser
|
||||
|
||||
// *****************************************************************************
|
||||
// template, inline and free functions
|
||||
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new CrwImage instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newCrwInstance(BasicIo::UniquePtr io, bool create);
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new CrwImage instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newCrwInstance(BasicIo::UniquePtr io, bool create);
|
||||
|
||||
//! Check if the file iIo is a CRW image.
|
||||
EXIV2API bool isCrwType(BasicIo& iIo, bool advance);
|
||||
//! Check if the file iIo is a CRW image.
|
||||
EXIV2API bool isCrwType(BasicIo& iIo, bool advance);
|
||||
|
||||
} // namespace Exiv2
|
||||
} // namespace Exiv2
|
||||
|
||||
#endif // #ifndef CRWIMAGE_HPP_
|
||||
#endif // #ifndef CRWIMAGE_HPP_
|
||||
|
||||
+274
-276
@@ -16,320 +16,318 @@
|
||||
// *****************************************************************************
|
||||
// namespace extensions
|
||||
namespace Exiv2 {
|
||||
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
|
||||
//! Details of an IPTC record.
|
||||
struct EXIV2API RecordInfo {
|
||||
uint16_t recordId_; //!< Record id
|
||||
const char* name_; //!< Record name (one word)
|
||||
const char* desc_; //!< Record description
|
||||
};
|
||||
//! Details of an IPTC record.
|
||||
struct EXIV2API RecordInfo {
|
||||
uint16_t recordId_; //!< Record id
|
||||
const char* name_; //!< Record name (one word)
|
||||
const char* desc_; //!< Record description
|
||||
};
|
||||
|
||||
//! Details of an IPTC dataset.
|
||||
struct EXIV2API DataSet {
|
||||
uint16_t number_; //!< Dataset number
|
||||
const char* name_; //!< Dataset name
|
||||
const char* title_; //!< Dataset title or label
|
||||
const char* desc_; //!< Dataset description
|
||||
bool mandatory_; //!< True if dataset is mandatory
|
||||
bool repeatable_; //!< True if dataset is repeatable
|
||||
uint32_t minbytes_; //!< Minimum number of bytes
|
||||
uint32_t maxbytes_; //!< Maximum number of bytes
|
||||
TypeId type_; //!< Exiv2 default type
|
||||
uint16_t recordId_; //!< Record id
|
||||
const char* photoshop_; //!< Photoshop string
|
||||
}; // struct DataSet
|
||||
//! Details of an IPTC dataset.
|
||||
struct EXIV2API DataSet {
|
||||
uint16_t number_; //!< Dataset number
|
||||
const char* name_; //!< Dataset name
|
||||
const char* title_; //!< Dataset title or label
|
||||
const char* desc_; //!< Dataset description
|
||||
bool mandatory_; //!< True if dataset is mandatory
|
||||
bool repeatable_; //!< True if dataset is repeatable
|
||||
uint32_t minbytes_; //!< Minimum number of bytes
|
||||
uint32_t maxbytes_; //!< Maximum number of bytes
|
||||
TypeId type_; //!< Exiv2 default type
|
||||
uint16_t recordId_; //!< Record id
|
||||
const char* photoshop_; //!< Photoshop string
|
||||
}; // struct DataSet
|
||||
|
||||
//! IPTC dataset reference, implemented as a static class.
|
||||
class EXIV2API IptcDataSets {
|
||||
public:
|
||||
/*!
|
||||
@name Record identifiers
|
||||
@brief Record identifiers to logically group dataSets. There are other
|
||||
possible record types, but they are not standardized by the IPTC
|
||||
IIM4 standard (and not commonly used in images).
|
||||
*/
|
||||
//@{
|
||||
static constexpr uint16_t invalidRecord = 0;
|
||||
static constexpr uint16_t envelope = 1;
|
||||
static constexpr uint16_t application2 = 2;
|
||||
//@}
|
||||
//! IPTC dataset reference, implemented as a static class.
|
||||
class EXIV2API IptcDataSets {
|
||||
public:
|
||||
/*!
|
||||
@name Record identifiers
|
||||
@brief Record identifiers to logically group dataSets. There are other
|
||||
possible record types, but they are not standardized by the IPTC
|
||||
IIM4 standard (and not commonly used in images).
|
||||
*/
|
||||
//@{
|
||||
static constexpr uint16_t invalidRecord = 0;
|
||||
static constexpr uint16_t envelope = 1;
|
||||
static constexpr uint16_t application2 = 2;
|
||||
//@}
|
||||
|
||||
//! @name Dataset identifiers
|
||||
//@{
|
||||
static constexpr uint16_t ModelVersion = 0;
|
||||
static constexpr uint16_t Destination = 5;
|
||||
static constexpr uint16_t FileFormat = 20;
|
||||
static constexpr uint16_t FileVersion = 22;
|
||||
static constexpr uint16_t ServiceId = 30;
|
||||
static constexpr uint16_t EnvelopeNumber = 40;
|
||||
static constexpr uint16_t ProductId = 50;
|
||||
static constexpr uint16_t EnvelopePriority = 60;
|
||||
static constexpr uint16_t DateSent = 70;
|
||||
static constexpr uint16_t TimeSent = 80;
|
||||
static constexpr uint16_t CharacterSet = 90;
|
||||
static constexpr uint16_t UNO = 100;
|
||||
static constexpr uint16_t ARMId = 120;
|
||||
static constexpr uint16_t ARMVersion = 122;
|
||||
//! @name Dataset identifiers
|
||||
//@{
|
||||
static constexpr uint16_t ModelVersion = 0;
|
||||
static constexpr uint16_t Destination = 5;
|
||||
static constexpr uint16_t FileFormat = 20;
|
||||
static constexpr uint16_t FileVersion = 22;
|
||||
static constexpr uint16_t ServiceId = 30;
|
||||
static constexpr uint16_t EnvelopeNumber = 40;
|
||||
static constexpr uint16_t ProductId = 50;
|
||||
static constexpr uint16_t EnvelopePriority = 60;
|
||||
static constexpr uint16_t DateSent = 70;
|
||||
static constexpr uint16_t TimeSent = 80;
|
||||
static constexpr uint16_t CharacterSet = 90;
|
||||
static constexpr uint16_t UNO = 100;
|
||||
static constexpr uint16_t ARMId = 120;
|
||||
static constexpr uint16_t ARMVersion = 122;
|
||||
|
||||
static constexpr uint16_t RecordVersion = 0;
|
||||
static constexpr uint16_t ObjectType = 3;
|
||||
static constexpr uint16_t ObjectAttribute = 4;
|
||||
static constexpr uint16_t ObjectName = 5;
|
||||
static constexpr uint16_t EditStatus = 7;
|
||||
static constexpr uint16_t EditorialUpdate = 8;
|
||||
static constexpr uint16_t Urgency = 10;
|
||||
static constexpr uint16_t Subject = 12;
|
||||
static constexpr uint16_t Category = 15;
|
||||
static constexpr uint16_t SuppCategory = 20;
|
||||
static constexpr uint16_t FixtureId = 22;
|
||||
static constexpr uint16_t Keywords = 25;
|
||||
static constexpr uint16_t LocationCode = 26;
|
||||
static constexpr uint16_t LocationName = 27;
|
||||
static constexpr uint16_t ReleaseDate = 30;
|
||||
static constexpr uint16_t ReleaseTime = 35;
|
||||
static constexpr uint16_t ExpirationDate = 37;
|
||||
static constexpr uint16_t ExpirationTime = 38;
|
||||
static constexpr uint16_t SpecialInstructions = 40;
|
||||
static constexpr uint16_t ActionAdvised = 42;
|
||||
static constexpr uint16_t ReferenceService = 45;
|
||||
static constexpr uint16_t ReferenceDate = 47;
|
||||
static constexpr uint16_t ReferenceNumber = 50;
|
||||
static constexpr uint16_t DateCreated = 55;
|
||||
static constexpr uint16_t TimeCreated = 60;
|
||||
static constexpr uint16_t DigitizationDate = 62;
|
||||
static constexpr uint16_t DigitizationTime = 63;
|
||||
static constexpr uint16_t Program = 65;
|
||||
static constexpr uint16_t ProgramVersion = 70;
|
||||
static constexpr uint16_t ObjectCycle = 75;
|
||||
static constexpr uint16_t Byline = 80;
|
||||
static constexpr uint16_t BylineTitle = 85;
|
||||
static constexpr uint16_t City = 90;
|
||||
static constexpr uint16_t SubLocation = 92;
|
||||
static constexpr uint16_t ProvinceState = 95;
|
||||
static constexpr uint16_t CountryCode = 100;
|
||||
static constexpr uint16_t CountryName = 101;
|
||||
static constexpr uint16_t TransmissionReference = 103;
|
||||
static constexpr uint16_t Headline = 105;
|
||||
static constexpr uint16_t Credit = 110;
|
||||
static constexpr uint16_t Source = 115;
|
||||
static constexpr uint16_t Copyright = 116;
|
||||
static constexpr uint16_t Contact = 118;
|
||||
static constexpr uint16_t Caption = 120;
|
||||
static constexpr uint16_t Writer = 122;
|
||||
static constexpr uint16_t RasterizedCaption = 125;
|
||||
static constexpr uint16_t ImageType = 130;
|
||||
static constexpr uint16_t ImageOrientation = 131;
|
||||
static constexpr uint16_t Language = 135;
|
||||
static constexpr uint16_t AudioType = 150;
|
||||
static constexpr uint16_t AudioRate = 151;
|
||||
static constexpr uint16_t AudioResolution = 152;
|
||||
static constexpr uint16_t AudioDuration = 153;
|
||||
static constexpr uint16_t AudioOutcue = 154;
|
||||
static constexpr uint16_t PreviewFormat = 200;
|
||||
static constexpr uint16_t PreviewVersion = 201;
|
||||
static constexpr uint16_t Preview = 202;
|
||||
//@}
|
||||
static constexpr uint16_t RecordVersion = 0;
|
||||
static constexpr uint16_t ObjectType = 3;
|
||||
static constexpr uint16_t ObjectAttribute = 4;
|
||||
static constexpr uint16_t ObjectName = 5;
|
||||
static constexpr uint16_t EditStatus = 7;
|
||||
static constexpr uint16_t EditorialUpdate = 8;
|
||||
static constexpr uint16_t Urgency = 10;
|
||||
static constexpr uint16_t Subject = 12;
|
||||
static constexpr uint16_t Category = 15;
|
||||
static constexpr uint16_t SuppCategory = 20;
|
||||
static constexpr uint16_t FixtureId = 22;
|
||||
static constexpr uint16_t Keywords = 25;
|
||||
static constexpr uint16_t LocationCode = 26;
|
||||
static constexpr uint16_t LocationName = 27;
|
||||
static constexpr uint16_t ReleaseDate = 30;
|
||||
static constexpr uint16_t ReleaseTime = 35;
|
||||
static constexpr uint16_t ExpirationDate = 37;
|
||||
static constexpr uint16_t ExpirationTime = 38;
|
||||
static constexpr uint16_t SpecialInstructions = 40;
|
||||
static constexpr uint16_t ActionAdvised = 42;
|
||||
static constexpr uint16_t ReferenceService = 45;
|
||||
static constexpr uint16_t ReferenceDate = 47;
|
||||
static constexpr uint16_t ReferenceNumber = 50;
|
||||
static constexpr uint16_t DateCreated = 55;
|
||||
static constexpr uint16_t TimeCreated = 60;
|
||||
static constexpr uint16_t DigitizationDate = 62;
|
||||
static constexpr uint16_t DigitizationTime = 63;
|
||||
static constexpr uint16_t Program = 65;
|
||||
static constexpr uint16_t ProgramVersion = 70;
|
||||
static constexpr uint16_t ObjectCycle = 75;
|
||||
static constexpr uint16_t Byline = 80;
|
||||
static constexpr uint16_t BylineTitle = 85;
|
||||
static constexpr uint16_t City = 90;
|
||||
static constexpr uint16_t SubLocation = 92;
|
||||
static constexpr uint16_t ProvinceState = 95;
|
||||
static constexpr uint16_t CountryCode = 100;
|
||||
static constexpr uint16_t CountryName = 101;
|
||||
static constexpr uint16_t TransmissionReference = 103;
|
||||
static constexpr uint16_t Headline = 105;
|
||||
static constexpr uint16_t Credit = 110;
|
||||
static constexpr uint16_t Source = 115;
|
||||
static constexpr uint16_t Copyright = 116;
|
||||
static constexpr uint16_t Contact = 118;
|
||||
static constexpr uint16_t Caption = 120;
|
||||
static constexpr uint16_t Writer = 122;
|
||||
static constexpr uint16_t RasterizedCaption = 125;
|
||||
static constexpr uint16_t ImageType = 130;
|
||||
static constexpr uint16_t ImageOrientation = 131;
|
||||
static constexpr uint16_t Language = 135;
|
||||
static constexpr uint16_t AudioType = 150;
|
||||
static constexpr uint16_t AudioRate = 151;
|
||||
static constexpr uint16_t AudioResolution = 152;
|
||||
static constexpr uint16_t AudioDuration = 153;
|
||||
static constexpr uint16_t AudioOutcue = 154;
|
||||
static constexpr uint16_t PreviewFormat = 200;
|
||||
static constexpr uint16_t PreviewVersion = 201;
|
||||
static constexpr uint16_t Preview = 202;
|
||||
//@}
|
||||
|
||||
//! Prevent construction: not implemented.
|
||||
IptcDataSets() = delete;
|
||||
//! Prevent copy-construction: not implemented.
|
||||
IptcDataSets(const IptcDataSets& rhs) = delete;
|
||||
//! Prevent assignment: not implemented.
|
||||
IptcDataSets& operator=(const IptcDataSets& rhs) = delete;
|
||||
//! Prevent construction: not implemented.
|
||||
IptcDataSets() = delete;
|
||||
//! Prevent copy-construction: not implemented.
|
||||
IptcDataSets(const IptcDataSets& rhs) = delete;
|
||||
//! Prevent assignment: not implemented.
|
||||
IptcDataSets& operator=(const IptcDataSets& rhs) = delete;
|
||||
|
||||
/*!
|
||||
@brief Return the name of the dataset.
|
||||
@param number The dataset number
|
||||
@param recordId The IPTC record Id
|
||||
@return The name of the dataset or a string containing the hexadecimal
|
||||
value of the dataset in the form "0x01ff", if this is an unknown
|
||||
dataset.
|
||||
*/
|
||||
static std::string dataSetName(uint16_t number, uint16_t recordId);
|
||||
/*!
|
||||
@brief Return the name of the dataset.
|
||||
@param number The dataset number
|
||||
@param recordId The IPTC record Id
|
||||
@return The name of the dataset or a string containing the hexadecimal
|
||||
value of the dataset in the form "0x01ff", if this is an unknown
|
||||
dataset.
|
||||
*/
|
||||
static std::string dataSetName(uint16_t number, uint16_t recordId);
|
||||
|
||||
/*!
|
||||
@brief Return the title (label) of the dataset.
|
||||
@param number The dataset number
|
||||
@param recordId The IPTC record Id
|
||||
@return The title (label) of the dataset
|
||||
*/
|
||||
static const char* dataSetTitle(uint16_t number, uint16_t recordId);
|
||||
/*!
|
||||
@brief Return the title (label) of the dataset.
|
||||
@param number The dataset number
|
||||
@param recordId The IPTC record Id
|
||||
@return The title (label) of the dataset
|
||||
*/
|
||||
static const char* dataSetTitle(uint16_t number, uint16_t recordId);
|
||||
|
||||
/*!
|
||||
@brief Return the description of the dataset.
|
||||
@param number The dataset number
|
||||
@param recordId The IPTC record Id
|
||||
@return The description of the dataset
|
||||
*/
|
||||
static const char* dataSetDesc(uint16_t number, uint16_t recordId);
|
||||
/*!
|
||||
@brief Return the description of the dataset.
|
||||
@param number The dataset number
|
||||
@param recordId The IPTC record Id
|
||||
@return The description of the dataset
|
||||
*/
|
||||
static const char* dataSetDesc(uint16_t number, uint16_t recordId);
|
||||
|
||||
/*!
|
||||
@brief Return the Photoshop name of a given dataset.
|
||||
@param number The dataset number
|
||||
@param recordId The IPTC record Id
|
||||
@return The name used by Photoshop for a dataset or an empty
|
||||
string if Photoshop does not use the dataset.
|
||||
*/
|
||||
static const char* dataSetPsName(uint16_t number, uint16_t recordId);
|
||||
/*!
|
||||
@brief Return the Photoshop name of a given dataset.
|
||||
@param number The dataset number
|
||||
@param recordId The IPTC record Id
|
||||
@return The name used by Photoshop for a dataset or an empty
|
||||
string if Photoshop does not use the dataset.
|
||||
*/
|
||||
static const char* dataSetPsName(uint16_t number, uint16_t recordId);
|
||||
|
||||
/*!
|
||||
@brief Check if a given dataset is repeatable
|
||||
@param number The dataset number
|
||||
@param recordId The IPTC record Id
|
||||
@return true if the given dataset is repeatable otherwise false
|
||||
*/
|
||||
static bool dataSetRepeatable(uint16_t number, uint16_t recordId);
|
||||
/*!
|
||||
@brief Check if a given dataset is repeatable
|
||||
@param number The dataset number
|
||||
@param recordId The IPTC record Id
|
||||
@return true if the given dataset is repeatable otherwise false
|
||||
*/
|
||||
static bool dataSetRepeatable(uint16_t number, uint16_t recordId);
|
||||
|
||||
/*!
|
||||
@brief Return the dataSet number for dataset name and record id
|
||||
/*!
|
||||
@brief Return the dataSet number for dataset name and record id
|
||||
|
||||
@param dataSetName dataSet name
|
||||
@param recordId recordId
|
||||
@param dataSetName dataSet name
|
||||
@param recordId recordId
|
||||
|
||||
@return dataSet number
|
||||
@return dataSet number
|
||||
|
||||
@throw Error if the \em dataSetName or \em recordId are invalid
|
||||
*/
|
||||
static uint16_t dataSet(const std::string& dataSetName, uint16_t recordId);
|
||||
@throw Error if the \em dataSetName or \em recordId are invalid
|
||||
*/
|
||||
static uint16_t dataSet(const std::string& dataSetName, uint16_t recordId);
|
||||
|
||||
//! Return the type for dataSet number and Record id
|
||||
static TypeId dataSetType(uint16_t number, uint16_t recordId);
|
||||
//! Return the type for dataSet number and Record id
|
||||
static TypeId dataSetType(uint16_t number, uint16_t recordId);
|
||||
|
||||
/*!
|
||||
@brief Return the name of the Record
|
||||
@param recordId The record id
|
||||
@return The name of the record or a string containing the hexadecimal
|
||||
value of the record in the form "0x01ff", if this is an
|
||||
unknown record.
|
||||
*/
|
||||
static std::string recordName(uint16_t recordId);
|
||||
/*!
|
||||
@brief Return the name of the Record
|
||||
@param recordId The record id
|
||||
@return The name of the record or a string containing the hexadecimal
|
||||
value of the record in the form "0x01ff", if this is an
|
||||
unknown record.
|
||||
*/
|
||||
static std::string recordName(uint16_t recordId);
|
||||
|
||||
/*!
|
||||
@brief Return the description of a record
|
||||
@param recordId Record Id number
|
||||
@return the description of the Record
|
||||
*/
|
||||
static const char* recordDesc(uint16_t recordId);
|
||||
/*!
|
||||
@brief Return the description of a record
|
||||
@param recordId Record Id number
|
||||
@return the description of the Record
|
||||
*/
|
||||
static const char* recordDesc(uint16_t recordId);
|
||||
|
||||
/*!
|
||||
@brief Return the Id number of a record
|
||||
@param recordName Name of a record type
|
||||
@return the Id number of a Record
|
||||
@throw Error if the record is not known;
|
||||
*/
|
||||
static uint16_t recordId(const std::string& recordName);
|
||||
/*!
|
||||
@brief Return the Id number of a record
|
||||
@param recordName Name of a record type
|
||||
@return the Id number of a Record
|
||||
@throw Error if the record is not known;
|
||||
*/
|
||||
static uint16_t recordId(const std::string& recordName);
|
||||
|
||||
//! Return read-only list of built-in Envelope Record datasets
|
||||
static const DataSet* envelopeRecordList();
|
||||
//! Return read-only list of built-in Envelope Record datasets
|
||||
static const DataSet* envelopeRecordList();
|
||||
|
||||
//! Return read-only list of built-in Application2 Record datasets
|
||||
static const DataSet* application2RecordList();
|
||||
//! Return read-only list of built-in Application2 Record datasets
|
||||
static const DataSet* application2RecordList();
|
||||
|
||||
//! Print a list of all dataSets to output stream
|
||||
static void dataSetList(std::ostream& os);
|
||||
//! Print a list of all dataSets to output stream
|
||||
static void dataSetList(std::ostream& os);
|
||||
|
||||
private:
|
||||
static int dataSetIdx(uint16_t number, uint16_t recordId);
|
||||
static int dataSetIdx(const std::string& dataSetName, uint16_t recordId);
|
||||
private:
|
||||
static int dataSetIdx(uint16_t number, uint16_t recordId);
|
||||
static int dataSetIdx(const std::string& dataSetName, uint16_t recordId);
|
||||
|
||||
static const DataSet* const records_[];
|
||||
static const DataSet* const records_[];
|
||||
|
||||
}; // class IptcDataSets
|
||||
}; // class IptcDataSets
|
||||
|
||||
/*!
|
||||
@brief Concrete keys for IPTC metadata.
|
||||
*/
|
||||
class EXIV2API IptcKey : public Key {
|
||||
public:
|
||||
//! Shortcut for an %IptcKey auto pointer.
|
||||
using UniquePtr = std::unique_ptr<IptcKey>;
|
||||
/*!
|
||||
@brief Concrete keys for IPTC metadata.
|
||||
*/
|
||||
class EXIV2API IptcKey : public Key {
|
||||
public:
|
||||
//! Shortcut for an %IptcKey auto pointer.
|
||||
using UniquePtr = std::unique_ptr<IptcKey>;
|
||||
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor to create an IPTC key from a key string.
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor to create an IPTC key from a key string.
|
||||
|
||||
@param key The key string.
|
||||
@throw Error if the first part of the key is not '<b>Iptc</b>' or
|
||||
the remaining parts of the key cannot be parsed and
|
||||
converted to a record name and a dataset name.
|
||||
*/
|
||||
explicit IptcKey(std::string key);
|
||||
/*!
|
||||
@brief Constructor to create an IPTC key from dataset and record ids.
|
||||
@param tag Dataset id
|
||||
@param record Record id
|
||||
*/
|
||||
IptcKey(uint16_t tag, uint16_t record);
|
||||
//! Copy constructor
|
||||
IptcKey(const IptcKey& rhs);
|
||||
IptcKey& operator=(const IptcKey& rhs) = delete;
|
||||
//! Destructor
|
||||
~IptcKey() override = default;
|
||||
//@}
|
||||
@param key The key string.
|
||||
@throw Error if the first part of the key is not '<b>Iptc</b>' or
|
||||
the remaining parts of the key cannot be parsed and
|
||||
converted to a record name and a dataset name.
|
||||
*/
|
||||
explicit IptcKey(std::string key);
|
||||
/*!
|
||||
@brief Constructor to create an IPTC key from dataset and record ids.
|
||||
@param tag Dataset id
|
||||
@param record Record id
|
||||
*/
|
||||
IptcKey(uint16_t tag, uint16_t record);
|
||||
//! Copy constructor
|
||||
IptcKey(const IptcKey& rhs);
|
||||
IptcKey& operator=(const IptcKey& rhs) = delete;
|
||||
//! Destructor
|
||||
~IptcKey() override = default;
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string key() const override;
|
||||
const char* familyName() const override;
|
||||
/*!
|
||||
@brief Return the name of the group (the second part of the key).
|
||||
For IPTC keys, the group name is the record name.
|
||||
*/
|
||||
std::string groupName() const override;
|
||||
std::string tagName() const override;
|
||||
std::string tagLabel() const override;
|
||||
uint16_t tag() const override;
|
||||
UniquePtr clone() const;
|
||||
//! Return the name of the record
|
||||
std::string recordName() const;
|
||||
//! Return the record id
|
||||
uint16_t record() const;
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string key() const override;
|
||||
const char* familyName() const override;
|
||||
/*!
|
||||
@brief Return the name of the group (the second part of the key).
|
||||
For IPTC keys, the group name is the record name.
|
||||
*/
|
||||
std::string groupName() const override;
|
||||
std::string tagName() const override;
|
||||
std::string tagLabel() const override;
|
||||
uint16_t tag() const override;
|
||||
UniquePtr clone() const;
|
||||
//! Return the name of the record
|
||||
std::string recordName() const;
|
||||
//! Return the record id
|
||||
uint16_t record() const;
|
||||
//@}
|
||||
protected:
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
/*!
|
||||
@brief Set the key corresponding to the dataset and record id.
|
||||
The key is of the form '<b>Iptc</b>.recordName.dataSetName'.
|
||||
*/
|
||||
void makeKey();
|
||||
/*!
|
||||
@brief Parse and convert the key string into dataset and record id.
|
||||
Updates data members if the string can be decomposed, or throws
|
||||
\em Error.
|
||||
|
||||
protected:
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
/*!
|
||||
@brief Set the key corresponding to the dataset and record id.
|
||||
The key is of the form '<b>Iptc</b>.recordName.dataSetName'.
|
||||
*/
|
||||
void makeKey();
|
||||
/*!
|
||||
@brief Parse and convert the key string into dataset and record id.
|
||||
Updates data members if the string can be decomposed, or throws
|
||||
\em Error.
|
||||
@throw Error if the key cannot be decomposed.
|
||||
*/
|
||||
void decomposeKey();
|
||||
//@}
|
||||
|
||||
@throw Error if the key cannot be decomposed.
|
||||
*/
|
||||
void decomposeKey();
|
||||
//@}
|
||||
private:
|
||||
//! Internal virtual copy constructor.
|
||||
IptcKey* clone_() const override;
|
||||
|
||||
private:
|
||||
//! Internal virtual copy constructor.
|
||||
IptcKey* clone_() const override;
|
||||
uint16_t tag_; //!< Tag value
|
||||
uint16_t record_; //!< Record value
|
||||
std::string key_; //!< Key
|
||||
|
||||
uint16_t tag_; //!< Tag value
|
||||
uint16_t record_; //!< Record value
|
||||
std::string key_; //!< Key
|
||||
}; // class IptcKey
|
||||
|
||||
}; // class IptcKey
|
||||
/*!
|
||||
@brief typedef for string:string map
|
||||
*/
|
||||
using Dictionary = std::map<std::string, std::string>;
|
||||
|
||||
/*!
|
||||
@brief typedef for string:string map
|
||||
*/
|
||||
using Dictionary = std::map<std::string, std::string>;
|
||||
// *****************************************************************************
|
||||
// free functions
|
||||
|
||||
// *****************************************************************************
|
||||
// free functions
|
||||
//! Output operator for dataSet
|
||||
EXIV2API std::ostream& operator<<(std::ostream& os, const DataSet& dataSet);
|
||||
|
||||
//! Output operator for dataSet
|
||||
EXIV2API std::ostream& operator<<(std::ostream& os, const DataSet& dataSet);
|
||||
} // namespace Exiv2
|
||||
|
||||
} // namespace Exiv2
|
||||
|
||||
#endif // #ifndef DATASETS_HPP_
|
||||
#endif // #ifndef DATASETS_HPP_
|
||||
|
||||
@@ -15,80 +15,79 @@
|
||||
#include "exif.hpp"
|
||||
|
||||
namespace Exiv2 {
|
||||
|
||||
// *****************************************************************************
|
||||
// class declarations
|
||||
class ExifData;
|
||||
class ExifData;
|
||||
|
||||
//! Return the orientation of the image
|
||||
EXIV2API ExifData::const_iterator orientation(const ExifData& ed);
|
||||
//! Return the ISO speed used to shoot the image
|
||||
EXIV2API ExifData::const_iterator isoSpeed(const ExifData& ed);
|
||||
//! Return the date and time when the original image data was generated
|
||||
EXIV2API ExifData::const_iterator dateTimeOriginal(const ExifData& ed);
|
||||
//! Return the flash bias value
|
||||
EXIV2API ExifData::const_iterator flashBias(const ExifData& ed);
|
||||
//! Return the exposure mode setting
|
||||
EXIV2API ExifData::const_iterator exposureMode(const ExifData& ed);
|
||||
//! Return the scene mode setting
|
||||
EXIV2API ExifData::const_iterator sceneMode(const ExifData& ed);
|
||||
//! Return the macro mode setting
|
||||
EXIV2API ExifData::const_iterator macroMode(const ExifData& ed);
|
||||
//! Return the image quality setting
|
||||
EXIV2API ExifData::const_iterator imageQuality(const ExifData& ed);
|
||||
//! Return the white balance setting
|
||||
EXIV2API ExifData::const_iterator whiteBalance(const ExifData& ed);
|
||||
//! Return the name of the lens used
|
||||
EXIV2API ExifData::const_iterator lensName(const ExifData& ed);
|
||||
//! Return the saturation level
|
||||
EXIV2API ExifData::const_iterator saturation(const ExifData& ed);
|
||||
//! Return the sharpness level
|
||||
EXIV2API ExifData::const_iterator sharpness(const ExifData& ed);
|
||||
//! Return the contrast level
|
||||
EXIV2API ExifData::const_iterator contrast(const ExifData& ed);
|
||||
//! Return the scene capture type
|
||||
EXIV2API ExifData::const_iterator sceneCaptureType(const ExifData& ed);
|
||||
//! Return the metering mode setting
|
||||
EXIV2API ExifData::const_iterator meteringMode(const ExifData& ed);
|
||||
//! Return the camera make
|
||||
EXIV2API ExifData::const_iterator make(const ExifData& ed);
|
||||
//! Return the camera model
|
||||
EXIV2API ExifData::const_iterator model(const ExifData& ed);
|
||||
//! Return the exposure time
|
||||
EXIV2API ExifData::const_iterator exposureTime(const ExifData& ed);
|
||||
//! Return the F number
|
||||
EXIV2API ExifData::const_iterator fNumber(const ExifData& ed);
|
||||
//! Return the shutter speed value
|
||||
EXIV2API ExifData::const_iterator shutterSpeedValue(const ExifData& ed);
|
||||
//! Return the aperture value
|
||||
EXIV2API ExifData::const_iterator apertureValue(const ExifData& ed);
|
||||
//! Return the brightness value
|
||||
EXIV2API ExifData::const_iterator brightnessValue(const ExifData& ed);
|
||||
//! Return the exposure bias value
|
||||
EXIV2API ExifData::const_iterator exposureBiasValue(const ExifData& ed);
|
||||
//! Return the max aperture value
|
||||
EXIV2API ExifData::const_iterator maxApertureValue(const ExifData& ed);
|
||||
//! Return the subject distance
|
||||
EXIV2API ExifData::const_iterator subjectDistance(const ExifData& ed);
|
||||
//! Return the kind of light source
|
||||
EXIV2API ExifData::const_iterator lightSource(const ExifData& ed);
|
||||
//! Return the status of flash
|
||||
EXIV2API ExifData::const_iterator flash(const ExifData& ed);
|
||||
//! Return the camera serial number
|
||||
EXIV2API ExifData::const_iterator serialNumber(const ExifData& ed);
|
||||
//! Return the focal length setting
|
||||
EXIV2API ExifData::const_iterator focalLength(const ExifData& ed);
|
||||
//! Return the subject location and area
|
||||
EXIV2API ExifData::const_iterator subjectArea(const ExifData& ed);
|
||||
//! Return the flash energy
|
||||
EXIV2API ExifData::const_iterator flashEnergy(const ExifData& ed);
|
||||
//! Return the exposure index
|
||||
EXIV2API ExifData::const_iterator exposureIndex(const ExifData& ed);
|
||||
//! Return the image sensor type
|
||||
EXIV2API ExifData::const_iterator sensingMethod(const ExifData& ed);
|
||||
//! Return the AF point
|
||||
EXIV2API ExifData::const_iterator afPoint(const ExifData& ed);
|
||||
//! Return the orientation of the image
|
||||
EXIV2API ExifData::const_iterator orientation(const ExifData& ed);
|
||||
//! Return the ISO speed used to shoot the image
|
||||
EXIV2API ExifData::const_iterator isoSpeed(const ExifData& ed);
|
||||
//! Return the date and time when the original image data was generated
|
||||
EXIV2API ExifData::const_iterator dateTimeOriginal(const ExifData& ed);
|
||||
//! Return the flash bias value
|
||||
EXIV2API ExifData::const_iterator flashBias(const ExifData& ed);
|
||||
//! Return the exposure mode setting
|
||||
EXIV2API ExifData::const_iterator exposureMode(const ExifData& ed);
|
||||
//! Return the scene mode setting
|
||||
EXIV2API ExifData::const_iterator sceneMode(const ExifData& ed);
|
||||
//! Return the macro mode setting
|
||||
EXIV2API ExifData::const_iterator macroMode(const ExifData& ed);
|
||||
//! Return the image quality setting
|
||||
EXIV2API ExifData::const_iterator imageQuality(const ExifData& ed);
|
||||
//! Return the white balance setting
|
||||
EXIV2API ExifData::const_iterator whiteBalance(const ExifData& ed);
|
||||
//! Return the name of the lens used
|
||||
EXIV2API ExifData::const_iterator lensName(const ExifData& ed);
|
||||
//! Return the saturation level
|
||||
EXIV2API ExifData::const_iterator saturation(const ExifData& ed);
|
||||
//! Return the sharpness level
|
||||
EXIV2API ExifData::const_iterator sharpness(const ExifData& ed);
|
||||
//! Return the contrast level
|
||||
EXIV2API ExifData::const_iterator contrast(const ExifData& ed);
|
||||
//! Return the scene capture type
|
||||
EXIV2API ExifData::const_iterator sceneCaptureType(const ExifData& ed);
|
||||
//! Return the metering mode setting
|
||||
EXIV2API ExifData::const_iterator meteringMode(const ExifData& ed);
|
||||
//! Return the camera make
|
||||
EXIV2API ExifData::const_iterator make(const ExifData& ed);
|
||||
//! Return the camera model
|
||||
EXIV2API ExifData::const_iterator model(const ExifData& ed);
|
||||
//! Return the exposure time
|
||||
EXIV2API ExifData::const_iterator exposureTime(const ExifData& ed);
|
||||
//! Return the F number
|
||||
EXIV2API ExifData::const_iterator fNumber(const ExifData& ed);
|
||||
//! Return the shutter speed value
|
||||
EXIV2API ExifData::const_iterator shutterSpeedValue(const ExifData& ed);
|
||||
//! Return the aperture value
|
||||
EXIV2API ExifData::const_iterator apertureValue(const ExifData& ed);
|
||||
//! Return the brightness value
|
||||
EXIV2API ExifData::const_iterator brightnessValue(const ExifData& ed);
|
||||
//! Return the exposure bias value
|
||||
EXIV2API ExifData::const_iterator exposureBiasValue(const ExifData& ed);
|
||||
//! Return the max aperture value
|
||||
EXIV2API ExifData::const_iterator maxApertureValue(const ExifData& ed);
|
||||
//! Return the subject distance
|
||||
EXIV2API ExifData::const_iterator subjectDistance(const ExifData& ed);
|
||||
//! Return the kind of light source
|
||||
EXIV2API ExifData::const_iterator lightSource(const ExifData& ed);
|
||||
//! Return the status of flash
|
||||
EXIV2API ExifData::const_iterator flash(const ExifData& ed);
|
||||
//! Return the camera serial number
|
||||
EXIV2API ExifData::const_iterator serialNumber(const ExifData& ed);
|
||||
//! Return the focal length setting
|
||||
EXIV2API ExifData::const_iterator focalLength(const ExifData& ed);
|
||||
//! Return the subject location and area
|
||||
EXIV2API ExifData::const_iterator subjectArea(const ExifData& ed);
|
||||
//! Return the flash energy
|
||||
EXIV2API ExifData::const_iterator flashEnergy(const ExifData& ed);
|
||||
//! Return the exposure index
|
||||
EXIV2API ExifData::const_iterator exposureIndex(const ExifData& ed);
|
||||
//! Return the image sensor type
|
||||
EXIV2API ExifData::const_iterator sensingMethod(const ExifData& ed);
|
||||
//! Return the AF point
|
||||
EXIV2API ExifData::const_iterator afPoint(const ExifData& ed);
|
||||
|
||||
} // namespace Exiv2
|
||||
} // namespace Exiv2
|
||||
|
||||
#endif // EASYACCESS_HPP_
|
||||
#endif // EASYACCESS_HPP_
|
||||
|
||||
+66
-64
@@ -4,10 +4,14 @@
|
||||
@file epsimage.hpp
|
||||
@brief EPS image.
|
||||
<br>References:
|
||||
<br>[1] <a href="http://partners.adobe.com/public/developer/en/ps/5001.DSC_Spec.pdf">Adobe PostScript Language Document Structuring Conventions Specification, Version 3.0</a>, September 1992
|
||||
<br>[2] <a href="http://partners.adobe.com/public/developer/en/ps/5002.EPSF_Spec.pdf">Adobe Encapsulated PostScript File Format Specification, Version 3.0</a>, May 1992
|
||||
<br>[3] <a href="http://www.adobe.com/content/dam/Adobe/en/devnet/xmp/pdfs/XMPSpecificationPart3.pdf">Adobe XMP Specification Part 3: Storage in Files</a>, July 2010
|
||||
<br>[4] <a href="http://groups.google.com/group/adobe.illustrator.windows/msg/0a9d7b1244b59062">Re: Thumbnail data format in ai file</a>, Dec 2003
|
||||
<br>[1] <a href="http://partners.adobe.com/public/developer/en/ps/5001.DSC_Spec.pdf">Adobe PostScript
|
||||
Language Document Structuring Conventions Specification, Version 3.0</a>, September 1992 <br>[2] <a
|
||||
href="http://partners.adobe.com/public/developer/en/ps/5002.EPSF_Spec.pdf">Adobe Encapsulated PostScript File Format
|
||||
Specification, Version 3.0</a>, May 1992 <br>[3] <a
|
||||
href="http://www.adobe.com/content/dam/Adobe/en/devnet/xmp/pdfs/XMPSpecificationPart3.pdf">Adobe XMP Specification
|
||||
Part 3: Storage in Files</a>, July 2010 <br>[4] <a
|
||||
href="http://groups.google.com/group/adobe.illustrator.windows/msg/0a9d7b1244b59062">Re: Thumbnail data format in ai
|
||||
file</a>, Dec 2003
|
||||
@author Michael Ulbrich (mul)
|
||||
<a href="mailto:mul@rentapacs.de">mul@rentapacs.de</a>
|
||||
@author Volker Grabsch (vog)
|
||||
@@ -25,77 +29,75 @@
|
||||
|
||||
// *****************************************************************************
|
||||
// namespace extensions
|
||||
namespace Exiv2
|
||||
{
|
||||
|
||||
namespace Exiv2 {
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
|
||||
/*!
|
||||
@brief Class to access EPS images.
|
||||
*/
|
||||
class EXIV2API EpsImage : public Image {
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor to open a EPS image. Since the
|
||||
constructor can't return a result, callers should check the
|
||||
good() method after object construction to determine success
|
||||
or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
@param create Specifies if an existing image should be read (false)
|
||||
or if a new file should be created (true).
|
||||
*/
|
||||
EpsImage(BasicIo::UniquePtr io, bool create);
|
||||
//@}
|
||||
/*!
|
||||
@brief Class to access EPS images.
|
||||
*/
|
||||
class EXIV2API EpsImage : public Image {
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor to open a EPS image. Since the
|
||||
constructor can't return a result, callers should check the
|
||||
good() method after object construction to determine success
|
||||
or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
@param create Specifies if an existing image should be read (false)
|
||||
or if a new file should be created (true).
|
||||
*/
|
||||
EpsImage(BasicIo::UniquePtr io, bool create);
|
||||
//@}
|
||||
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void readMetadata() override;
|
||||
void writeMetadata() override;
|
||||
/*!
|
||||
@brief Not supported.
|
||||
Calling this function will throw an instance of Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setComment(std::string_view comment) override;
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void readMetadata() override;
|
||||
void writeMetadata() override;
|
||||
/*!
|
||||
@brief Not supported.
|
||||
Calling this function will throw an instance of Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setComment(std::string_view comment) override;
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override;
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override;
|
||||
//@}
|
||||
|
||||
//! @name NOT Implemented
|
||||
//@{
|
||||
//! Copy constructor
|
||||
EpsImage(const EpsImage& rhs) = delete;
|
||||
//! Assignment operator
|
||||
EpsImage& operator=(const EpsImage& rhs) = delete;
|
||||
//@}
|
||||
//! @name NOT Implemented
|
||||
//@{
|
||||
//! Copy constructor
|
||||
EpsImage(const EpsImage& rhs) = delete;
|
||||
//! Assignment operator
|
||||
EpsImage& operator=(const EpsImage& rhs) = delete;
|
||||
//@}
|
||||
|
||||
}; // class EpsImage
|
||||
}; // class EpsImage
|
||||
|
||||
// *****************************************************************************
|
||||
// template, inline and free functions
|
||||
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new EpsImage instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newEpsInstance(BasicIo::UniquePtr io, bool create);
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new EpsImage instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newEpsInstance(BasicIo::UniquePtr io, bool create);
|
||||
|
||||
//! Check if the file iIo is a EPS image.
|
||||
EXIV2API bool isEpsType(BasicIo& iIo, bool advance);
|
||||
//! Check if the file iIo is a EPS image.
|
||||
EXIV2API bool isEpsType(BasicIo& iIo, bool advance);
|
||||
|
||||
} // namespace Exiv2
|
||||
} // namespace Exiv2
|
||||
|
||||
#endif // #ifndef EPSIMAGE_HPP_
|
||||
#endif // #ifndef EPSIMAGE_HPP_
|
||||
|
||||
+232
-248
@@ -16,136 +16,127 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <exception> // for exception
|
||||
#include <sstream> // for operator<<, ostream, ostringstream, bas...
|
||||
#include <string> // for basic_string, string
|
||||
#include <exception> // for exception
|
||||
#include <sstream> // for operator<<, ostream, ostringstream, bas...
|
||||
#include <string> // for basic_string, string
|
||||
|
||||
// *****************************************************************************
|
||||
// namespace extensions
|
||||
namespace Exiv2
|
||||
{
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
namespace Exiv2 {
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
|
||||
/*!
|
||||
@brief Class for a log message, used by the library. Applications can set
|
||||
the log level and provide a customer log message handler (callback
|
||||
function).
|
||||
/*!
|
||||
@brief Class for a log message, used by the library. Applications can set
|
||||
the log level and provide a customer log message handler (callback
|
||||
function).
|
||||
|
||||
This class is meant to be used as a temporary object with the
|
||||
related macro-magic like this:
|
||||
This class is meant to be used as a temporary object with the
|
||||
related macro-magic like this:
|
||||
|
||||
<code>
|
||||
EXV_WARNING << "Warning! Something looks fishy.\n";
|
||||
</code>
|
||||
<code>
|
||||
EXV_WARNING << "Warning! Something looks fishy.\n";
|
||||
</code>
|
||||
|
||||
which translates to
|
||||
which translates to
|
||||
|
||||
<code>
|
||||
if (LogMsg::warn >= LogMsg::level() && LogMsg::handler())
|
||||
LogMsg(LogMsg::warn).os() << "Warning! Something looks fishy.\n";
|
||||
</code>
|
||||
<code>
|
||||
if (LogMsg::warn >= LogMsg::level() && LogMsg::handler())
|
||||
LogMsg(LogMsg::warn).os() << "Warning! Something looks fishy.\n";
|
||||
</code>
|
||||
|
||||
The macros EXV_DEBUG, EXV_INFO, EXV_WARNING and EXV_ERROR are
|
||||
shorthands and ensure efficient use of the logging facility: If a
|
||||
log message doesn't need to be generated because of the log level
|
||||
setting, the temp object is not even created.
|
||||
The macros EXV_DEBUG, EXV_INFO, EXV_WARNING and EXV_ERROR are
|
||||
shorthands and ensure efficient use of the logging facility: If a
|
||||
log message doesn't need to be generated because of the log level
|
||||
setting, the temp object is not even created.
|
||||
|
||||
Caveat: The entire log message is not processed in this case. So don't
|
||||
make that call any logic that always needs to be executed.
|
||||
*/
|
||||
class EXIV2API LogMsg
|
||||
{
|
||||
public:
|
||||
//! Prevent copy-construction: not implemented.
|
||||
LogMsg(const LogMsg&) = delete;
|
||||
//! Prevent assignment: not implemented.
|
||||
LogMsg& operator=(const LogMsg&) = delete;
|
||||
/*!
|
||||
@brief Defined log levels. To suppress all log messages, either set the
|
||||
log level to \c mute or set the log message handler to 0.
|
||||
*/
|
||||
enum Level
|
||||
{
|
||||
debug = 0,
|
||||
info = 1,
|
||||
warn = 2,
|
||||
error = 3,
|
||||
mute = 4
|
||||
};
|
||||
/*!
|
||||
@brief Type for a log message handler function. The function receives
|
||||
the log level and message and can process it in an application
|
||||
specific way. The default handler sends the log message to
|
||||
standard error.
|
||||
*/
|
||||
using Handler = void (*)(int, const char*);
|
||||
Caveat: The entire log message is not processed in this case. So don't
|
||||
make that call any logic that always needs to be executed.
|
||||
*/
|
||||
class EXIV2API LogMsg {
|
||||
public:
|
||||
//! Prevent copy-construction: not implemented.
|
||||
LogMsg(const LogMsg&) = delete;
|
||||
//! Prevent assignment: not implemented.
|
||||
LogMsg& operator=(const LogMsg&) = delete;
|
||||
/*!
|
||||
@brief Defined log levels. To suppress all log messages, either set the
|
||||
log level to \c mute or set the log message handler to 0.
|
||||
*/
|
||||
enum Level { debug = 0, info = 1, warn = 2, error = 3, mute = 4 };
|
||||
/*!
|
||||
@brief Type for a log message handler function. The function receives
|
||||
the log level and message and can process it in an application
|
||||
specific way. The default handler sends the log message to
|
||||
standard error.
|
||||
*/
|
||||
using Handler = void (*)(int, const char*);
|
||||
|
||||
//! @name Creators
|
||||
//@{
|
||||
//! Constructor, takes the log message type as an argument
|
||||
explicit LogMsg(Level msgType);
|
||||
//! @name Creators
|
||||
//@{
|
||||
//! Constructor, takes the log message type as an argument
|
||||
explicit LogMsg(Level msgType);
|
||||
|
||||
//! Destructor, passes the log message to the message handler depending on the log level
|
||||
~LogMsg();
|
||||
//@}
|
||||
//! Destructor, passes the log message to the message handler depending on the log level
|
||||
~LogMsg();
|
||||
//@}
|
||||
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
//! Return a reference to the ostringstream which holds the log message
|
||||
std::ostringstream& os();
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
//! Return a reference to the ostringstream which holds the log message
|
||||
std::ostringstream& os();
|
||||
//@}
|
||||
|
||||
/*!
|
||||
@brief Set the log level. Only log messages with a level greater or
|
||||
equal \em level are sent to the log message handler. Default
|
||||
log level is \c warn. To suppress all log messages, set the log
|
||||
level to \c mute (or set the log message handler to 0).
|
||||
*/
|
||||
static void setLevel(Level level);
|
||||
/*!
|
||||
@brief Set the log message handler. The default handler writes log
|
||||
messages to standard error. To suppress all log messages, set
|
||||
the log message handler to 0 (or set the log level to \c mute).
|
||||
*/
|
||||
static void setHandler(Handler handler);
|
||||
//! Return the current log level
|
||||
static Level level();
|
||||
//! Return the current log message handler
|
||||
static Handler handler();
|
||||
//! The default log handler. Sends the log message to standard error.
|
||||
static void defaultHandler(int level, const char* s);
|
||||
/*!
|
||||
@brief Set the log level. Only log messages with a level greater or
|
||||
equal \em level are sent to the log message handler. Default
|
||||
log level is \c warn. To suppress all log messages, set the log
|
||||
level to \c mute (or set the log message handler to 0).
|
||||
*/
|
||||
static void setLevel(Level level);
|
||||
/*!
|
||||
@brief Set the log message handler. The default handler writes log
|
||||
messages to standard error. To suppress all log messages, set
|
||||
the log message handler to 0 (or set the log level to \c mute).
|
||||
*/
|
||||
static void setHandler(Handler handler);
|
||||
//! Return the current log level
|
||||
static Level level();
|
||||
//! Return the current log message handler
|
||||
static Handler handler();
|
||||
//! The default log handler. Sends the log message to standard error.
|
||||
static void defaultHandler(int level, const char* s);
|
||||
|
||||
private:
|
||||
// DATA
|
||||
// The output level. Only messages with type >= level_ will be written
|
||||
static Level level_;
|
||||
// The log handler in use
|
||||
static Handler handler_;
|
||||
// The type of this log message
|
||||
const Level msgType_;
|
||||
// Holds the log message until it is passed to the message handler
|
||||
std::ostringstream os_;
|
||||
private:
|
||||
// DATA
|
||||
// The output level. Only messages with type >= level_ will be written
|
||||
static Level level_;
|
||||
// The log handler in use
|
||||
static Handler handler_;
|
||||
// The type of this log message
|
||||
const Level msgType_;
|
||||
// Holds the log message until it is passed to the message handler
|
||||
std::ostringstream os_;
|
||||
|
||||
}; // class LogMsg
|
||||
}; // class LogMsg
|
||||
|
||||
// Macros for simple access
|
||||
//! Shorthand to create a temp debug log message object and return its ostringstream
|
||||
#define EXV_DEBUG \
|
||||
if (LogMsg::debug >= LogMsg::level() && LogMsg::handler()) \
|
||||
LogMsg(LogMsg::debug).os()
|
||||
#define EXV_DEBUG \
|
||||
if (LogMsg::debug >= LogMsg::level() && LogMsg::handler()) \
|
||||
LogMsg(LogMsg::debug).os()
|
||||
//! Shorthand for a temp info log message object and return its ostringstream
|
||||
#define EXV_INFO \
|
||||
if (LogMsg::info >= LogMsg::level() && LogMsg::handler()) \
|
||||
LogMsg(LogMsg::info).os()
|
||||
#define EXV_INFO \
|
||||
if (LogMsg::info >= LogMsg::level() && LogMsg::handler()) \
|
||||
LogMsg(LogMsg::info).os()
|
||||
//! Shorthand for a temp warning log message object and return its ostringstream
|
||||
#define EXV_WARNING \
|
||||
if (LogMsg::warn >= LogMsg::level() && LogMsg::handler()) \
|
||||
LogMsg(LogMsg::warn).os()
|
||||
#define EXV_WARNING \
|
||||
if (LogMsg::warn >= LogMsg::level() && LogMsg::handler()) \
|
||||
LogMsg(LogMsg::warn).os()
|
||||
//! Shorthand for a temp error log message object and return its ostringstream
|
||||
#define EXV_ERROR \
|
||||
if (LogMsg::error >= LogMsg::level() && LogMsg::handler()) \
|
||||
LogMsg(LogMsg::error).os()
|
||||
#define EXV_ERROR \
|
||||
if (LogMsg::error >= LogMsg::level() && LogMsg::handler()) \
|
||||
LogMsg(LogMsg::error).os()
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// Disable MSVC warnings "non - DLL-interface classkey 'identifier' used as base
|
||||
@@ -153,157 +144,150 @@ namespace Exiv2
|
||||
#pragma warning(disable : 4275)
|
||||
#endif
|
||||
|
||||
//! Generalised toString function
|
||||
template <typename charT, typename T>
|
||||
std::basic_string<charT> toBasicString(const T& arg)
|
||||
{
|
||||
std::basic_ostringstream<charT> os;
|
||||
os << arg;
|
||||
return os.str();
|
||||
}
|
||||
//! Generalised toString function
|
||||
template <typename charT, typename T>
|
||||
std::basic_string<charT> toBasicString(const T& arg) {
|
||||
std::basic_ostringstream<charT> os;
|
||||
os << arg;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
//! Complete list of all Exiv2 error codes
|
||||
enum class ErrorCode
|
||||
{
|
||||
kerSuccess = 0,
|
||||
kerGeneralError,
|
||||
kerErrorMessage,
|
||||
kerCallFailed,
|
||||
kerNotAnImage,
|
||||
kerInvalidDataset,
|
||||
kerInvalidRecord,
|
||||
kerInvalidKey,
|
||||
kerInvalidTag,
|
||||
kerValueNotSet,
|
||||
kerDataSourceOpenFailed,
|
||||
kerFileOpenFailed,
|
||||
kerFileContainsUnknownImageType,
|
||||
kerMemoryContainsUnknownImageType,
|
||||
kerUnsupportedImageType,
|
||||
kerFailedToReadImageData,
|
||||
kerNotAJpeg,
|
||||
kerFailedToMapFileForReadWrite,
|
||||
kerFileRenameFailed,
|
||||
kerTransferFailed,
|
||||
kerMemoryTransferFailed,
|
||||
kerInputDataReadFailed,
|
||||
kerImageWriteFailed,
|
||||
kerNoImageInInputData,
|
||||
kerInvalidIfdId,
|
||||
kerValueTooLarge,
|
||||
kerDataAreaValueTooLarge,
|
||||
kerOffsetOutOfRange,
|
||||
kerUnsupportedDataAreaOffsetType,
|
||||
kerInvalidCharset,
|
||||
kerUnsupportedDateFormat,
|
||||
kerUnsupportedTimeFormat,
|
||||
kerWritingImageFormatUnsupported,
|
||||
kerInvalidSettingForImage,
|
||||
kerNotACrwImage,
|
||||
kerFunctionNotSupported,
|
||||
kerNoNamespaceInfoForXmpPrefix,
|
||||
kerNoPrefixForNamespace,
|
||||
kerTooLargeJpegSegment,
|
||||
kerUnhandledXmpdatum,
|
||||
kerUnhandledXmpNode,
|
||||
kerXMPToolkitError,
|
||||
kerDecodeLangAltPropertyFailed,
|
||||
kerDecodeLangAltQualifierFailed,
|
||||
kerEncodeLangAltPropertyFailed,
|
||||
kerPropertyNameIdentificationFailed,
|
||||
kerSchemaNamespaceNotRegistered,
|
||||
kerNoNamespaceForPrefix,
|
||||
kerAliasesNotSupported,
|
||||
kerInvalidXmpText,
|
||||
kerTooManyTiffDirectoryEntries,
|
||||
kerMultipleTiffArrayElementTagsInDirectory,
|
||||
kerWrongTiffArrayElementTagType,
|
||||
kerInvalidKeyXmpValue,
|
||||
kerInvalidIccProfile,
|
||||
kerInvalidXMP,
|
||||
kerTiffDirectoryTooLarge,
|
||||
kerInvalidTypeValue,
|
||||
kerInvalidLangAltValue,
|
||||
kerInvalidMalloc,
|
||||
kerCorruptedMetadata,
|
||||
kerArithmeticOverflow,
|
||||
kerMallocFailed,
|
||||
//! Complete list of all Exiv2 error codes
|
||||
enum class ErrorCode {
|
||||
kerSuccess = 0,
|
||||
kerGeneralError,
|
||||
kerErrorMessage,
|
||||
kerCallFailed,
|
||||
kerNotAnImage,
|
||||
kerInvalidDataset,
|
||||
kerInvalidRecord,
|
||||
kerInvalidKey,
|
||||
kerInvalidTag,
|
||||
kerValueNotSet,
|
||||
kerDataSourceOpenFailed,
|
||||
kerFileOpenFailed,
|
||||
kerFileContainsUnknownImageType,
|
||||
kerMemoryContainsUnknownImageType,
|
||||
kerUnsupportedImageType,
|
||||
kerFailedToReadImageData,
|
||||
kerNotAJpeg,
|
||||
kerFailedToMapFileForReadWrite,
|
||||
kerFileRenameFailed,
|
||||
kerTransferFailed,
|
||||
kerMemoryTransferFailed,
|
||||
kerInputDataReadFailed,
|
||||
kerImageWriteFailed,
|
||||
kerNoImageInInputData,
|
||||
kerInvalidIfdId,
|
||||
kerValueTooLarge,
|
||||
kerDataAreaValueTooLarge,
|
||||
kerOffsetOutOfRange,
|
||||
kerUnsupportedDataAreaOffsetType,
|
||||
kerInvalidCharset,
|
||||
kerUnsupportedDateFormat,
|
||||
kerUnsupportedTimeFormat,
|
||||
kerWritingImageFormatUnsupported,
|
||||
kerInvalidSettingForImage,
|
||||
kerNotACrwImage,
|
||||
kerFunctionNotSupported,
|
||||
kerNoNamespaceInfoForXmpPrefix,
|
||||
kerNoPrefixForNamespace,
|
||||
kerTooLargeJpegSegment,
|
||||
kerUnhandledXmpdatum,
|
||||
kerUnhandledXmpNode,
|
||||
kerXMPToolkitError,
|
||||
kerDecodeLangAltPropertyFailed,
|
||||
kerDecodeLangAltQualifierFailed,
|
||||
kerEncodeLangAltPropertyFailed,
|
||||
kerPropertyNameIdentificationFailed,
|
||||
kerSchemaNamespaceNotRegistered,
|
||||
kerNoNamespaceForPrefix,
|
||||
kerAliasesNotSupported,
|
||||
kerInvalidXmpText,
|
||||
kerTooManyTiffDirectoryEntries,
|
||||
kerMultipleTiffArrayElementTagsInDirectory,
|
||||
kerWrongTiffArrayElementTagType,
|
||||
kerInvalidKeyXmpValue,
|
||||
kerInvalidIccProfile,
|
||||
kerInvalidXMP,
|
||||
kerTiffDirectoryTooLarge,
|
||||
kerInvalidTypeValue,
|
||||
kerInvalidLangAltValue,
|
||||
kerInvalidMalloc,
|
||||
kerCorruptedMetadata,
|
||||
kerArithmeticOverflow,
|
||||
kerMallocFailed,
|
||||
|
||||
kerErrorCount,
|
||||
};
|
||||
kerErrorCount,
|
||||
};
|
||||
|
||||
/*!
|
||||
@brief Simple error class used for exceptions. An output operator is
|
||||
provided to print errors to a stream.
|
||||
*/
|
||||
class EXIV2API Error : public std::exception
|
||||
{
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
//! Constructor taking only an error code
|
||||
explicit Error(ErrorCode code);
|
||||
/*!
|
||||
@brief Simple error class used for exceptions. An output operator is
|
||||
provided to print errors to a stream.
|
||||
*/
|
||||
class EXIV2API Error : public std::exception {
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
//! Constructor taking only an error code
|
||||
explicit Error(ErrorCode code);
|
||||
|
||||
//! Constructor taking an error code and one argument
|
||||
template <typename A>
|
||||
Error(ErrorCode code, const A& arg1) : code_(code), arg1_(toBasicString<char>(arg1))
|
||||
{
|
||||
setMsg(1);
|
||||
}
|
||||
//! Constructor taking an error code and one argument
|
||||
template <typename A>
|
||||
Error(ErrorCode code, const A& arg1) : code_(code), arg1_(toBasicString<char>(arg1)) {
|
||||
setMsg(1);
|
||||
}
|
||||
|
||||
//! Constructor taking an error code and two arguments
|
||||
template <typename A, typename B>
|
||||
Error(ErrorCode code, const A& arg1, const B& arg2)
|
||||
: code_(code), arg1_(toBasicString<char>(arg1)), arg2_(toBasicString<char>(arg2))
|
||||
{
|
||||
setMsg(2);
|
||||
}
|
||||
//! Constructor taking an error code and two arguments
|
||||
template <typename A, typename B>
|
||||
Error(ErrorCode code, const A& arg1, const B& arg2) :
|
||||
code_(code), arg1_(toBasicString<char>(arg1)), arg2_(toBasicString<char>(arg2)) {
|
||||
setMsg(2);
|
||||
}
|
||||
|
||||
//! Constructor taking an error code and three arguments
|
||||
template <typename A, typename B, typename C>
|
||||
Error(ErrorCode code, const A& arg1, const B& arg2, const C& arg3)
|
||||
: code_(code),
|
||||
arg1_(toBasicString<char>(arg1)),
|
||||
arg2_(toBasicString<char>(arg2)),
|
||||
arg3_(toBasicString<char>(arg3))
|
||||
{
|
||||
setMsg(3);
|
||||
}
|
||||
//! Constructor taking an error code and three arguments
|
||||
template <typename A, typename B, typename C>
|
||||
Error(ErrorCode code, const A& arg1, const B& arg2, const C& arg3) :
|
||||
code_(code),
|
||||
arg1_(toBasicString<char>(arg1)),
|
||||
arg2_(toBasicString<char>(arg2)),
|
||||
arg3_(toBasicString<char>(arg3)) {
|
||||
setMsg(3);
|
||||
}
|
||||
|
||||
//! Virtual destructor. (Needed because of throw())
|
||||
virtual ~Error() noexcept;
|
||||
//@}
|
||||
//! Virtual destructor. (Needed because of throw())
|
||||
virtual ~Error() noexcept;
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
ErrorCode code() const noexcept;
|
||||
/*!
|
||||
@brief Return the error message as a C-string. The pointer returned by what()
|
||||
is valid only as long as the BasicError object exists.
|
||||
*/
|
||||
const char* what() const noexcept override;
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
ErrorCode code() const noexcept;
|
||||
/*!
|
||||
@brief Return the error message as a C-string. The pointer returned by what()
|
||||
is valid only as long as the BasicError object exists.
|
||||
*/
|
||||
const char* what() const noexcept override;
|
||||
//@}
|
||||
|
||||
private:
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
//! Assemble the error message from the arguments
|
||||
void setMsg(int count);
|
||||
//@}
|
||||
private:
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
//! Assemble the error message from the arguments
|
||||
void setMsg(int count);
|
||||
//@}
|
||||
|
||||
// DATA
|
||||
const ErrorCode code_; //!< Error code
|
||||
const std::string arg1_; //!< First argument
|
||||
const std::string arg2_; //!< Second argument
|
||||
const std::string arg3_; //!< Third argument
|
||||
std::string msg_; //!< Complete error message
|
||||
}; // class BasicError
|
||||
// DATA
|
||||
const ErrorCode code_; //!< Error code
|
||||
const std::string arg1_; //!< First argument
|
||||
const std::string arg2_; //!< Second argument
|
||||
const std::string arg3_; //!< Third argument
|
||||
std::string msg_; //!< Complete error message
|
||||
}; // class BasicError
|
||||
|
||||
//! %Error output operator
|
||||
inline std::ostream& operator<<(std::ostream& os, const Error& error)
|
||||
{
|
||||
return os << error.what();
|
||||
}
|
||||
//! %Error output operator
|
||||
inline std::ostream& operator<<(std::ostream& os, const Error& error) {
|
||||
return os << error.what();
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(default : 4275)
|
||||
|
||||
+469
-467
File diff suppressed because it is too large
Load Diff
@@ -5,14 +5,14 @@
|
||||
|
||||
// *****************************************************************************
|
||||
// included header files
|
||||
#include "exiv2/config.h"
|
||||
#include "exiv2/datasets.hpp"
|
||||
#include "exiv2/basicio.hpp"
|
||||
#include "exiv2/bmffimage.hpp"
|
||||
#include "exiv2/bmpimage.hpp"
|
||||
#include "exiv2/config.h"
|
||||
#include "exiv2/convert.hpp"
|
||||
#include "exiv2/cr2image.hpp"
|
||||
#include "exiv2/crwimage.hpp"
|
||||
#include "exiv2/datasets.hpp"
|
||||
#include "exiv2/easyaccess.hpp"
|
||||
#include "exiv2/epsimage.hpp"
|
||||
#include "exiv2/error.hpp"
|
||||
@@ -49,4 +49,4 @@
|
||||
#include "exiv2/xmp_exiv2.hpp"
|
||||
#include "exiv2/xmpsidecar.hpp"
|
||||
|
||||
#endif//ifndef EXIV2_HPP_
|
||||
#endif // ifndef EXIV2_HPP_
|
||||
|
||||
+94
-110
@@ -3,138 +3,122 @@
|
||||
#ifndef FUTILS_HPP_
|
||||
#define FUTILS_HPP_
|
||||
|
||||
#include "exiv2lib_export.h"
|
||||
#include "config.h"
|
||||
#include "exiv2lib_export.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
// namespace extensions
|
||||
namespace Exiv2
|
||||
{
|
||||
//! the name of environmental variables.
|
||||
enum EnVar
|
||||
{
|
||||
envHTTPPOST = 0,
|
||||
envTIMEOUT = 1
|
||||
};
|
||||
//! the collection of protocols.
|
||||
enum Protocol
|
||||
{
|
||||
pFile = 0,
|
||||
pHttp,
|
||||
pFtp,
|
||||
pHttps,
|
||||
pSftp,
|
||||
pFileUri,
|
||||
pDataUri,
|
||||
pStdin
|
||||
};
|
||||
// *********************************************************************
|
||||
// free functions
|
||||
/*!
|
||||
@brief Return the value of environmental variable.
|
||||
@param[in] var The name of environmental variable. Must be a member of the enumeration @ref EnVar.
|
||||
@return the value of environmental variable. If it's empty, the default value is returned.
|
||||
@throws std::out_of_range when an unexpected EnVar is given as input.
|
||||
*/
|
||||
EXIV2API std::string getEnv(int env_var);
|
||||
namespace Exiv2 {
|
||||
//! the name of environmental variables.
|
||||
enum EnVar { envHTTPPOST = 0, envTIMEOUT = 1 };
|
||||
//! the collection of protocols.
|
||||
enum Protocol { pFile = 0, pHttp, pFtp, pHttps, pSftp, pFileUri, pDataUri, pStdin };
|
||||
// *********************************************************************
|
||||
// free functions
|
||||
/*!
|
||||
@brief Return the value of environmental variable.
|
||||
@param[in] var The name of environmental variable. Must be a member of the enumeration @ref EnVar.
|
||||
@return the value of environmental variable. If it's empty, the default value is returned.
|
||||
@throws std::out_of_range when an unexpected EnVar is given as input.
|
||||
*/
|
||||
EXIV2API std::string getEnv(int env_var);
|
||||
|
||||
/*!
|
||||
@brief Encode the input url.
|
||||
@param str The url needs encoding.
|
||||
@return the url-encoded version of str.
|
||||
@note Source: http://www.geekhideout.com/urlcode.shtml
|
||||
@todo This function can probably be hidden into the implementation details
|
||||
*/
|
||||
EXIV2API std::string urlencode(std::string_view str);
|
||||
/*!
|
||||
@brief Encode the input url.
|
||||
@param str The url needs encoding.
|
||||
@return the url-encoded version of str.
|
||||
@note Source: http://www.geekhideout.com/urlcode.shtml
|
||||
@todo This function can probably be hidden into the implementation details
|
||||
*/
|
||||
EXIV2API std::string urlencode(std::string_view str);
|
||||
|
||||
/*!
|
||||
@brief Like urlencode(char* str) but accept the input url in the std::string and modify it.
|
||||
@todo This function can probably be hidden into the implementation details
|
||||
*/
|
||||
EXIV2API void urldecode(std::string& str);
|
||||
/*!
|
||||
@brief Like urlencode(char* str) but accept the input url in the std::string and modify it.
|
||||
@todo This function can probably be hidden into the implementation details
|
||||
*/
|
||||
EXIV2API void urldecode(std::string& str);
|
||||
|
||||
/*!
|
||||
@brief Encode in base64 the data in data_buf and put the resulting string in result.
|
||||
@param data_buf The data need to encode
|
||||
@param dataLength Size in bytes of the in buffer
|
||||
@param result The container for the result, NULL if it fails
|
||||
@param resultSize Size in bytes of the out string, it should be at least
|
||||
((dataLength + 2) / 3) * 4 + 1
|
||||
@return 1 indicate success
|
||||
/*!
|
||||
@brief Encode in base64 the data in data_buf and put the resulting string in result.
|
||||
@param data_buf The data need to encode
|
||||
@param dataLength Size in bytes of the in buffer
|
||||
@param result The container for the result, NULL if it fails
|
||||
@param resultSize Size in bytes of the out string, it should be at least
|
||||
((dataLength + 2) / 3) * 4 + 1
|
||||
@return 1 indicate success
|
||||
|
||||
@note Source: http://en.wikibooks.org/wiki/Algorithm_Implementation/Miscellaneous/Base64
|
||||
*/
|
||||
EXIV2API int base64encode(const void* data_buf, size_t dataLength, char* result, size_t resultSize);
|
||||
@note Source: http://en.wikibooks.org/wiki/Algorithm_Implementation/Miscellaneous/Base64
|
||||
*/
|
||||
EXIV2API int base64encode(const void* data_buf, size_t dataLength, char* result, size_t resultSize);
|
||||
|
||||
/*!
|
||||
@brief Decode base64 data and put the resulting string in out.
|
||||
@param in The data need to decode.
|
||||
@param out The container for the result, it should be large enough to contain the result.
|
||||
@param out_size The size of out in bytes.
|
||||
@return the size of the resulting string. If it fails, return -1.
|
||||
/*!
|
||||
@brief Decode base64 data and put the resulting string in out.
|
||||
@param in The data need to decode.
|
||||
@param out The container for the result, it should be large enough to contain the result.
|
||||
@param out_size The size of out in bytes.
|
||||
@return the size of the resulting string. If it fails, return -1.
|
||||
|
||||
@note Source: https://github.com/davidgaleano/libwebsockets/blob/master/lib/base64-decode.c
|
||||
*/
|
||||
EXIV2API size_t base64decode(const char* in, char* out, size_t out_size);
|
||||
@note Source: https://github.com/davidgaleano/libwebsockets/blob/master/lib/base64-decode.c
|
||||
*/
|
||||
EXIV2API size_t base64decode(const char* in, char* out, size_t out_size);
|
||||
|
||||
/*!
|
||||
@brief Return the protocol of the path.
|
||||
@param path The path of file to extract the protocol.
|
||||
@return the protocol of the path.
|
||||
*/
|
||||
EXIV2API Protocol fileProtocol(const std::string& path);
|
||||
/*!
|
||||
@brief Return the protocol of the path.
|
||||
@param path The path of file to extract the protocol.
|
||||
@return the protocol of the path.
|
||||
*/
|
||||
EXIV2API Protocol fileProtocol(const std::string& path);
|
||||
|
||||
/*!
|
||||
@brief Test if a file exists.
|
||||
/*!
|
||||
@brief Test if a file exists.
|
||||
|
||||
@param path Name of file to verify.
|
||||
@param ct Flag to check if <i>path</i> is a regular file.
|
||||
@return true if <i>path</i> exists and, if <i>ct</i> is set,
|
||||
is a regular file, else false.
|
||||
@param path Name of file to verify.
|
||||
@param ct Flag to check if <i>path</i> is a regular file.
|
||||
@return true if <i>path</i> exists and, if <i>ct</i> is set,
|
||||
is a regular file, else false.
|
||||
|
||||
@note The function calls <b>stat()</b> test for <i>path</i>
|
||||
and its type, see stat(2). <b>errno</b> is left unchanged
|
||||
in case of an error.
|
||||
*/
|
||||
EXIV2API bool fileExists(const std::string& path);
|
||||
@note The function calls <b>stat()</b> test for <i>path</i>
|
||||
and its type, see stat(2). <b>errno</b> is left unchanged
|
||||
in case of an error.
|
||||
*/
|
||||
EXIV2API bool fileExists(const std::string& path);
|
||||
|
||||
/*!
|
||||
@brief Return a system error message and the error code (errno).
|
||||
See %strerror(3).
|
||||
*/
|
||||
EXIV2API std::string strError();
|
||||
/*!
|
||||
@brief Return a system error message and the error code (errno).
|
||||
See %strerror(3).
|
||||
*/
|
||||
EXIV2API std::string strError();
|
||||
|
||||
//! @brief Return the path of the current process.
|
||||
EXIV2API std::string getProcessPath();
|
||||
//! @brief Return the path of the current process.
|
||||
EXIV2API std::string getProcessPath();
|
||||
|
||||
/*!
|
||||
@brief A container for URL components. It also provides the method to parse a
|
||||
URL to get the protocol, host, path, port, querystring, username, password.
|
||||
/*!
|
||||
@brief A container for URL components. It also provides the method to parse a
|
||||
URL to get the protocol, host, path, port, querystring, username, password.
|
||||
|
||||
Source: http://stackoverflow.com/questions/2616011/easy-way-to-parse-a-url-in-c-cross-platform
|
||||
Source: http://stackoverflow.com/questions/2616011/easy-way-to-parse-a-url-in-c-cross-platform
|
||||
|
||||
@todo This class can probably be hidden from the API
|
||||
*/
|
||||
class Uri
|
||||
{
|
||||
public:
|
||||
// DATA
|
||||
std::string QueryString; //!< URL query string
|
||||
std::string Path; //!< URL file path
|
||||
std::string Protocol; //!< URL protocol
|
||||
std::string Host; //!< URL host
|
||||
std::string Port; //!< URL port
|
||||
std::string Username; //!< URL username
|
||||
std::string Password; //!< URL password
|
||||
@todo This class can probably be hidden from the API
|
||||
*/
|
||||
class Uri {
|
||||
public:
|
||||
// DATA
|
||||
std::string QueryString; //!< URL query string
|
||||
std::string Path; //!< URL file path
|
||||
std::string Protocol; //!< URL protocol
|
||||
std::string Host; //!< URL host
|
||||
std::string Port; //!< URL port
|
||||
std::string Username; //!< URL username
|
||||
std::string Password; //!< URL password
|
||||
|
||||
/// @brief Parse the input URL to the protocol, host, path, username, password
|
||||
static Uri EXIV2API Parse(const std::string& uri);
|
||||
/// @brief Parse the input URL to the protocol, host, path, username, password
|
||||
static Uri EXIV2API Parse(const std::string& uri);
|
||||
|
||||
/// @brief Decode the url components.
|
||||
static void EXIV2API Decode(Uri& uri);
|
||||
};
|
||||
/// @brief Decode the url components.
|
||||
static void EXIV2API Decode(Uri& uri);
|
||||
};
|
||||
|
||||
} // namespace Exiv2
|
||||
|
||||
#endif // #ifndef FUTILS_HPP_
|
||||
#endif // #ifndef FUTILS_HPP_
|
||||
|
||||
+70
-71
@@ -12,88 +12,87 @@
|
||||
// *****************************************************************************
|
||||
// namespace extensions
|
||||
namespace Exiv2 {
|
||||
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
|
||||
/*!
|
||||
@brief Class to access raw GIF images. Exif/IPTC metadata are supported
|
||||
directly.
|
||||
*/
|
||||
class EXIV2API GifImage : public Image {
|
||||
public:
|
||||
//! @name NOT Implemented
|
||||
//@{
|
||||
//! Copy constructor
|
||||
GifImage(const GifImage& rhs) = delete;
|
||||
//! Assignment operator
|
||||
GifImage& operator=(const GifImage& rhs) = delete;
|
||||
//@}
|
||||
/*!
|
||||
@brief Class to access raw GIF images. Exif/IPTC metadata are supported
|
||||
directly.
|
||||
*/
|
||||
class EXIV2API GifImage : public Image {
|
||||
public:
|
||||
//! @name NOT Implemented
|
||||
//@{
|
||||
//! Copy constructor
|
||||
GifImage(const GifImage& rhs) = delete;
|
||||
//! Assignment operator
|
||||
GifImage& operator=(const GifImage& rhs) = delete;
|
||||
//@}
|
||||
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor to open a GIF image. Since the
|
||||
constructor can not return a result, callers should check the
|
||||
good() method after object construction to determine success
|
||||
or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
*/
|
||||
explicit GifImage(BasicIo::UniquePtr io);
|
||||
//@}
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor to open a GIF image. Since the
|
||||
constructor can not return a result, callers should check the
|
||||
good() method after object construction to determine success
|
||||
or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
*/
|
||||
explicit GifImage(BasicIo::UniquePtr io);
|
||||
//@}
|
||||
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void readMetadata() override;
|
||||
/*!
|
||||
@brief Todo: Write metadata back to the image. This method is not
|
||||
yet(?) implemented. Calling it will throw an Error(ErrorCode::kerWritingImageFormatUnsupported).
|
||||
*/
|
||||
void writeMetadata() override;
|
||||
/*!
|
||||
@brief Todo: Not supported yet(?). Calling this function will throw
|
||||
an instance of Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setExifData(const ExifData& exifData) override;
|
||||
/*!
|
||||
@brief Todo: Not supported yet(?). Calling this function will throw
|
||||
an instance of Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setIptcData(const IptcData& iptcData) override;
|
||||
/*!
|
||||
@brief Not supported. Calling this function will throw an instance
|
||||
of Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setComment(std::string_view comment) override;
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void readMetadata() override;
|
||||
/*!
|
||||
@brief Todo: Write metadata back to the image. This method is not
|
||||
yet(?) implemented. Calling it will throw an Error(ErrorCode::kerWritingImageFormatUnsupported).
|
||||
*/
|
||||
void writeMetadata() override;
|
||||
/*!
|
||||
@brief Todo: Not supported yet(?). Calling this function will throw
|
||||
an instance of Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setExifData(const ExifData& exifData) override;
|
||||
/*!
|
||||
@brief Todo: Not supported yet(?). Calling this function will throw
|
||||
an instance of Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setIptcData(const IptcData& iptcData) override;
|
||||
/*!
|
||||
@brief Not supported. Calling this function will throw an instance
|
||||
of Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setComment(std::string_view comment) override;
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override;
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override;
|
||||
//@}
|
||||
|
||||
}; // class GifImage
|
||||
}; // class GifImage
|
||||
|
||||
// *****************************************************************************
|
||||
// template, inline and free functions
|
||||
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new GifImage instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newGifInstance(BasicIo::UniquePtr io, bool create);
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new GifImage instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newGifInstance(BasicIo::UniquePtr io, bool create);
|
||||
|
||||
//! Check if the file iIo is a GIF image.
|
||||
EXIV2API bool isGifType(BasicIo& iIo, bool advance);
|
||||
//! Check if the file iIo is a GIF image.
|
||||
EXIV2API bool isGifType(BasicIo& iIo, bool advance);
|
||||
|
||||
} // namespace Exiv2
|
||||
} // namespace Exiv2
|
||||
|
||||
#endif // #ifndef GIFIMAGE_HPP_
|
||||
#endif // #ifndef GIFIMAGE_HPP_
|
||||
|
||||
+9
-10
@@ -7,16 +7,15 @@
|
||||
|
||||
#include "datasets.hpp"
|
||||
|
||||
|
||||
namespace Exiv2 {
|
||||
/*!
|
||||
@brief execute an HTTP request
|
||||
@param request - a Dictionary of headers to send to server
|
||||
@param response - a Dictionary of response headers (dictionary is filled by the response)
|
||||
@param errors - a String with an error
|
||||
@return Server response 200 = OK, 404 = Not Found etc...
|
||||
*/
|
||||
EXIV2API int http(Exiv2::Dictionary& request,Exiv2::Dictionary& response,std::string& errors);
|
||||
}
|
||||
/*!
|
||||
@brief execute an HTTP request
|
||||
@param request - a Dictionary of headers to send to server
|
||||
@param response - a Dictionary of response headers (dictionary is filled by the response)
|
||||
@param errors - a String with an error
|
||||
@return Server response 200 = OK, 404 = Not Found etc...
|
||||
*/
|
||||
EXIV2API int http(Exiv2::Dictionary& request, Exiv2::Dictionary& response, std::string& errors);
|
||||
} // namespace Exiv2
|
||||
|
||||
#endif
|
||||
|
||||
+649
-646
File diff suppressed because it is too large
Load Diff
@@ -3,40 +3,38 @@
|
||||
#ifndef IMAGE_TYPES_H
|
||||
#define IMAGE_TYPES_H
|
||||
|
||||
namespace Exiv2
|
||||
{
|
||||
/// Supported Image Formats
|
||||
enum class ImageType
|
||||
{
|
||||
none,
|
||||
arw,
|
||||
bigtiff,
|
||||
bmff,
|
||||
bmp, ///< Windows bitmap
|
||||
cr2,
|
||||
crw,
|
||||
dng,
|
||||
eps,
|
||||
exv,
|
||||
gif, ///< GIF
|
||||
jp2, ///< JPEG-2000
|
||||
jpeg,
|
||||
mrw,
|
||||
nef,
|
||||
orf,
|
||||
pef,
|
||||
png,
|
||||
pgf,
|
||||
psd, ///< Photoshop (PSD)
|
||||
raf,
|
||||
rw2,
|
||||
sr2,
|
||||
srw,
|
||||
tga,
|
||||
tiff,
|
||||
webp,
|
||||
xmp, ///< XMP sidecar files
|
||||
};
|
||||
namespace Exiv2 {
|
||||
/// Supported Image Formats
|
||||
enum class ImageType {
|
||||
none,
|
||||
arw,
|
||||
bigtiff,
|
||||
bmff,
|
||||
bmp, ///< Windows bitmap
|
||||
cr2,
|
||||
crw,
|
||||
dng,
|
||||
eps,
|
||||
exv,
|
||||
gif, ///< GIF
|
||||
jp2, ///< JPEG-2000
|
||||
jpeg,
|
||||
mrw,
|
||||
nef,
|
||||
orf,
|
||||
pef,
|
||||
png,
|
||||
pgf,
|
||||
psd, ///< Photoshop (PSD)
|
||||
raf,
|
||||
rw2,
|
||||
sr2,
|
||||
srw,
|
||||
tga,
|
||||
tiff,
|
||||
webp,
|
||||
xmp, ///< XMP sidecar files
|
||||
};
|
||||
} // namespace Exiv2
|
||||
|
||||
#endif // IMAGE_TYPES_H
|
||||
|
||||
Executable → Regular
+52
-56
@@ -17,7 +17,6 @@
|
||||
#include <string>
|
||||
|
||||
namespace Exiv2 {
|
||||
|
||||
#ifndef __INI_H__
|
||||
#define __INI_H__
|
||||
|
||||
@@ -72,8 +71,7 @@ int ini_parse_file(FILE* file, ini_handler handler, void* user);
|
||||
|
||||
@return 0 on success
|
||||
*/
|
||||
int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
|
||||
void* user);
|
||||
int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler, void* user);
|
||||
|
||||
/*! @brief Nonzero to allow multi-line value parsing, in the style of Python's
|
||||
configparser. If allowed, ini_parse() will call the handler with the same
|
||||
@@ -122,76 +120,74 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
|
||||
|
||||
#endif /* __INI_H__ */
|
||||
|
||||
|
||||
/*! @brief Read an INI file into easy-to-access name/value pairs. (Note that I've gone
|
||||
for simplicity here rather than speed, but it should be pretty decent.)
|
||||
*/
|
||||
class EXIV2API INIReader
|
||||
{
|
||||
public:
|
||||
/*! @brief Construct INIReader and parse given filename. See ini.h for more info
|
||||
about the parsing.
|
||||
*/
|
||||
explicit INIReader(const std::string& filename);
|
||||
class EXIV2API INIReader {
|
||||
public:
|
||||
/*! @brief Construct INIReader and parse given filename. See ini.h for more info
|
||||
about the parsing.
|
||||
*/
|
||||
explicit INIReader(const std::string& filename);
|
||||
|
||||
/*! @brief Return the result of ini_parse(), i.e., 0 on success, line number of
|
||||
first error on parse error, or -1 on file open error.
|
||||
*/
|
||||
int ParseError() const;
|
||||
/*! @brief Return the result of ini_parse(), i.e., 0 on success, line number of
|
||||
first error on parse error, or -1 on file open error.
|
||||
*/
|
||||
int ParseError() const;
|
||||
|
||||
/*! @brief Get a string value from INI file, returning default_value if not found.
|
||||
/*! @brief Get a string value from INI file, returning default_value if not found.
|
||||
|
||||
@param section name of section
|
||||
@param name name of key
|
||||
@param default_value default if not found
|
||||
@param section name of section
|
||||
@param name name of key
|
||||
@param default_value default if not found
|
||||
|
||||
@return value
|
||||
*/
|
||||
std::string Get(const std::string& section, const std::string& name, const std::string& default_value);
|
||||
@return value
|
||||
*/
|
||||
std::string Get(const std::string& section, const std::string& name, const std::string& default_value);
|
||||
|
||||
/*! @brief Get an integer (long) value from INI file, returning default_value if
|
||||
not found or not a valid integer (decimal "1234", "-1234", or hex "0x4d2").
|
||||
/*! @brief Get an integer (long) value from INI file, returning default_value if
|
||||
not found or not a valid integer (decimal "1234", "-1234", or hex "0x4d2").
|
||||
|
||||
@param section name of section
|
||||
@param name name of key
|
||||
@param default_value default if not found
|
||||
@param section name of section
|
||||
@param name name of key
|
||||
@param default_value default if not found
|
||||
|
||||
@return value
|
||||
*/
|
||||
long GetInteger(const std::string& section, const std::string& name, long default_value);
|
||||
@return value
|
||||
*/
|
||||
long GetInteger(const std::string& section, const std::string& name, long default_value);
|
||||
|
||||
/*! @brief Get a real (floating point double) value from INI file, returning
|
||||
default_value if not found or not a valid floating point value
|
||||
according to strtod().
|
||||
/*! @brief Get a real (floating point double) value from INI file, returning
|
||||
default_value if not found or not a valid floating point value
|
||||
according to strtod().
|
||||
|
||||
@param section name of section
|
||||
@param name name of key
|
||||
@param default_value default if not found
|
||||
@param section name of section
|
||||
@param name name of key
|
||||
@param default_value default if not found
|
||||
|
||||
@return value
|
||||
*/
|
||||
double GetReal(const std::string& section, const std::string& name, double default_value);
|
||||
@return value
|
||||
*/
|
||||
double GetReal(const std::string& section, const std::string& name, double default_value);
|
||||
|
||||
/*! @brief Get a boolean value from INI file, returning default_value if not found or if
|
||||
not a valid true/false value. Valid true values are "true", "yes", "on", "1",
|
||||
and valid false values are "false", "no", "off", "0" (not case sensitive).
|
||||
/*! @brief Get a boolean value from INI file, returning default_value if not found or if
|
||||
not a valid true/false value. Valid true values are "true", "yes", "on", "1",
|
||||
and valid false values are "false", "no", "off", "0" (not case sensitive).
|
||||
|
||||
@param section name of section
|
||||
@param name name of key
|
||||
@param default_value default if not found
|
||||
@param section name of section
|
||||
@param name name of key
|
||||
@param default_value default if not found
|
||||
|
||||
@return value
|
||||
*/
|
||||
bool GetBoolean(const std::string& section, const std::string& name, bool default_value);
|
||||
@return value
|
||||
*/
|
||||
bool GetBoolean(const std::string& section, const std::string& name, bool default_value);
|
||||
|
||||
private:
|
||||
int _error; //!< status
|
||||
std::map<std::string, std::string> _values; //!< values from file
|
||||
static std::string MakeKey(const std::string& section,
|
||||
const std::string& name); //!< return key encoded from section/name
|
||||
static int ValueHandler(void* user, const char* section, const char* name,
|
||||
const char* value); //!< value handler
|
||||
private:
|
||||
int _error; //!< status
|
||||
std::map<std::string, std::string> _values; //!< values from file
|
||||
static std::string MakeKey(const std::string& section,
|
||||
const std::string& name); //!< return key encoded from section/name
|
||||
static int ValueHandler(void* user, const char* section, const char* name,
|
||||
const char* value); //!< value handler
|
||||
};
|
||||
} // namespace Exiv2
|
||||
} // namespace Exiv2
|
||||
|
||||
#endif // __INIREADER_H__
|
||||
|
||||
+254
-243
@@ -11,285 +11,296 @@
|
||||
#include "exiv2lib_export.h"
|
||||
|
||||
// included header files
|
||||
#include "metadatum.hpp"
|
||||
#include "datasets.hpp"
|
||||
#include "metadatum.hpp"
|
||||
|
||||
// *****************************************************************************
|
||||
// namespace extensions
|
||||
namespace Exiv2 {
|
||||
|
||||
// *****************************************************************************
|
||||
// class declarations
|
||||
class ExifData;
|
||||
class ExifData;
|
||||
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
|
||||
/*!
|
||||
@brief An IPTC metadatum ("dataset"), consisting of an IptcKey and a
|
||||
Value and methods to manipulate these.
|
||||
/*!
|
||||
@brief An IPTC metadatum ("dataset"), consisting of an IptcKey and a
|
||||
Value and methods to manipulate these.
|
||||
|
||||
This is referred in the standard as a property.
|
||||
*/
|
||||
class EXIV2API Iptcdatum : public Metadatum {
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor for new tags created by an application. The
|
||||
%Iptcdatum is created from a key / value pair. %Iptcdatum
|
||||
copies (clones) the value if one is provided. Alternatively, a
|
||||
program can create an 'empty' %Iptcdatum with only a key and
|
||||
set the value using setValue().
|
||||
This is referred in the standard as a property.
|
||||
*/
|
||||
class EXIV2API Iptcdatum : public Metadatum {
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor for new tags created by an application. The
|
||||
%Iptcdatum is created from a key / value pair. %Iptcdatum
|
||||
copies (clones) the value if one is provided. Alternatively, a
|
||||
program can create an 'empty' %Iptcdatum with only a key and
|
||||
set the value using setValue().
|
||||
|
||||
@param key The key of the %Iptcdatum.
|
||||
@param pValue Pointer to a %Iptcdatum value.
|
||||
@throw Error if the key cannot be parsed and converted
|
||||
to a tag number and record id.
|
||||
*/
|
||||
explicit Iptcdatum(const IptcKey& key, const Value* pValue = nullptr);
|
||||
//! Copy constructor
|
||||
Iptcdatum(const Iptcdatum& rhs);
|
||||
//! Destructor
|
||||
~Iptcdatum() override = default;
|
||||
//@}
|
||||
@param key The key of the %Iptcdatum.
|
||||
@param pValue Pointer to a %Iptcdatum value.
|
||||
@throw Error if the key cannot be parsed and converted
|
||||
to a tag number and record id.
|
||||
*/
|
||||
explicit Iptcdatum(const IptcKey& key, const Value* pValue = nullptr);
|
||||
//! Copy constructor
|
||||
Iptcdatum(const Iptcdatum& rhs);
|
||||
//! Destructor
|
||||
~Iptcdatum() override = default;
|
||||
//@}
|
||||
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
//! Assignment operator
|
||||
Iptcdatum& operator=(const Iptcdatum& rhs);
|
||||
/*!
|
||||
@brief Assign \em value to the %Iptcdatum. The type of the new Value
|
||||
is set to UShortValue.
|
||||
*/
|
||||
Iptcdatum& operator=(const uint16_t& value);
|
||||
/*!
|
||||
@brief Assign \em value to the %Iptcdatum.
|
||||
Calls setValue(const std::string&).
|
||||
*/
|
||||
Iptcdatum& operator=(const std::string& value);
|
||||
/*!
|
||||
@brief Assign \em value to the %Iptcdatum.
|
||||
Calls setValue(const Value*).
|
||||
*/
|
||||
Iptcdatum& operator=(const Value& value);
|
||||
void setValue(const Value* pValue) override;
|
||||
/*!
|
||||
@brief Set the value to the string \em value, using
|
||||
Value::read(const std::string&).
|
||||
If the %Iptcdatum does not have a Value yet, then a %Value of
|
||||
the correct type for this %Iptcdatum is created. If that
|
||||
fails (because of an unknown dataset), a StringValue is
|
||||
created. Return 0 if the value was read successfully.
|
||||
*/
|
||||
int setValue(const std::string& value) override;
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
//! Assignment operator
|
||||
Iptcdatum& operator=(const Iptcdatum& rhs);
|
||||
/*!
|
||||
@brief Assign \em value to the %Iptcdatum. The type of the new Value
|
||||
is set to UShortValue.
|
||||
*/
|
||||
Iptcdatum& operator=(const uint16_t& value);
|
||||
/*!
|
||||
@brief Assign \em value to the %Iptcdatum.
|
||||
Calls setValue(const std::string&).
|
||||
*/
|
||||
Iptcdatum& operator=(const std::string& value);
|
||||
/*!
|
||||
@brief Assign \em value to the %Iptcdatum.
|
||||
Calls setValue(const Value*).
|
||||
*/
|
||||
Iptcdatum& operator=(const Value& value);
|
||||
void setValue(const Value* pValue) override;
|
||||
/*!
|
||||
@brief Set the value to the string \em value, using
|
||||
Value::read(const std::string&).
|
||||
If the %Iptcdatum does not have a Value yet, then a %Value of
|
||||
the correct type for this %Iptcdatum is created. If that
|
||||
fails (because of an unknown dataset), a StringValue is
|
||||
created. Return 0 if the value was read successfully.
|
||||
*/
|
||||
int setValue(const std::string& value) override;
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
size_t copy(byte* buf, ByteOrder byteOrder) const override;
|
||||
std::ostream& write(std::ostream& os, const ExifData* pMetadata = nullptr) const override;
|
||||
/*!
|
||||
@brief Return the key of the Iptcdatum. The key is of the form
|
||||
'<b>Iptc</b>.recordName.datasetName'. Note however that the key
|
||||
is not necessarily unique, i.e., an IptcData object may contain
|
||||
multiple metadata with the same key.
|
||||
*/
|
||||
std::string key() const override;
|
||||
/*!
|
||||
@brief Return the name of the record (deprecated)
|
||||
@return record name
|
||||
*/
|
||||
std::string recordName() const;
|
||||
/*!
|
||||
@brief Return the record id
|
||||
@return record id
|
||||
*/
|
||||
uint16_t record() const;
|
||||
const char* familyName() const override;
|
||||
std::string groupName() const override;
|
||||
/*!
|
||||
@brief Return the name of the tag (aka dataset)
|
||||
@return tag name
|
||||
*/
|
||||
std::string tagName() const override;
|
||||
std::string tagLabel() const override;
|
||||
//! Return the tag (aka dataset) number
|
||||
uint16_t tag() const override;
|
||||
TypeId typeId() const override;
|
||||
const char* typeName() const override;
|
||||
size_t typeSize() const override;
|
||||
size_t count() const override;
|
||||
size_t size() const override;
|
||||
std::string toString() const override;
|
||||
std::string toString(size_t n) const override;
|
||||
int64_t toInt64(size_t n = 0) const override;
|
||||
float toFloat(size_t n = 0) const override;
|
||||
Rational toRational(size_t n = 0) const override;
|
||||
Value::UniquePtr getValue() const override;
|
||||
const Value& value() const override;
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
size_t copy(byte* buf, ByteOrder byteOrder) const override;
|
||||
std::ostream& write(std::ostream& os, const ExifData* pMetadata = nullptr) const override;
|
||||
/*!
|
||||
@brief Return the key of the Iptcdatum. The key is of the form
|
||||
'<b>Iptc</b>.recordName.datasetName'. Note however that the key
|
||||
is not necessarily unique, i.e., an IptcData object may contain
|
||||
multiple metadata with the same key.
|
||||
*/
|
||||
std::string key() const override;
|
||||
/*!
|
||||
@brief Return the name of the record (deprecated)
|
||||
@return record name
|
||||
*/
|
||||
std::string recordName() const;
|
||||
/*!
|
||||
@brief Return the record id
|
||||
@return record id
|
||||
*/
|
||||
uint16_t record() const;
|
||||
const char* familyName() const override;
|
||||
std::string groupName() const override;
|
||||
/*!
|
||||
@brief Return the name of the tag (aka dataset)
|
||||
@return tag name
|
||||
*/
|
||||
std::string tagName() const override;
|
||||
std::string tagLabel() const override;
|
||||
//! Return the tag (aka dataset) number
|
||||
uint16_t tag() const override;
|
||||
TypeId typeId() const override;
|
||||
const char* typeName() const override;
|
||||
size_t typeSize() const override;
|
||||
size_t count() const override;
|
||||
size_t size() const override;
|
||||
std::string toString() const override;
|
||||
std::string toString(size_t n) const override;
|
||||
int64_t toInt64(size_t n = 0) const override;
|
||||
float toFloat(size_t n = 0) const override;
|
||||
Rational toRational(size_t n = 0) const override;
|
||||
Value::UniquePtr getValue() const override;
|
||||
const Value& value() const override;
|
||||
//@}
|
||||
|
||||
private:
|
||||
// DATA
|
||||
IptcKey::UniquePtr key_; //!< Key
|
||||
Value::UniquePtr value_; //!< Value
|
||||
private:
|
||||
// DATA
|
||||
IptcKey::UniquePtr key_; //!< Key
|
||||
Value::UniquePtr value_; //!< Value
|
||||
|
||||
}; // class Iptcdatum
|
||||
}; // class Iptcdatum
|
||||
|
||||
//! Container type to hold all metadata
|
||||
using IptcMetadata = std::vector<Iptcdatum>;
|
||||
//! Container type to hold all metadata
|
||||
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.
|
||||
|
||||
Provide high-level access to the IPTC data of an image:
|
||||
- read IPTC information from JPEG files
|
||||
- access metadata through keys and standard C++ iterators
|
||||
- add, modify and delete metadata
|
||||
- write IPTC data to JPEG files
|
||||
- extract IPTC metadata to files, insert from these files
|
||||
*/
|
||||
class EXIV2API IptcData {
|
||||
public:
|
||||
//! IptcMetadata iterator type
|
||||
using iterator = IptcMetadata::iterator;
|
||||
//! IptcMetadata const iterator type
|
||||
using const_iterator = IptcMetadata::const_iterator;
|
||||
Provide high-level access to the IPTC data of an image:
|
||||
- read IPTC information from JPEG files
|
||||
- access metadata through keys and standard C++ iterators
|
||||
- add, modify and delete metadata
|
||||
- write IPTC data to JPEG files
|
||||
- extract IPTC metadata to files, insert from these files
|
||||
*/
|
||||
class EXIV2API IptcData {
|
||||
public:
|
||||
//! IptcMetadata iterator type
|
||||
using iterator = IptcMetadata::iterator;
|
||||
//! IptcMetadata const iterator type
|
||||
using const_iterator = IptcMetadata::const_iterator;
|
||||
|
||||
// Use the compiler generated constructors and assignment operator
|
||||
// Use the compiler generated constructors and assignment operator
|
||||
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
/*!
|
||||
@brief Returns a reference to the %Iptcdatum that is associated with a
|
||||
particular \em key. If %IptcData does not already contain such
|
||||
an %Iptcdatum, operator[] adds object \em Iptcdatum(key).
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
/*!
|
||||
@brief Returns a reference to the %Iptcdatum that is associated with a
|
||||
particular \em key. If %IptcData does not already contain such
|
||||
an %Iptcdatum, operator[] adds object \em Iptcdatum(key).
|
||||
|
||||
@note Since operator[] might insert a new element, it can't be a const
|
||||
member function.
|
||||
*/
|
||||
Iptcdatum& operator[](const std::string& key);
|
||||
/*!
|
||||
@brief Add an %Iptcdatum from the supplied key and value pair. This
|
||||
method copies (clones) the value. A check for non-repeatable
|
||||
datasets is performed.
|
||||
@return 0 if successful;<BR>
|
||||
6 if the dataset already exists and is not repeatable
|
||||
*/
|
||||
int add(const IptcKey& key, Value* value);
|
||||
/*!
|
||||
@brief Add a copy of the Iptcdatum to the IPTC metadata. A check
|
||||
for non-repeatable datasets is performed.
|
||||
@return 0 if successful;<BR>
|
||||
6 if the dataset already exists and is not repeatable;<BR>
|
||||
*/
|
||||
int add(const Iptcdatum& iptcdatum);
|
||||
/*!
|
||||
@brief Delete the Iptcdatum at iterator position pos, return the
|
||||
position of the next Iptcdatum. Note that iterators into
|
||||
the metadata, including pos, are potentially invalidated
|
||||
by this call.
|
||||
*/
|
||||
iterator erase(iterator pos);
|
||||
/*!
|
||||
@brief Delete all Iptcdatum instances resulting in an empty container.
|
||||
*/
|
||||
void clear() { iptcMetadata_.clear(); }
|
||||
//! Sort metadata by key
|
||||
void sortByKey();
|
||||
//! Sort metadata by tag (aka dataset)
|
||||
void sortByTag();
|
||||
//! Begin of the metadata
|
||||
iterator begin() { return iptcMetadata_.begin(); }
|
||||
//! End of the metadata
|
||||
iterator end() { return iptcMetadata_.end(); }
|
||||
/*!
|
||||
@brief Find the first Iptcdatum with the given key, return an iterator
|
||||
to it.
|
||||
*/
|
||||
iterator findKey(const IptcKey& key);
|
||||
/*!
|
||||
@brief Find the first Iptcdatum with the given record and dataset it,
|
||||
return a const iterator to it.
|
||||
*/
|
||||
iterator findId(uint16_t dataset,
|
||||
uint16_t record = IptcDataSets::application2);
|
||||
//@}
|
||||
@note Since operator[] might insert a new element, it can't be a const
|
||||
member function.
|
||||
*/
|
||||
Iptcdatum& operator[](const std::string& key);
|
||||
/*!
|
||||
@brief Add an %Iptcdatum from the supplied key and value pair. This
|
||||
method copies (clones) the value. A check for non-repeatable
|
||||
datasets is performed.
|
||||
@return 0 if successful;<BR>
|
||||
6 if the dataset already exists and is not repeatable
|
||||
*/
|
||||
int add(const IptcKey& key, Value* value);
|
||||
/*!
|
||||
@brief Add a copy of the Iptcdatum to the IPTC metadata. A check
|
||||
for non-repeatable datasets is performed.
|
||||
@return 0 if successful;<BR>
|
||||
6 if the dataset already exists and is not repeatable;<BR>
|
||||
*/
|
||||
int add(const Iptcdatum& iptcdatum);
|
||||
/*!
|
||||
@brief Delete the Iptcdatum at iterator position pos, return the
|
||||
position of the next Iptcdatum. Note that iterators into
|
||||
the metadata, including pos, are potentially invalidated
|
||||
by this call.
|
||||
*/
|
||||
iterator erase(iterator pos);
|
||||
/*!
|
||||
@brief Delete all Iptcdatum instances resulting in an empty container.
|
||||
*/
|
||||
void clear() {
|
||||
iptcMetadata_.clear();
|
||||
}
|
||||
//! Sort metadata by key
|
||||
void sortByKey();
|
||||
//! Sort metadata by tag (aka dataset)
|
||||
void sortByTag();
|
||||
//! Begin of the metadata
|
||||
iterator begin() {
|
||||
return iptcMetadata_.begin();
|
||||
}
|
||||
//! End of the metadata
|
||||
iterator end() {
|
||||
return iptcMetadata_.end();
|
||||
}
|
||||
/*!
|
||||
@brief Find the first Iptcdatum with the given key, return an iterator
|
||||
to it.
|
||||
*/
|
||||
iterator findKey(const IptcKey& key);
|
||||
/*!
|
||||
@brief Find the first Iptcdatum with the given record and dataset it,
|
||||
return a const iterator to it.
|
||||
*/
|
||||
iterator findId(uint16_t dataset, uint16_t record = IptcDataSets::application2);
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
//! Begin of the metadata
|
||||
const_iterator begin() const { return iptcMetadata_.begin(); }
|
||||
//! End of the metadata
|
||||
const_iterator end() const { return iptcMetadata_.end(); }
|
||||
/*!
|
||||
@brief Find the first Iptcdatum with the given key, return a const
|
||||
iterator to it.
|
||||
*/
|
||||
const_iterator findKey(const IptcKey& key) const;
|
||||
/*!
|
||||
@brief Find the first Iptcdatum with the given record and dataset
|
||||
number, return a const iterator to it.
|
||||
*/
|
||||
const_iterator findId(uint16_t dataset,
|
||||
uint16_t record = IptcDataSets::application2) const;
|
||||
//! Return true if there is no IPTC metadata
|
||||
bool empty() const { return count() == 0; }
|
||||
//! @name Accessors
|
||||
//@{
|
||||
//! Begin of the metadata
|
||||
const_iterator begin() const {
|
||||
return iptcMetadata_.begin();
|
||||
}
|
||||
//! End of the metadata
|
||||
const_iterator end() const {
|
||||
return iptcMetadata_.end();
|
||||
}
|
||||
/*!
|
||||
@brief Find the first Iptcdatum with the given key, return a const
|
||||
iterator to it.
|
||||
*/
|
||||
const_iterator findKey(const IptcKey& key) const;
|
||||
/*!
|
||||
@brief Find the first Iptcdatum with the given record and dataset
|
||||
number, return a const iterator to it.
|
||||
*/
|
||||
const_iterator findId(uint16_t dataset, uint16_t record = IptcDataSets::application2) const;
|
||||
//! Return true if there is no IPTC metadata
|
||||
bool empty() const {
|
||||
return count() == 0;
|
||||
}
|
||||
|
||||
//! Get the number of metadata entries
|
||||
size_t count() const { return iptcMetadata_.size(); }
|
||||
//! Get the number of metadata entries
|
||||
size_t count() const {
|
||||
return iptcMetadata_.size();
|
||||
}
|
||||
|
||||
//! @brief Return the exact size of all contained IPTC metadata
|
||||
size_t size() const;
|
||||
//! @brief Return the exact size of all contained IPTC metadata
|
||||
size_t size() const;
|
||||
|
||||
//! @brief Return the metadata charset name or 0
|
||||
const char *detectCharset() const;
|
||||
//! @brief Return the metadata charset name or 0
|
||||
const char* detectCharset() const;
|
||||
|
||||
//! @brief dump iptc formatted binary data (used by printStructure kpsRecursive)
|
||||
static void printStructure(std::ostream& out, const Slice<byte*>& bytes,uint32_t depth);
|
||||
//@}
|
||||
//! @brief dump iptc formatted binary data (used by printStructure kpsRecursive)
|
||||
static void printStructure(std::ostream& out, const Slice<byte*>& bytes, uint32_t depth);
|
||||
//@}
|
||||
|
||||
private:
|
||||
// DATA
|
||||
IptcMetadata iptcMetadata_;
|
||||
}; // class IptcData
|
||||
private:
|
||||
// DATA
|
||||
IptcMetadata iptcMetadata_;
|
||||
}; // class IptcData
|
||||
|
||||
/*!
|
||||
@brief Stateless parser class for IPTC data. Images use this class to
|
||||
decode and encode binary IPTC data.
|
||||
*/
|
||||
class EXIV2API IptcParser {
|
||||
public:
|
||||
/*!
|
||||
@brief Decode binary IPTC data in IPTC IIM4 format from a buffer \em pData
|
||||
of length \em size to the provided metadata container.
|
||||
/*!
|
||||
@brief Stateless parser class for IPTC data. Images use this class to
|
||||
decode and encode binary IPTC data.
|
||||
*/
|
||||
class EXIV2API IptcParser {
|
||||
public:
|
||||
/*!
|
||||
@brief Decode binary IPTC data in IPTC IIM4 format from a buffer \em pData
|
||||
of length \em size to the provided metadata container.
|
||||
|
||||
@param iptcData Metadata container to add the decoded IPTC datasets to.
|
||||
@param pData Pointer to the data buffer to read from.
|
||||
@param size Number of bytes in the data buffer.
|
||||
@param iptcData Metadata container to add the decoded IPTC datasets to.
|
||||
@param pData Pointer to the data buffer to read from.
|
||||
@param size Number of bytes in the data buffer.
|
||||
|
||||
@return 0 if successful;<BR>
|
||||
5 if the binary IPTC data is invalid or corrupt
|
||||
*/
|
||||
static int decode(IptcData& iptcData, const byte* pData, size_t size);
|
||||
@return 0 if successful;<BR>
|
||||
5 if the binary IPTC data is invalid or corrupt
|
||||
*/
|
||||
static int decode(IptcData& iptcData, const byte* pData, size_t size);
|
||||
|
||||
/*!
|
||||
@brief Encode the IPTC datasets from \em iptcData to a binary representation in IPTC IIM4 format.
|
||||
/*!
|
||||
@brief Encode the IPTC datasets from \em iptcData to a binary representation in IPTC IIM4 format.
|
||||
|
||||
Convert the IPTC datasets to binary format and return it. Caller owns
|
||||
the returned buffer. The copied data follows the IPTC IIM4 standard.
|
||||
Convert the IPTC datasets to binary format and return it. Caller owns
|
||||
the returned buffer. The copied data follows the IPTC IIM4 standard.
|
||||
|
||||
@return Data buffer containing the binary IPTC data in IPTC IIM4 format.
|
||||
*/
|
||||
static DataBuf encode(const IptcData& iptcData);
|
||||
@return Data buffer containing the binary IPTC data in IPTC IIM4 format.
|
||||
*/
|
||||
static DataBuf encode(const IptcData& iptcData);
|
||||
|
||||
private:
|
||||
// Constant data
|
||||
static const byte marker_; // Dataset marker
|
||||
private:
|
||||
// Constant data
|
||||
static const byte marker_; // Dataset marker
|
||||
|
||||
}; // class IptcParser
|
||||
}; // class IptcParser
|
||||
|
||||
} // namespace Exiv2
|
||||
} // namespace Exiv2
|
||||
|
||||
#endif // #ifndef IPTC_HPP_
|
||||
#endif // #ifndef IPTC_HPP_
|
||||
|
||||
+79
-81
@@ -11,103 +11,101 @@
|
||||
|
||||
// *****************************************************************************
|
||||
// namespace extensions
|
||||
namespace Exiv2
|
||||
{
|
||||
|
||||
namespace Exiv2 {
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
|
||||
/*!
|
||||
@brief Class to access JPEG-2000 images.
|
||||
*/
|
||||
class EXIV2API Jp2Image : public Image {
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor to open a JPEG-2000 image. Since the
|
||||
constructor can not return a result, callers should check the
|
||||
good() method after object construction to determine success
|
||||
or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
@param create Specifies if an existing image should be read (false)
|
||||
or if a new file should be created (true).
|
||||
*/
|
||||
Jp2Image(BasicIo::UniquePtr io, bool create);
|
||||
//@}
|
||||
/*!
|
||||
@brief Class to access JPEG-2000 images.
|
||||
*/
|
||||
class EXIV2API Jp2Image : public Image {
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor to open a JPEG-2000 image. Since the
|
||||
constructor can not return a result, callers should check the
|
||||
good() method after object construction to determine success
|
||||
or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
@param create Specifies if an existing image should be read (false)
|
||||
or if a new file should be created (true).
|
||||
*/
|
||||
Jp2Image(BasicIo::UniquePtr io, bool create);
|
||||
//@}
|
||||
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void readMetadata() override;
|
||||
void writeMetadata() override;
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void readMetadata() override;
|
||||
void writeMetadata() override;
|
||||
|
||||
/*!
|
||||
@brief Print out the structure of image file.
|
||||
@throw Error if reading of the file fails or the image data is
|
||||
not valid (does not look like data of the specific image type).
|
||||
@warning This function is not thread safe and intended for exiv2 -pS for debugging.
|
||||
*/
|
||||
void printStructure(std::ostream& out, PrintStructureOption option, int depth) override;
|
||||
/*!
|
||||
@brief Print out the structure of image file.
|
||||
@throw Error if reading of the file fails or the image data is
|
||||
not valid (does not look like data of the specific image type).
|
||||
@warning This function is not thread safe and intended for exiv2 -pS for debugging.
|
||||
*/
|
||||
void printStructure(std::ostream &out, PrintStructureOption option, int depth) override;
|
||||
|
||||
/*!
|
||||
@brief Todo: Not supported yet(?). Calling this function will throw
|
||||
an instance of Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setComment(std::string_view comment) override;
|
||||
//@}
|
||||
/*!
|
||||
@brief Todo: Not supported yet(?). Calling this function will throw
|
||||
an instance of Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setComment(std::string_view comment) override;
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override;
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override;
|
||||
//@}
|
||||
|
||||
//! @name NOT Implemented
|
||||
//@{
|
||||
//! Copy constructor
|
||||
Jp2Image(const Jp2Image& rhs) = delete;
|
||||
//! Assignment operator
|
||||
Jp2Image& operator=(const Jp2Image& rhs) = delete;
|
||||
//! @name NOT Implemented
|
||||
//@{
|
||||
//! Copy constructor
|
||||
Jp2Image(const Jp2Image &rhs) = delete;
|
||||
//! Assignment operator
|
||||
Jp2Image &operator=(const Jp2Image &rhs) = delete;
|
||||
|
||||
private:
|
||||
/*!
|
||||
@brief Provides the main implementation of writeMetadata() by
|
||||
writing all buffered metadata to the provided BasicIo.
|
||||
@param oIo BasicIo instance to write to (a temporary location).
|
||||
private:
|
||||
/*!
|
||||
@brief Provides the main implementation of writeMetadata() by
|
||||
writing all buffered metadata to the provided BasicIo.
|
||||
@param oIo BasicIo instance to write to (a temporary location).
|
||||
|
||||
@return 4 if opening or writing to the associated BasicIo fails
|
||||
*/
|
||||
void doWriteMetadata(BasicIo& outIo);
|
||||
@return 4 if opening or writing to the associated BasicIo fails
|
||||
*/
|
||||
void doWriteMetadata(BasicIo &outIo);
|
||||
|
||||
/*!
|
||||
@brief reformats the Jp2Header to store iccProfile
|
||||
@param oldData DataBufRef to data in the file.
|
||||
@param newData DataBufRef with updated data
|
||||
*/
|
||||
void encodeJp2Header(const DataBuf& boxBuf, DataBuf& outBuf);
|
||||
//@}
|
||||
/*!
|
||||
@brief reformats the Jp2Header to store iccProfile
|
||||
@param oldData DataBufRef to data in the file.
|
||||
@param newData DataBufRef with updated data
|
||||
*/
|
||||
void encodeJp2Header(const DataBuf &boxBuf, DataBuf &outBuf);
|
||||
//@}
|
||||
|
||||
}; // class Jp2Image
|
||||
}; // class Jp2Image
|
||||
|
||||
// *****************************************************************************
|
||||
// template, inline and free functions
|
||||
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new Jp2Image instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newJp2Instance(BasicIo::UniquePtr io, bool create);
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new Jp2Image instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newJp2Instance(BasicIo::UniquePtr io, bool create);
|
||||
|
||||
//! Check if the file iIo is a JPEG-2000 image.
|
||||
EXIV2API bool isJp2Type(BasicIo& iIo, bool advance);
|
||||
//! Check if the file iIo is a JPEG-2000 image.
|
||||
EXIV2API bool isJp2Type(BasicIo &iIo, bool advance);
|
||||
|
||||
} // namespace Exiv2
|
||||
} // namespace Exiv2
|
||||
|
||||
#endif // #ifndef JP2IMAGE_HPP_
|
||||
#endif // #ifndef JP2IMAGE_HPP_
|
||||
|
||||
+341
-354
@@ -9,403 +9,390 @@
|
||||
#include <array>
|
||||
|
||||
// included header files
|
||||
#include "image.hpp"
|
||||
#include "error.hpp"
|
||||
#include "image.hpp"
|
||||
|
||||
// *****************************************************************************
|
||||
// namespace extensions
|
||||
namespace Exiv2 {
|
||||
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
|
||||
/*!
|
||||
@brief Helper class, has methods to deal with %Photoshop "Information
|
||||
Resource Blocks" (IRBs).
|
||||
*/
|
||||
struct EXIV2API Photoshop {
|
||||
// Todo: Public for now
|
||||
static constexpr std::array<const char*, 4> irbId_{"8BIM", "AgHg", "DCSR", "PHUT"}; //!< %Photoshop IRB markers
|
||||
inline static const char* ps3Id_ = "Photoshop 3.0\0"; //!< %Photoshop marker
|
||||
inline static const char* bimId_ = "8BIM"; //!< %Photoshop IRB marker (deprecated)
|
||||
inline static const uint16_t iptc_ = 0x0404; //!< %Photoshop IPTC marker
|
||||
inline static const uint16_t preview_ = 0x040c; //!< %Photoshop preview marker
|
||||
/*!
|
||||
@brief Helper class, has methods to deal with %Photoshop "Information
|
||||
Resource Blocks" (IRBs).
|
||||
*/
|
||||
struct EXIV2API Photoshop {
|
||||
// Todo: Public for now
|
||||
static constexpr std::array<const char*, 4> irbId_{"8BIM", "AgHg", "DCSR", "PHUT"}; //!< %Photoshop IRB markers
|
||||
inline static const char* ps3Id_ = "Photoshop 3.0\0"; //!< %Photoshop marker
|
||||
inline static const char* bimId_ = "8BIM"; //!< %Photoshop IRB marker (deprecated)
|
||||
inline static const uint16_t iptc_ = 0x0404; //!< %Photoshop IPTC marker
|
||||
inline static const uint16_t preview_ = 0x040c; //!< %Photoshop preview marker
|
||||
|
||||
/*!
|
||||
@brief Checks an IRB
|
||||
/*!
|
||||
@brief Checks an IRB
|
||||
|
||||
@param pPsData Existing IRB buffer
|
||||
@param sizePsData Size of the IRB buffer
|
||||
@return true if the IRB marker is known and the buffer is big enough to check this;<BR>
|
||||
false otherwise
|
||||
*/
|
||||
static bool isIrb(const byte* pPsData, size_t sizePsData);
|
||||
/*!
|
||||
@brief Validates all IRBs
|
||||
@param pPsData Existing IRB buffer
|
||||
@param sizePsData Size of the IRB buffer
|
||||
@return true if the IRB marker is known and the buffer is big enough to check this;<BR>
|
||||
false otherwise
|
||||
*/
|
||||
static bool isIrb(const byte* pPsData, size_t sizePsData);
|
||||
/*!
|
||||
@brief Validates all IRBs
|
||||
|
||||
@param pPsData Existing IRB buffer
|
||||
@param sizePsData Size of the IRB buffer, may be 0
|
||||
@return true if all IRBs are valid;<BR>
|
||||
false otherwise
|
||||
*/
|
||||
static bool valid(const byte* pPsData, size_t sizePsData);
|
||||
/*!
|
||||
@brief Locates the data for a %Photoshop tag in a %Photoshop formated memory
|
||||
buffer. Operates on raw data to simplify reuse.
|
||||
@param pPsData Pointer to buffer containing entire payload of
|
||||
%Photoshop formated data, e.g., from APP13 Jpeg segment.
|
||||
@param sizePsData Size in bytes of pPsData.
|
||||
@param psTag %Tag number of the block to look for.
|
||||
@param record Output value that is set to the start of the
|
||||
data block within pPsData (may not be null).
|
||||
@param sizeHdr Output value that is set to the size of the header
|
||||
within the data block pointed to by record (may not be null).
|
||||
@param sizeData Output value that is set to the size of the actual
|
||||
data within the data block pointed to by record (may not be null).
|
||||
@return 0 if successful;<BR>
|
||||
3 if no data for psTag was found in pPsData;<BR>
|
||||
-2 if the pPsData buffer does not contain valid data.
|
||||
*/
|
||||
static int locateIrb(const byte *pPsData,
|
||||
size_t sizePsData,
|
||||
uint16_t psTag,
|
||||
const byte **record,
|
||||
uint32_t *const sizeHdr,
|
||||
uint32_t *const sizeData);
|
||||
/*!
|
||||
@brief Forwards to locateIrb() with \em psTag = \em iptc_
|
||||
*/
|
||||
static int locateIptcIrb(const byte *pPsData,
|
||||
size_t sizePsData,
|
||||
const byte **record,
|
||||
uint32_t *const sizeHdr,
|
||||
uint32_t *const sizeData);
|
||||
/*!
|
||||
@brief Forwards to locatePreviewIrb() with \em psTag = \em preview_
|
||||
*/
|
||||
static int locatePreviewIrb(const byte *pPsData,
|
||||
size_t sizePsData,
|
||||
const byte **record,
|
||||
uint32_t *const sizeHdr,
|
||||
uint32_t *const sizeData);
|
||||
/*!
|
||||
@brief Set the new IPTC IRB, keeps existing IRBs but removes the
|
||||
IPTC block if there is no new IPTC data to write.
|
||||
@param pPsData Existing IRB buffer
|
||||
@param sizePsData Size of the IRB buffer, may be 0
|
||||
@return true if all IRBs are valid;<BR>
|
||||
false otherwise
|
||||
*/
|
||||
static bool valid(const byte* pPsData, size_t sizePsData);
|
||||
/*!
|
||||
@brief Locates the data for a %Photoshop tag in a %Photoshop formated memory
|
||||
buffer. Operates on raw data to simplify reuse.
|
||||
@param pPsData Pointer to buffer containing entire payload of
|
||||
%Photoshop formated data, e.g., from APP13 Jpeg segment.
|
||||
@param sizePsData Size in bytes of pPsData.
|
||||
@param psTag %Tag number of the block to look for.
|
||||
@param record Output value that is set to the start of the
|
||||
data block within pPsData (may not be null).
|
||||
@param sizeHdr Output value that is set to the size of the header
|
||||
within the data block pointed to by record (may not be null).
|
||||
@param sizeData Output value that is set to the size of the actual
|
||||
data within the data block pointed to by record (may not be null).
|
||||
@return 0 if successful;<BR>
|
||||
3 if no data for psTag was found in pPsData;<BR>
|
||||
-2 if the pPsData buffer does not contain valid data.
|
||||
*/
|
||||
static int locateIrb(const byte* pPsData, size_t sizePsData, uint16_t psTag, const byte** record,
|
||||
uint32_t* const sizeHdr, uint32_t* const sizeData);
|
||||
/*!
|
||||
@brief Forwards to locateIrb() with \em psTag = \em iptc_
|
||||
*/
|
||||
static int locateIptcIrb(const byte* pPsData, size_t sizePsData, const byte** record, uint32_t* const sizeHdr,
|
||||
uint32_t* const sizeData);
|
||||
/*!
|
||||
@brief Forwards to locatePreviewIrb() with \em psTag = \em preview_
|
||||
*/
|
||||
static int locatePreviewIrb(const byte* pPsData, size_t sizePsData, const byte** record, uint32_t* const sizeHdr,
|
||||
uint32_t* const sizeData);
|
||||
/*!
|
||||
@brief Set the new IPTC IRB, keeps existing IRBs but removes the
|
||||
IPTC block if there is no new IPTC data to write.
|
||||
|
||||
@param pPsData Existing IRB buffer
|
||||
@param sizePsData Size of the IRB buffer, may be 0
|
||||
@param iptcData Iptc data to embed, may be empty
|
||||
@return A data buffer containing the new IRB buffer, may have 0 size
|
||||
*/
|
||||
static DataBuf setIptcIrb(const byte* pPsData, size_t sizePsData, const IptcData& iptcData);
|
||||
@param pPsData Existing IRB buffer
|
||||
@param sizePsData Size of the IRB buffer, may be 0
|
||||
@param iptcData Iptc data to embed, may be empty
|
||||
@return A data buffer containing the new IRB buffer, may have 0 size
|
||||
*/
|
||||
static DataBuf setIptcIrb(const byte* pPsData, size_t sizePsData, const IptcData& iptcData);
|
||||
|
||||
}; // class Photoshop
|
||||
}; // class Photoshop
|
||||
|
||||
/*!
|
||||
@brief Abstract helper base class to access JPEG images.
|
||||
*/
|
||||
class EXIV2API JpegBase : public Image {
|
||||
public:
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void readMetadata() override;
|
||||
void writeMetadata() override;
|
||||
void printStructure(std::ostream& out, PrintStructureOption option, int depth) override;
|
||||
//@}
|
||||
/*!
|
||||
@brief Abstract helper base class to access JPEG images.
|
||||
*/
|
||||
class EXIV2API JpegBase : public Image {
|
||||
public:
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void readMetadata() override;
|
||||
void writeMetadata() override;
|
||||
void printStructure(std::ostream& out, PrintStructureOption option, int depth) override;
|
||||
//@}
|
||||
|
||||
//! @name NOT implemented
|
||||
//@{
|
||||
//! Default constructor.
|
||||
JpegBase() = delete;
|
||||
//! Copy constructor
|
||||
JpegBase(const JpegBase& rhs) = delete;
|
||||
//! Assignment operator
|
||||
JpegBase& operator=(const JpegBase& rhs) = delete;
|
||||
//@}
|
||||
//! @name NOT implemented
|
||||
//@{
|
||||
//! Default constructor.
|
||||
JpegBase() = delete;
|
||||
//! Copy constructor
|
||||
JpegBase(const JpegBase& rhs) = delete;
|
||||
//! Assignment operator
|
||||
JpegBase& operator=(const JpegBase& rhs) = delete;
|
||||
//@}
|
||||
|
||||
protected:
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor that can either open an existing image or create
|
||||
a new image from scratch. If a new image is to be created, any
|
||||
existing data is overwritten.
|
||||
@param type Image type.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
@param create Specifies if an existing image should be read (false)
|
||||
or if a new image should be created (true).
|
||||
@param initData Data to initialize newly created images. Only used
|
||||
when \em create is true. Should contain data for the smallest
|
||||
valid image of the calling subclass.
|
||||
@param dataSize Size of initData in bytes.
|
||||
*/
|
||||
JpegBase(ImageType type,
|
||||
BasicIo::UniquePtr io,
|
||||
bool create,
|
||||
const byte initData[],
|
||||
size_t dataSize);
|
||||
//@}
|
||||
protected:
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor that can either open an existing image or create
|
||||
a new image from scratch. If a new image is to be created, any
|
||||
existing data is overwritten.
|
||||
@param type Image type.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
@param create Specifies if an existing image should be read (false)
|
||||
or if a new image should be created (true).
|
||||
@param initData Data to initialize newly created images. Only used
|
||||
when \em create is true. Should contain data for the smallest
|
||||
valid image of the calling subclass.
|
||||
@param dataSize Size of initData in bytes.
|
||||
*/
|
||||
JpegBase(ImageType type, BasicIo::UniquePtr io, bool create, const byte initData[], size_t dataSize);
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
/*!
|
||||
@brief Determine if the content of the BasicIo instance is of the
|
||||
type supported by this class.
|
||||
//! @name Accessors
|
||||
//@{
|
||||
/*!
|
||||
@brief Determine if the content of the BasicIo instance is of the
|
||||
type supported by this class.
|
||||
|
||||
The advance flag determines if the read position in the stream is
|
||||
moved (see below). This applies only if the type matches and the
|
||||
function returns true. If the type does not match, the stream
|
||||
position is not changed. However, if reading from the stream fails,
|
||||
the stream position is undefined. Consult the stream state to obtain
|
||||
more information in this case.
|
||||
The advance flag determines if the read position in the stream is
|
||||
moved (see below). This applies only if the type matches and the
|
||||
function returns true. If the type does not match, the stream
|
||||
position is not changed. However, if reading from the stream fails,
|
||||
the stream position is undefined. Consult the stream state to obtain
|
||||
more information in this case.
|
||||
|
||||
@param iIo BasicIo instance to read from.
|
||||
@param advance Flag indicating whether the position of the io
|
||||
should be advanced by the number of characters read to
|
||||
analyse the data (true) or left at its original
|
||||
position (false). This applies only if the type matches.
|
||||
@return true if the data matches the type of this class;<BR>
|
||||
false if the data does not match
|
||||
*/
|
||||
virtual bool isThisType(BasicIo& iIo, bool advance) const =0;
|
||||
//@}
|
||||
@param iIo BasicIo instance to read from.
|
||||
@param advance Flag indicating whether the position of the io
|
||||
should be advanced by the number of characters read to
|
||||
analyse the data (true) or left at its original
|
||||
position (false). This applies only if the type matches.
|
||||
@return true if the data matches the type of this class;<BR>
|
||||
false if the data does not match
|
||||
*/
|
||||
virtual bool isThisType(BasicIo& iIo, bool advance) const = 0;
|
||||
//@}
|
||||
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
/*!
|
||||
@brief Writes the image header (aka signature) to the BasicIo instance.
|
||||
@param oIo BasicIo instance that the header is written to.
|
||||
@return 0 if successful;<BR>
|
||||
4 if the output file can not be written to
|
||||
*/
|
||||
virtual int writeHeader(BasicIo& oIo) const =0;
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
/*!
|
||||
@brief Writes the image header (aka signature) to the BasicIo instance.
|
||||
@param oIo BasicIo instance that the header is written to.
|
||||
@return 0 if successful;<BR>
|
||||
4 if the output file can not be written to
|
||||
*/
|
||||
virtual int writeHeader(BasicIo& oIo) const = 0;
|
||||
//@}
|
||||
|
||||
// Constant Data
|
||||
static constexpr byte dht_ = 0xc4; //!< JPEG DHT marker
|
||||
static constexpr byte dqt_ = 0xdb; //!< JPEG DQT marker
|
||||
static constexpr byte dri_ = 0xdd; //!< JPEG DRI marker
|
||||
static constexpr byte sos_ = 0xda; //!< JPEG SOS marker
|
||||
static constexpr byte eoi_ = 0xd9; //!< JPEG EOI marker
|
||||
static constexpr byte app0_ = 0xe0; //!< JPEG APP0 marker
|
||||
static constexpr byte app1_ = 0xe1; //!< JPEG APP1 marker
|
||||
static constexpr byte app2_ = 0xe2; //!< JPEG APP2 marker
|
||||
static constexpr byte app13_ = 0xed; //!< JPEG APP13 marker
|
||||
static constexpr byte com_ = 0xfe; //!< JPEG Comment marker
|
||||
// Constant Data
|
||||
static constexpr byte dht_ = 0xc4; //!< JPEG DHT marker
|
||||
static constexpr byte dqt_ = 0xdb; //!< JPEG DQT marker
|
||||
static constexpr byte dri_ = 0xdd; //!< JPEG DRI marker
|
||||
static constexpr byte sos_ = 0xda; //!< JPEG SOS marker
|
||||
static constexpr byte eoi_ = 0xd9; //!< JPEG EOI marker
|
||||
static constexpr byte app0_ = 0xe0; //!< JPEG APP0 marker
|
||||
static constexpr byte app1_ = 0xe1; //!< JPEG APP1 marker
|
||||
static constexpr byte app2_ = 0xe2; //!< JPEG APP2 marker
|
||||
static constexpr byte app13_ = 0xed; //!< JPEG APP13 marker
|
||||
static constexpr byte com_ = 0xfe; //!< JPEG Comment marker
|
||||
|
||||
// Start of Frame markers, nondifferential Huffman-coding frames
|
||||
static constexpr byte sof0_ = 0xc0; //!< JPEG Start-Of-Frame marker
|
||||
static constexpr byte sof1_ = 0xc1; //!< JPEG Start-Of-Frame marker
|
||||
static constexpr byte sof2_ = 0xc2; //!< JPEG Start-Of-Frame marker
|
||||
static constexpr byte sof3_ = 0xc3; //!< JPEG Start-Of-Frame marker
|
||||
// Start of Frame markers, nondifferential Huffman-coding frames
|
||||
static constexpr byte sof0_ = 0xc0; //!< JPEG Start-Of-Frame marker
|
||||
static constexpr byte sof1_ = 0xc1; //!< JPEG Start-Of-Frame marker
|
||||
static constexpr byte sof2_ = 0xc2; //!< JPEG Start-Of-Frame marker
|
||||
static constexpr byte sof3_ = 0xc3; //!< JPEG Start-Of-Frame marker
|
||||
|
||||
// Start of Frame markers, differential Huffman-coding frames
|
||||
static constexpr byte sof5_ = 0xc5; //!< JPEG Start-Of-Frame marker
|
||||
static constexpr byte sof6_ = 0xc6; //!< JPEG Start-Of-Frame marker
|
||||
static constexpr byte sof7_ = 0xc7; //!< JPEG Start-Of-Frame marker
|
||||
// Start of Frame markers, differential Huffman-coding frames
|
||||
static constexpr byte sof5_ = 0xc5; //!< JPEG Start-Of-Frame marker
|
||||
static constexpr byte sof6_ = 0xc6; //!< JPEG Start-Of-Frame marker
|
||||
static constexpr byte sof7_ = 0xc7; //!< JPEG Start-Of-Frame marker
|
||||
|
||||
// Start of Frame markers, nondifferential arithmetic-coding frames
|
||||
static constexpr byte sof9_ = 0xc9; //!< JPEG Start-Of-Frame marker
|
||||
static constexpr byte sof10_ = 0xca; //!< JPEG Start-Of-Frame marker
|
||||
static constexpr byte sof11_ = 0xcb; //!< JPEG Start-Of-Frame marker
|
||||
// Start of Frame markers, nondifferential arithmetic-coding frames
|
||||
static constexpr byte sof9_ = 0xc9; //!< JPEG Start-Of-Frame marker
|
||||
static constexpr byte sof10_ = 0xca; //!< JPEG Start-Of-Frame marker
|
||||
static constexpr byte sof11_ = 0xcb; //!< JPEG Start-Of-Frame marker
|
||||
|
||||
// Start of Frame markers, differential arithmetic-coding frames
|
||||
static constexpr byte sof13_ = 0xcd; //!< JPEG Start-Of-Frame marker
|
||||
static constexpr byte sof14_ = 0xce; //!< JPEG Start-Of-Frame marker
|
||||
static constexpr byte sof15_ = 0xcf; //!< JPEG Start-Of-Frame marker
|
||||
// Start of Frame markers, differential arithmetic-coding frames
|
||||
static constexpr byte sof13_ = 0xcd; //!< JPEG Start-Of-Frame marker
|
||||
static constexpr byte sof14_ = 0xce; //!< JPEG Start-Of-Frame marker
|
||||
static constexpr byte sof15_ = 0xcf; //!< JPEG Start-Of-Frame marker
|
||||
|
||||
static constexpr auto exifId_ = "Exif\0\0"; //!< Exif identifier
|
||||
static constexpr auto jfifId_ = "JFIF\0"; //!< JFIF identifier
|
||||
static constexpr auto xmpId_ = "http://ns.adobe.com/xap/1.0/\0"; //!< XMP packet identifier
|
||||
static constexpr auto iccId_ = "ICC_PROFILE\0"; //!< ICC profile identifier
|
||||
static constexpr auto exifId_ = "Exif\0\0"; //!< Exif identifier
|
||||
static constexpr auto jfifId_ = "JFIF\0"; //!< JFIF identifier
|
||||
static constexpr auto xmpId_ = "http://ns.adobe.com/xap/1.0/\0"; //!< XMP packet identifier
|
||||
static constexpr auto iccId_ = "ICC_PROFILE\0"; //!< ICC profile identifier
|
||||
|
||||
private:
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
/*!
|
||||
@brief Initialize the image with the provided data.
|
||||
@param initData Data to be written to the associated BasicIo
|
||||
@param dataSize Size in bytes of data to be written
|
||||
@return 0 if successful;<BR>
|
||||
4 if the image can not be written to.
|
||||
*/
|
||||
int initImage(const byte initData[], size_t dataSize);
|
||||
/*!
|
||||
@brief Provides the main implementation of writeMetadata() by
|
||||
writing all buffered metadata to the provided BasicIo.
|
||||
@param oIo BasicIo instance to write to (a temporary location).
|
||||
private:
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
/*!
|
||||
@brief Initialize the image with the provided data.
|
||||
@param initData Data to be written to the associated BasicIo
|
||||
@param dataSize Size in bytes of data to be written
|
||||
@return 0 if successful;<BR>
|
||||
4 if the image can not be written to.
|
||||
*/
|
||||
int initImage(const byte initData[], size_t dataSize);
|
||||
/*!
|
||||
@brief Provides the main implementation of writeMetadata() by
|
||||
writing all buffered metadata to the provided BasicIo.
|
||||
@param oIo BasicIo instance to write to (a temporary location).
|
||||
|
||||
@return 4 if opening or writing to the associated BasicIo fails
|
||||
*/
|
||||
void doWriteMetadata(BasicIo& outIo);
|
||||
//@}
|
||||
@return 4 if opening or writing to the associated BasicIo fails
|
||||
*/
|
||||
void doWriteMetadata(BasicIo& outIo);
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
/*!
|
||||
@brief Advances associated io instance to one byte past the next
|
||||
Jpeg marker and returns the marker. This method should be called
|
||||
when the BasicIo instance is positioned one byte past the end of a
|
||||
Jpeg segment.
|
||||
@param err the error code to throw if no marker is found
|
||||
@return the next Jpeg segment marker if successful;<BR>
|
||||
throws an Error if not successful
|
||||
*/
|
||||
byte advanceToMarker(ErrorCode err) const;
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
/*!
|
||||
@brief Advances associated io instance to one byte past the next
|
||||
Jpeg marker and returns the marker. This method should be called
|
||||
when the BasicIo instance is positioned one byte past the end of a
|
||||
Jpeg segment.
|
||||
@param err the error code to throw if no marker is found
|
||||
@return the next Jpeg segment marker if successful;<BR>
|
||||
throws an Error if not successful
|
||||
*/
|
||||
byte advanceToMarker(ErrorCode err) const;
|
||||
//@}
|
||||
|
||||
DataBuf readNextSegment(byte marker);
|
||||
DataBuf readNextSegment(byte marker);
|
||||
|
||||
/*!
|
||||
@brief Is the marker followed by a non-zero payload?
|
||||
@param marker The marker at the start of a segment
|
||||
@return true if the marker is followed by a non-zero payload
|
||||
*/
|
||||
static bool markerHasLength(byte marker);
|
||||
}; // class JpegBase
|
||||
/*!
|
||||
@brief Is the marker followed by a non-zero payload?
|
||||
@param marker The marker at the start of a segment
|
||||
@return true if the marker is followed by a non-zero payload
|
||||
*/
|
||||
static bool markerHasLength(byte marker);
|
||||
}; // class JpegBase
|
||||
|
||||
/*!
|
||||
@brief Class to access JPEG images
|
||||
*/
|
||||
class EXIV2API JpegImage : public JpegBase {
|
||||
friend EXIV2API bool isJpegType(BasicIo& iIo, bool advance);
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor that can either open an existing Jpeg image or create
|
||||
a new image from scratch. If a new image is to be created, any
|
||||
existing data is overwritten. Since the constructor can not return
|
||||
a result, callers should check the good() method after object
|
||||
construction to determine success or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
@param create Specifies if an existing image should be read (false)
|
||||
or if a new file should be created (true).
|
||||
*/
|
||||
JpegImage(BasicIo::UniquePtr io, bool create);
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override;
|
||||
//@}
|
||||
/*!
|
||||
@brief Class to access JPEG images
|
||||
*/
|
||||
class EXIV2API JpegImage : public JpegBase {
|
||||
friend EXIV2API bool isJpegType(BasicIo& iIo, bool advance);
|
||||
|
||||
// NOT Implemented
|
||||
//! Default constructor
|
||||
JpegImage() = delete;
|
||||
//! Copy constructor
|
||||
JpegImage(const JpegImage& rhs) = delete;
|
||||
//! Assignment operator
|
||||
JpegImage& operator=(const JpegImage& rhs) = delete;
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor that can either open an existing Jpeg image or create
|
||||
a new image from scratch. If a new image is to be created, any
|
||||
existing data is overwritten. Since the constructor can not return
|
||||
a result, callers should check the good() method after object
|
||||
construction to determine success or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
@param create Specifies if an existing image should be read (false)
|
||||
or if a new file should be created (true).
|
||||
*/
|
||||
JpegImage(BasicIo::UniquePtr io, bool create);
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override;
|
||||
//@}
|
||||
|
||||
protected:
|
||||
//! @name Accessors
|
||||
//@{
|
||||
bool isThisType(BasicIo& iIo, bool advance) const override;
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
/*!
|
||||
@brief Writes a Jpeg header (aka signature) to the BasicIo instance.
|
||||
@param oIo BasicIo instance that the header is written to.
|
||||
@return 0 if successful;<BR>
|
||||
2 if the input image is invalid or can not be read;<BR>
|
||||
4 if the temporary image can not be written to;<BR>
|
||||
-3 other temporary errors
|
||||
*/
|
||||
int writeHeader(BasicIo& outIo) const override;
|
||||
//@}
|
||||
// NOT Implemented
|
||||
//! Default constructor
|
||||
JpegImage() = delete;
|
||||
//! Copy constructor
|
||||
JpegImage(const JpegImage& rhs) = delete;
|
||||
//! Assignment operator
|
||||
JpegImage& operator=(const JpegImage& rhs) = delete;
|
||||
|
||||
private:
|
||||
// Constant data
|
||||
static const byte soi_; // SOI marker
|
||||
static const byte blank_[]; // Minimal Jpeg image
|
||||
}; // class JpegImage
|
||||
protected:
|
||||
//! @name Accessors
|
||||
//@{
|
||||
bool isThisType(BasicIo& iIo, bool advance) const override;
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
/*!
|
||||
@brief Writes a Jpeg header (aka signature) to the BasicIo instance.
|
||||
@param oIo BasicIo instance that the header is written to.
|
||||
@return 0 if successful;<BR>
|
||||
2 if the input image is invalid or can not be read;<BR>
|
||||
4 if the temporary image can not be written to;<BR>
|
||||
-3 other temporary errors
|
||||
*/
|
||||
int writeHeader(BasicIo& outIo) const override;
|
||||
//@}
|
||||
|
||||
//! Helper class to access %Exiv2 files
|
||||
class EXIV2API ExvImage : public JpegBase {
|
||||
friend EXIV2API bool isExvType(BasicIo& iIo, bool advance);
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor that can either open an existing EXV image or create
|
||||
a new image from scratch. If a new image is to be created, any
|
||||
existing data is overwritten. Since the constructor can not return
|
||||
a result, callers should check the good() method after object
|
||||
construction to determine success or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
@param create Specifies if an existing image should be read (false)
|
||||
or if a new file should be created (true).
|
||||
*/
|
||||
ExvImage(BasicIo::UniquePtr io, bool create);
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override;
|
||||
//@}
|
||||
private:
|
||||
// Constant data
|
||||
static const byte soi_; // SOI marker
|
||||
static const byte blank_[]; // Minimal Jpeg image
|
||||
}; // class JpegImage
|
||||
|
||||
// NOT Implemented
|
||||
//! Default constructor
|
||||
ExvImage() = delete;
|
||||
//! Copy constructor
|
||||
ExvImage(const ExvImage& rhs) = delete;
|
||||
//! Assignment operator
|
||||
ExvImage& operator=(const ExvImage& rhs) = delete;
|
||||
//! Helper class to access %Exiv2 files
|
||||
class EXIV2API ExvImage : public JpegBase {
|
||||
friend EXIV2API bool isExvType(BasicIo& iIo, bool advance);
|
||||
|
||||
protected:
|
||||
//! @name Accessors
|
||||
//@{
|
||||
bool isThisType(BasicIo& iIo, bool advance) const override;
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
int writeHeader(BasicIo& outIo) const override;
|
||||
//@}
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor that can either open an existing EXV image or create
|
||||
a new image from scratch. If a new image is to be created, any
|
||||
existing data is overwritten. Since the constructor can not return
|
||||
a result, callers should check the good() method after object
|
||||
construction to determine success or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
@param create Specifies if an existing image should be read (false)
|
||||
or if a new file should be created (true).
|
||||
*/
|
||||
ExvImage(BasicIo::UniquePtr io, bool create);
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override;
|
||||
//@}
|
||||
|
||||
private:
|
||||
// Constant data
|
||||
static constexpr char exiv2Id_[] = "Exiv2"; // EXV identifier
|
||||
static constexpr byte blank_[] = {0xff, 0x01, 'E', 'x', 'i', 'v', '2', 0xff, 0xd9}; // Minimal exiv2 file
|
||||
// NOT Implemented
|
||||
//! Default constructor
|
||||
ExvImage() = delete;
|
||||
//! Copy constructor
|
||||
ExvImage(const ExvImage& rhs) = delete;
|
||||
//! Assignment operator
|
||||
ExvImage& operator=(const ExvImage& rhs) = delete;
|
||||
|
||||
}; // class ExvImage
|
||||
protected:
|
||||
//! @name Accessors
|
||||
//@{
|
||||
bool isThisType(BasicIo& iIo, bool advance) const override;
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
int writeHeader(BasicIo& outIo) const override;
|
||||
//@}
|
||||
|
||||
private:
|
||||
// Constant data
|
||||
static constexpr char exiv2Id_[] = "Exiv2"; // EXV identifier
|
||||
static constexpr byte blank_[] = {0xff, 0x01, 'E', 'x', 'i', 'v', '2', 0xff, 0xd9}; // Minimal exiv2 file
|
||||
|
||||
}; // class ExvImage
|
||||
|
||||
// *****************************************************************************
|
||||
// template, inline and free functions
|
||||
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new JpegImage instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newJpegInstance(BasicIo::UniquePtr io, bool create);
|
||||
//! Check if the file iIo is a JPEG image.
|
||||
EXIV2API bool isJpegType(BasicIo& iIo, bool advance);
|
||||
/*!
|
||||
@brief Create a new ExvImage instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newExvInstance(BasicIo::UniquePtr io, bool create);
|
||||
//! Check if the file iIo is an EXV file
|
||||
EXIV2API bool isExvType(BasicIo& iIo, bool advance);
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new JpegImage instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newJpegInstance(BasicIo::UniquePtr io, bool create);
|
||||
//! Check if the file iIo is a JPEG image.
|
||||
EXIV2API bool isJpegType(BasicIo& iIo, bool advance);
|
||||
/*!
|
||||
@brief Create a new ExvImage instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newExvInstance(BasicIo::UniquePtr io, bool create);
|
||||
//! Check if the file iIo is an EXV file
|
||||
EXIV2API bool isExvType(BasicIo& iIo, bool advance);
|
||||
|
||||
} // namespace Exiv2
|
||||
} // namespace Exiv2
|
||||
|
||||
#endif // #ifndef JPGIMAGE_HPP_
|
||||
#endif // #ifndef JPGIMAGE_HPP_
|
||||
|
||||
+242
-243
@@ -12,278 +12,277 @@
|
||||
// *****************************************************************************
|
||||
// namespace extensions
|
||||
namespace Exiv2 {
|
||||
|
||||
// *****************************************************************************
|
||||
// class declarations
|
||||
class ExifData;
|
||||
class ExifData;
|
||||
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
|
||||
/*!
|
||||
@brief Abstract base class defining the %Key of a metadatum.
|
||||
Keys are used to identify and group metadata.
|
||||
*/
|
||||
class EXIV2API Key {
|
||||
public:
|
||||
//! Shortcut for a %Key auto pointer.
|
||||
using UniquePtr = std::unique_ptr<Key>;
|
||||
/*!
|
||||
@brief Abstract base class defining the %Key of a metadatum.
|
||||
Keys are used to identify and group metadata.
|
||||
*/
|
||||
class EXIV2API Key {
|
||||
public:
|
||||
//! Shortcut for a %Key auto pointer.
|
||||
using UniquePtr = std::unique_ptr<Key>;
|
||||
|
||||
//! @name Creators
|
||||
//@{
|
||||
//! Destructor
|
||||
virtual ~Key() = default;
|
||||
//@}
|
||||
//! @name Creators
|
||||
//@{
|
||||
//! Destructor
|
||||
virtual ~Key() = default;
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
/*!
|
||||
@brief Return the key of the metadatum as a string. The key is of the
|
||||
form 'familyName.groupName.tagName'. Note however that the
|
||||
key is not necessarily unique, e.g., an ExifData may contain
|
||||
multiple metadata with the same key.
|
||||
*/
|
||||
virtual std::string key() const =0;
|
||||
//! Return an identifier for the type of metadata (the first part of the key)
|
||||
virtual const char* familyName() const =0;
|
||||
//! Return the name of the group (the second part of the key)
|
||||
virtual std::string groupName() const =0;
|
||||
//! Return the name of the tag (which is also the third part of the key)
|
||||
virtual std::string tagName() const =0;
|
||||
//! Return a label for the tag
|
||||
virtual std::string tagLabel() const =0;
|
||||
//! Return the tag number
|
||||
virtual uint16_t tag() const =0;
|
||||
/*!
|
||||
@brief Return an auto-pointer to a copy of itself (deep copy).
|
||||
The caller owns this copy and the auto-pointer ensures that it
|
||||
will be deleted.
|
||||
*/
|
||||
UniquePtr clone() const;
|
||||
/*!
|
||||
@brief Write the key to an output stream. You do not usually have
|
||||
to use this function; it is used for the implementation of
|
||||
the output operator for %Key,
|
||||
operator<<(std::ostream &os, const Key &key).
|
||||
*/
|
||||
std::ostream& write(std::ostream& os) const { return os << key(); }
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
/*!
|
||||
@brief Return the key of the metadatum as a string. The key is of the
|
||||
form 'familyName.groupName.tagName'. Note however that the
|
||||
key is not necessarily unique, e.g., an ExifData may contain
|
||||
multiple metadata with the same key.
|
||||
*/
|
||||
virtual std::string key() const = 0;
|
||||
//! Return an identifier for the type of metadata (the first part of the key)
|
||||
virtual const char* familyName() const = 0;
|
||||
//! Return the name of the group (the second part of the key)
|
||||
virtual std::string groupName() const = 0;
|
||||
//! Return the name of the tag (which is also the third part of the key)
|
||||
virtual std::string tagName() const = 0;
|
||||
//! Return a label for the tag
|
||||
virtual std::string tagLabel() const = 0;
|
||||
//! Return the tag number
|
||||
virtual uint16_t tag() const = 0;
|
||||
/*!
|
||||
@brief Return an auto-pointer to a copy of itself (deep copy).
|
||||
The caller owns this copy and the auto-pointer ensures that it
|
||||
will be deleted.
|
||||
*/
|
||||
UniquePtr clone() const;
|
||||
/*!
|
||||
@brief Write the key to an output stream. You do not usually have
|
||||
to use this function; it is used for the implementation of
|
||||
the output operator for %Key,
|
||||
operator<<(std::ostream &os, const Key &key).
|
||||
*/
|
||||
std::ostream& write(std::ostream& os) const {
|
||||
return os << key();
|
||||
}
|
||||
//@}
|
||||
|
||||
protected:
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
/*!
|
||||
@brief Assignment operator. Protected so that it can only be used
|
||||
by subclasses but not directly.
|
||||
*/
|
||||
Key& operator=(const Key& rhs) = default;
|
||||
//@}
|
||||
protected:
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
/*!
|
||||
@brief Assignment operator. Protected so that it can only be used
|
||||
by subclasses but not directly.
|
||||
*/
|
||||
Key& operator=(const Key& rhs) = default;
|
||||
//@}
|
||||
|
||||
private:
|
||||
//! Internal virtual copy constructor.
|
||||
virtual Key* clone_() const =0;
|
||||
private:
|
||||
//! Internal virtual copy constructor.
|
||||
virtual Key* clone_() const = 0;
|
||||
|
||||
}; // class Key
|
||||
}; // class Key
|
||||
|
||||
//! Output operator for Key types
|
||||
inline std::ostream& operator<<(std::ostream& os, const Key& key)
|
||||
{
|
||||
return key.write(os);
|
||||
}
|
||||
//! Output operator for Key types
|
||||
inline std::ostream& operator<<(std::ostream& os, const Key& key) {
|
||||
return key.write(os);
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief Abstract base class defining the interface to access information
|
||||
related to one metadata tag.
|
||||
*/
|
||||
class EXIV2API Metadatum {
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
//! Default Constructor
|
||||
Metadatum() = default;
|
||||
//! Copy constructor
|
||||
Metadatum(const Metadatum& rhs) = default;
|
||||
//! Destructor
|
||||
virtual ~Metadatum() = default;
|
||||
//@}
|
||||
/*!
|
||||
@brief Abstract base class defining the interface to access information
|
||||
related to one metadata tag.
|
||||
*/
|
||||
class EXIV2API Metadatum {
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
//! Default Constructor
|
||||
Metadatum() = default;
|
||||
//! Copy constructor
|
||||
Metadatum(const Metadatum& rhs) = default;
|
||||
//! Destructor
|
||||
virtual ~Metadatum() = default;
|
||||
//@}
|
||||
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
/*!
|
||||
@brief Set the value. This method copies (clones) the value pointed
|
||||
to by pValue.
|
||||
*/
|
||||
virtual void setValue(const Value* pValue) =0;
|
||||
/*!
|
||||
@brief Set the value to the string buf.
|
||||
Uses Value::read(const std::string& buf). If the metadatum does
|
||||
not have a value yet, then one is created. See subclasses for
|
||||
more details. Return 0 if the value was read successfully.
|
||||
*/
|
||||
virtual int setValue(const std::string& buf) =0;
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
/*!
|
||||
@brief Set the value. This method copies (clones) the value pointed
|
||||
to by pValue.
|
||||
*/
|
||||
virtual void setValue(const Value* pValue) = 0;
|
||||
/*!
|
||||
@brief Set the value to the string buf.
|
||||
Uses Value::read(const std::string& buf). If the metadatum does
|
||||
not have a value yet, then one is created. See subclasses for
|
||||
more details. Return 0 if the value was read successfully.
|
||||
*/
|
||||
virtual int setValue(const std::string& buf) = 0;
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
/*!
|
||||
@brief Write the interpreted value to a string.
|
||||
//! @name Accessors
|
||||
//@{
|
||||
/*!
|
||||
@brief Write the interpreted value to a string.
|
||||
|
||||
Implemented in terms of write(), see there.
|
||||
*/
|
||||
std::string print(const ExifData* pMetadata = nullptr) const;
|
||||
/*!
|
||||
@brief Write value to a data buffer and return the number
|
||||
of bytes written.
|
||||
Implemented in terms of write(), see there.
|
||||
*/
|
||||
std::string print(const ExifData* pMetadata = nullptr) const;
|
||||
/*!
|
||||
@brief Write value to a data buffer and return the number
|
||||
of bytes written.
|
||||
|
||||
The user must ensure that the buffer has enough memory. Otherwise
|
||||
the call results in undefined behaviour.
|
||||
The user must ensure that the buffer has enough memory. Otherwise
|
||||
the call results in undefined behaviour.
|
||||
|
||||
@param buf Data buffer to write to.
|
||||
@param byteOrder Applicable byte order (little or big endian).
|
||||
@return Number of characters written.
|
||||
*/
|
||||
virtual size_t copy(byte* buf, ByteOrder byteOrder) const =0;
|
||||
/*!
|
||||
@brief Write the interpreted value to an output stream, return
|
||||
the stream.
|
||||
@param buf Data buffer to write to.
|
||||
@param byteOrder Applicable byte order (little or big endian).
|
||||
@return Number of characters written.
|
||||
*/
|
||||
virtual size_t copy(byte* buf, ByteOrder byteOrder) const = 0;
|
||||
/*!
|
||||
@brief Write the interpreted value to an output stream, return
|
||||
the stream.
|
||||
|
||||
The method takes an optional pointer to a metadata container.
|
||||
Pretty-print functions may use that to refer to other metadata as it
|
||||
is sometimes not sufficient to know only the value of the metadatum
|
||||
that should be interpreted. Thus, it is advisable to always call this
|
||||
method with a pointer to the metadata container if possible.
|
||||
The method takes an optional pointer to a metadata container.
|
||||
Pretty-print functions may use that to refer to other metadata as it
|
||||
is sometimes not sufficient to know only the value of the metadatum
|
||||
that should be interpreted. Thus, it is advisable to always call this
|
||||
method with a pointer to the metadata container if possible.
|
||||
|
||||
This functionality is currently only implemented for Exif tags.
|
||||
The pointer is ignored when used to write IPTC datasets or XMP
|
||||
properties.
|
||||
This functionality is currently only implemented for Exif tags.
|
||||
The pointer is ignored when used to write IPTC datasets or XMP
|
||||
properties.
|
||||
|
||||
Without the optional metadata pointer, you do not usually have to use
|
||||
this function; it is used for the implementation of the output
|
||||
operator for %Metadatum,
|
||||
operator<<(std::ostream &os, const Metadatum &md).
|
||||
Without the optional metadata pointer, you do not usually have to use
|
||||
this function; it is used for the implementation of the output
|
||||
operator for %Metadatum,
|
||||
operator<<(std::ostream &os, const Metadatum &md).
|
||||
|
||||
See also print(), which prints the interpreted value to a string.
|
||||
*/
|
||||
virtual std::ostream& write(std::ostream& os, const ExifData* pMetadata = nullptr) const = 0;
|
||||
/*!
|
||||
@brief Return the key of the metadatum. The key is of the form
|
||||
'familyName.groupName.tagName'. Note however that the key
|
||||
is not necessarily unique, e.g., an ExifData object may
|
||||
contain multiple metadata with the same key.
|
||||
*/
|
||||
virtual std::string key() const =0;
|
||||
//! Return the name of the metadata family (which is also the first part of the key)
|
||||
virtual const char* familyName() const =0;
|
||||
//! Return the name of the metadata group (which is also the second part of the key)
|
||||
virtual std::string groupName() const =0;
|
||||
//! Return the name of the tag (which is also the third part of the key)
|
||||
virtual std::string tagName() const =0;
|
||||
//! Return a label for the tag
|
||||
virtual std::string tagLabel() const =0;
|
||||
//! Return the tag
|
||||
virtual uint16_t tag() const =0;
|
||||
//! Return the type id of the value
|
||||
virtual TypeId typeId() const =0;
|
||||
//! Return the name of the type
|
||||
virtual const char* typeName() const =0;
|
||||
//! Return the size in bytes of one component of this type
|
||||
virtual size_t typeSize() const =0;
|
||||
//! Return the number of components in the value
|
||||
virtual size_t count() const =0;
|
||||
//! Return the size of the value in bytes
|
||||
virtual size_t size() const =0;
|
||||
//! Return the value as a string.
|
||||
virtual std::string toString() const =0;
|
||||
/*!
|
||||
@brief Return the <EM>n</EM>-th component of the value converted to
|
||||
a string. The behaviour of the method is undefined if there
|
||||
is no <EM>n</EM>-th component.
|
||||
*/
|
||||
virtual std::string toString(size_t n) const =0;
|
||||
/*!
|
||||
@brief Return the <EM>n</EM>-th component of the value converted to int64_t.
|
||||
The return value is -1 if the value is not set and the behaviour
|
||||
of the method is undefined if there is no <EM>n</EM>-th component.
|
||||
*/
|
||||
virtual int64_t toInt64(size_t n =0) const =0;
|
||||
/*!
|
||||
@brief Return the <EM>n</EM>-th component of the value converted to uint32_t.
|
||||
*/
|
||||
uint32_t toUint32(size_t n =0) const;
|
||||
/*!
|
||||
@brief Return the <EM>n</EM>-th component of the value converted to float.
|
||||
The return value is -1 if the value is not set and the behaviour
|
||||
of the method is undefined if there is no <EM>n</EM>-th component.
|
||||
*/
|
||||
virtual float toFloat(size_t n =0) const =0;
|
||||
/*!
|
||||
@brief Return the <EM>n</EM>-th component of the value converted to Rational.
|
||||
The return value is -1/1 if the value is not set and the behaviour
|
||||
of the method is undefined if there is no <EM>n</EM>-th component.
|
||||
*/
|
||||
virtual Rational toRational(size_t n =0) const =0;
|
||||
/*!
|
||||
@brief Return an auto-pointer to a copy (clone) of the value. The
|
||||
caller owns this copy and the auto-poiner ensures that it will
|
||||
be deleted.
|
||||
See also print(), which prints the interpreted value to a string.
|
||||
*/
|
||||
virtual std::ostream& write(std::ostream& os, const ExifData* pMetadata = nullptr) const = 0;
|
||||
/*!
|
||||
@brief Return the key of the metadatum. The key is of the form
|
||||
'familyName.groupName.tagName'. Note however that the key
|
||||
is not necessarily unique, e.g., an ExifData object may
|
||||
contain multiple metadata with the same key.
|
||||
*/
|
||||
virtual std::string key() const = 0;
|
||||
//! Return the name of the metadata family (which is also the first part of the key)
|
||||
virtual const char* familyName() const = 0;
|
||||
//! Return the name of the metadata group (which is also the second part of the key)
|
||||
virtual std::string groupName() const = 0;
|
||||
//! Return the name of the tag (which is also the third part of the key)
|
||||
virtual std::string tagName() const = 0;
|
||||
//! Return a label for the tag
|
||||
virtual std::string tagLabel() const = 0;
|
||||
//! Return the tag
|
||||
virtual uint16_t tag() const = 0;
|
||||
//! Return the type id of the value
|
||||
virtual TypeId typeId() const = 0;
|
||||
//! Return the name of the type
|
||||
virtual const char* typeName() const = 0;
|
||||
//! Return the size in bytes of one component of this type
|
||||
virtual size_t typeSize() const = 0;
|
||||
//! Return the number of components in the value
|
||||
virtual size_t count() const = 0;
|
||||
//! Return the size of the value in bytes
|
||||
virtual size_t size() const = 0;
|
||||
//! Return the value as a string.
|
||||
virtual std::string toString() const = 0;
|
||||
/*!
|
||||
@brief Return the <EM>n</EM>-th component of the value converted to
|
||||
a string. The behaviour of the method is undefined if there
|
||||
is no <EM>n</EM>-th component.
|
||||
*/
|
||||
virtual std::string toString(size_t n) const = 0;
|
||||
/*!
|
||||
@brief Return the <EM>n</EM>-th component of the value converted to int64_t.
|
||||
The return value is -1 if the value is not set and the behaviour
|
||||
of the method is undefined if there is no <EM>n</EM>-th component.
|
||||
*/
|
||||
virtual int64_t toInt64(size_t n = 0) const = 0;
|
||||
/*!
|
||||
@brief Return the <EM>n</EM>-th component of the value converted to uint32_t.
|
||||
*/
|
||||
uint32_t toUint32(size_t n = 0) const;
|
||||
/*!
|
||||
@brief Return the <EM>n</EM>-th component of the value converted to float.
|
||||
The return value is -1 if the value is not set and the behaviour
|
||||
of the method is undefined if there is no <EM>n</EM>-th component.
|
||||
*/
|
||||
virtual float toFloat(size_t n = 0) const = 0;
|
||||
/*!
|
||||
@brief Return the <EM>n</EM>-th component of the value converted to Rational.
|
||||
The return value is -1/1 if the value is not set and the behaviour
|
||||
of the method is undefined if there is no <EM>n</EM>-th component.
|
||||
*/
|
||||
virtual Rational toRational(size_t n = 0) const = 0;
|
||||
/*!
|
||||
@brief Return an auto-pointer to a copy (clone) of the value. The
|
||||
caller owns this copy and the auto-poiner ensures that it will
|
||||
be deleted.
|
||||
|
||||
This method is provided for users who need full control over the
|
||||
value. A caller may, e.g., downcast the pointer to the appropriate
|
||||
subclass of Value to make use of the interface of the subclass to set
|
||||
or modify its contents.
|
||||
This method is provided for users who need full control over the
|
||||
value. A caller may, e.g., downcast the pointer to the appropriate
|
||||
subclass of Value to make use of the interface of the subclass to set
|
||||
or modify its contents.
|
||||
|
||||
@return An auto-pointer containing a pointer to a copy (clone) of the
|
||||
value, 0 if the value is not set.
|
||||
*/
|
||||
virtual Value::UniquePtr getValue() const =0;
|
||||
/*!
|
||||
@brief Return a constant reference to the value.
|
||||
@return An auto-pointer containing a pointer to a copy (clone) of the
|
||||
value, 0 if the value is not set.
|
||||
*/
|
||||
virtual Value::UniquePtr getValue() const = 0;
|
||||
/*!
|
||||
@brief Return a constant reference to the value.
|
||||
|
||||
This method is provided mostly for convenient and versatile output of
|
||||
the value which can (to some extent) be formatted through standard
|
||||
stream manipulators. Do not attempt to write to the value through
|
||||
this reference. An Error is thrown if the value is not set; as an
|
||||
alternative to catching it, one can use count() to check if there
|
||||
is any data before calling this method.
|
||||
This method is provided mostly for convenient and versatile output of
|
||||
the value which can (to some extent) be formatted through standard
|
||||
stream manipulators. Do not attempt to write to the value through
|
||||
this reference. An Error is thrown if the value is not set; as an
|
||||
alternative to catching it, one can use count() to check if there
|
||||
is any data before calling this method.
|
||||
|
||||
@return A constant reference to the value.
|
||||
@throw Error if the value is not set.
|
||||
*/
|
||||
virtual const Value& value() const =0;
|
||||
//@}
|
||||
@return A constant reference to the value.
|
||||
@throw Error if the value is not set.
|
||||
*/
|
||||
virtual const Value& value() const = 0;
|
||||
//@}
|
||||
|
||||
protected:
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
/*!
|
||||
@brief Assignment operator. Protected so that it can only be used
|
||||
by subclasses but not directly.
|
||||
*/
|
||||
Metadatum& operator=(const Metadatum& rhs) = default;
|
||||
//@}
|
||||
protected:
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
/*!
|
||||
@brief Assignment operator. Protected so that it can only be used
|
||||
by subclasses but not directly.
|
||||
*/
|
||||
Metadatum& operator=(const Metadatum& rhs) = default;
|
||||
//@}
|
||||
|
||||
}; // class Metadatum
|
||||
}; // class Metadatum
|
||||
|
||||
/*!
|
||||
@brief Output operator for Metadatum types, writing the interpreted
|
||||
tag value.
|
||||
*/
|
||||
inline std::ostream& operator<<(std::ostream& os, const Metadatum& md)
|
||||
{
|
||||
return md.write(os);
|
||||
}
|
||||
/*!
|
||||
@brief Output operator for Metadatum types, writing the interpreted
|
||||
tag value.
|
||||
*/
|
||||
inline std::ostream& operator<<(std::ostream& os, const Metadatum& md) {
|
||||
return md.write(os);
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief Compare two metadata by tag. Return true if the tag of metadatum
|
||||
lhs is less than that of rhs.
|
||||
*/
|
||||
EXIV2API bool cmpMetadataByTag(const Metadatum& lhs, const Metadatum& rhs);
|
||||
/*!
|
||||
@brief Compare two metadata by key. Return true if the key of metadatum
|
||||
lhs is less than that of rhs.
|
||||
*/
|
||||
EXIV2API bool cmpMetadataByKey(const Metadatum& lhs, const Metadatum& rhs);
|
||||
/*!
|
||||
@brief Compare two metadata by tag. Return true if the tag of metadatum
|
||||
lhs is less than that of rhs.
|
||||
*/
|
||||
EXIV2API bool cmpMetadataByTag(const Metadatum& lhs, const Metadatum& rhs);
|
||||
/*!
|
||||
@brief Compare two metadata by key. Return true if the key of metadatum
|
||||
lhs is less than that of rhs.
|
||||
*/
|
||||
EXIV2API bool cmpMetadataByKey(const Metadatum& lhs, const Metadatum& rhs);
|
||||
|
||||
} // namespace Exiv2
|
||||
} // namespace Exiv2
|
||||
|
||||
#endif // #ifndef METADATUM_HPP_
|
||||
#endif // #ifndef METADATUM_HPP_
|
||||
|
||||
+75
-76
@@ -12,92 +12,91 @@
|
||||
// *****************************************************************************
|
||||
// namespace extensions
|
||||
namespace Exiv2 {
|
||||
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
|
||||
/*!
|
||||
@brief Class to access raw Minolta MRW images. Exif metadata is supported
|
||||
directly, IPTC is read from the Exif data, if present.
|
||||
*/
|
||||
class EXIV2API MrwImage : public Image {
|
||||
public:
|
||||
//! @name NOT Implemented
|
||||
//@{
|
||||
//! Copy constructor
|
||||
MrwImage(const MrwImage& rhs) = delete;
|
||||
//! Assignment operator
|
||||
MrwImage& operator=(const MrwImage& rhs) = delete;
|
||||
//@}
|
||||
/*!
|
||||
@brief Class to access raw Minolta MRW images. Exif metadata is supported
|
||||
directly, IPTC is read from the Exif data, if present.
|
||||
*/
|
||||
class EXIV2API MrwImage : public Image {
|
||||
public:
|
||||
//! @name NOT Implemented
|
||||
//@{
|
||||
//! Copy constructor
|
||||
MrwImage(const MrwImage& rhs) = delete;
|
||||
//! Assignment operator
|
||||
MrwImage& operator=(const MrwImage& rhs) = delete;
|
||||
//@}
|
||||
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor that can either open an existing MRW image or create
|
||||
a new image from scratch. If a new image is to be created, any
|
||||
existing data is overwritten. Since the constructor can not return
|
||||
a result, callers should check the good() method after object
|
||||
construction to determine success or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
@param create Specifies if an existing image should be read (false)
|
||||
or if a new file should be created (true).
|
||||
*/
|
||||
MrwImage(BasicIo::UniquePtr io, bool create);
|
||||
//@}
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor that can either open an existing MRW image or create
|
||||
a new image from scratch. If a new image is to be created, any
|
||||
existing data is overwritten. Since the constructor can not return
|
||||
a result, callers should check the good() method after object
|
||||
construction to determine success or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
@param create Specifies if an existing image should be read (false)
|
||||
or if a new file should be created (true).
|
||||
*/
|
||||
MrwImage(BasicIo::UniquePtr io, bool create);
|
||||
//@}
|
||||
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void readMetadata() override;
|
||||
/*!
|
||||
@brief Todo: Write metadata back to the image. This method is not
|
||||
yet implemented. Calling it will throw an Error(ErrorCode::kerWritingImageFormatUnsupported).
|
||||
*/
|
||||
void writeMetadata() override;
|
||||
/*!
|
||||
@brief Todo: Not supported yet, requires writeMetadata(). Calling
|
||||
this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setExifData(const ExifData& exifData) override;
|
||||
/*!
|
||||
@brief Todo: Not supported yet, requires writeMetadata(). Calling
|
||||
this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setIptcData(const IptcData& iptcData) override;
|
||||
/*!
|
||||
@brief Not supported. MRW format does not contain a comment.
|
||||
Calling this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setComment(std::string_view comment) override;
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void readMetadata() override;
|
||||
/*!
|
||||
@brief Todo: Write metadata back to the image. This method is not
|
||||
yet implemented. Calling it will throw an Error(ErrorCode::kerWritingImageFormatUnsupported).
|
||||
*/
|
||||
void writeMetadata() override;
|
||||
/*!
|
||||
@brief Todo: Not supported yet, requires writeMetadata(). Calling
|
||||
this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setExifData(const ExifData& exifData) override;
|
||||
/*!
|
||||
@brief Todo: Not supported yet, requires writeMetadata(). Calling
|
||||
this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setIptcData(const IptcData& iptcData) override;
|
||||
/*!
|
||||
@brief Not supported. MRW format does not contain a comment.
|
||||
Calling this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setComment(std::string_view comment) override;
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override;
|
||||
uint32_t pixelWidth() const override;
|
||||
uint32_t pixelHeight() const override;
|
||||
//@}
|
||||
}; // class MrwImage
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override;
|
||||
uint32_t pixelWidth() const override;
|
||||
uint32_t pixelHeight() const override;
|
||||
//@}
|
||||
}; // class MrwImage
|
||||
|
||||
// *****************************************************************************
|
||||
// template, inline and free functions
|
||||
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new MrwImage instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newMrwInstance(BasicIo::UniquePtr io, bool create);
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new MrwImage instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newMrwInstance(BasicIo::UniquePtr io, bool create);
|
||||
|
||||
//! Check if the file iIo is a MRW image.
|
||||
EXIV2API bool isMrwType(BasicIo& iIo, bool advance);
|
||||
//! Check if the file iIo is a MRW image.
|
||||
EXIV2API bool isMrwType(BasicIo& iIo, bool advance);
|
||||
|
||||
} // namespace Exiv2
|
||||
} // namespace Exiv2
|
||||
|
||||
#endif // #ifndef MRWIMAGE_HPP_
|
||||
#endif // #ifndef MRWIMAGE_HPP_
|
||||
|
||||
+82
-90
@@ -12,107 +12,99 @@
|
||||
// *****************************************************************************
|
||||
// namespace extensions
|
||||
namespace Exiv2 {
|
||||
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
|
||||
/*!
|
||||
@brief Class to access raw Olympus ORF images. Exif metadata is supported
|
||||
directly, IPTC is read from the Exif data, if present.
|
||||
*/
|
||||
class EXIV2API OrfImage : public TiffImage {
|
||||
public:
|
||||
//! @name NOT Implemented
|
||||
//@{
|
||||
//! Copy constructor
|
||||
OrfImage(const OrfImage& rhs) = delete;
|
||||
//! Assignment operator
|
||||
OrfImage& operator=(const OrfImage& rhs) = delete;
|
||||
//@}
|
||||
/*!
|
||||
@brief Class to access raw Olympus ORF images. Exif metadata is supported
|
||||
directly, IPTC is read from the Exif data, if present.
|
||||
*/
|
||||
class EXIV2API OrfImage : public TiffImage {
|
||||
public:
|
||||
//! @name NOT Implemented
|
||||
//@{
|
||||
//! Copy constructor
|
||||
OrfImage(const OrfImage& rhs) = delete;
|
||||
//! Assignment operator
|
||||
OrfImage& operator=(const OrfImage& rhs) = delete;
|
||||
//@}
|
||||
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor that can either open an existing ORF image or create
|
||||
a new image from scratch. If a new image is to be created, any
|
||||
existing data is overwritten. Since the constructor can not return
|
||||
a result, callers should check the good() method after object
|
||||
construction to determine success or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
@param create Specifies if an existing image should be read (false)
|
||||
or if a new file should be created (true).
|
||||
*/
|
||||
OrfImage(BasicIo::UniquePtr io, bool create);
|
||||
//@}
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor that can either open an existing ORF image or create
|
||||
a new image from scratch. If a new image is to be created, any
|
||||
existing data is overwritten. Since the constructor can not return
|
||||
a result, callers should check the good() method after object
|
||||
construction to determine success or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
@param create Specifies if an existing image should be read (false)
|
||||
or if a new file should be created (true).
|
||||
*/
|
||||
OrfImage(BasicIo::UniquePtr io, bool create);
|
||||
//@}
|
||||
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void printStructure(std::ostream& out, PrintStructureOption option, int depth) override;
|
||||
void readMetadata() override;
|
||||
void writeMetadata() override;
|
||||
/*!
|
||||
@brief Not supported. ORF format does not contain a comment.
|
||||
Calling this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setComment(std::string_view comment) override;
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void printStructure(std::ostream& out, PrintStructureOption option, int depth) override;
|
||||
void readMetadata() override;
|
||||
void writeMetadata() override;
|
||||
/*!
|
||||
@brief Not supported. ORF format does not contain a comment.
|
||||
Calling this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setComment(std::string_view comment) override;
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override;
|
||||
uint32_t pixelWidth() const override;
|
||||
uint32_t pixelHeight() const override;
|
||||
//@}
|
||||
}; // class OrfImage
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override;
|
||||
uint32_t pixelWidth() const override;
|
||||
uint32_t pixelHeight() const override;
|
||||
//@}
|
||||
}; // class OrfImage
|
||||
|
||||
/*!
|
||||
@brief Stateless parser class for data in ORF format. Images use this
|
||||
class to decode and encode ORF data.
|
||||
See class TiffParser for details.
|
||||
*/
|
||||
class EXIV2API OrfParser {
|
||||
public:
|
||||
/*!
|
||||
@brief Decode metadata from a buffer \em pData of length \em size
|
||||
with data in ORF format to the provided metadata containers.
|
||||
See TiffParser::decode().
|
||||
*/
|
||||
static ByteOrder decode(ExifData& exifData, IptcData& iptcData, XmpData& xmpData, const byte* pData,
|
||||
size_t size);
|
||||
/*!
|
||||
@brief Encode metadata from the provided metadata to ORF format.
|
||||
See TiffParser::encode().
|
||||
*/
|
||||
static WriteMethod encode(BasicIo& io,
|
||||
const byte* pData,
|
||||
size_t size,
|
||||
ByteOrder byteOrder,
|
||||
const ExifData& exifData,
|
||||
const IptcData& iptcData,
|
||||
const XmpData& xmpData
|
||||
);
|
||||
}; // class OrfParser
|
||||
/*!
|
||||
@brief Stateless parser class for data in ORF format. Images use this
|
||||
class to decode and encode ORF data.
|
||||
See class TiffParser for details.
|
||||
*/
|
||||
class EXIV2API OrfParser {
|
||||
public:
|
||||
/*!
|
||||
@brief Decode metadata from a buffer \em pData of length \em size
|
||||
with data in ORF format to the provided metadata containers.
|
||||
See TiffParser::decode().
|
||||
*/
|
||||
static ByteOrder decode(ExifData& exifData, IptcData& iptcData, XmpData& xmpData, const byte* pData, size_t size);
|
||||
/*!
|
||||
@brief Encode metadata from the provided metadata to ORF format.
|
||||
See TiffParser::encode().
|
||||
*/
|
||||
static WriteMethod encode(BasicIo& io, const byte* pData, size_t size, ByteOrder byteOrder, const ExifData& exifData,
|
||||
const IptcData& iptcData, const XmpData& xmpData);
|
||||
}; // class OrfParser
|
||||
|
||||
// *****************************************************************************
|
||||
// template, inline and free functions
|
||||
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new OrfImage instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newOrfInstance(BasicIo::UniquePtr io, bool create);
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new OrfImage instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newOrfInstance(BasicIo::UniquePtr io, bool create);
|
||||
|
||||
//! Check if the file iIo is an ORF image.
|
||||
EXIV2API bool isOrfType(BasicIo& iIo, bool advance);
|
||||
//! Check if the file iIo is an ORF image.
|
||||
EXIV2API bool isOrfType(BasicIo& iIo, bool advance);
|
||||
|
||||
} // namespace Exiv2
|
||||
} // namespace Exiv2
|
||||
|
||||
#endif // #ifndef ORFIMAGE_HPP_
|
||||
#endif // #ifndef ORFIMAGE_HPP_
|
||||
|
||||
+72
-75
@@ -11,94 +11,91 @@
|
||||
|
||||
// *****************************************************************************
|
||||
// namespace extensions
|
||||
namespace Exiv2
|
||||
{
|
||||
|
||||
namespace Exiv2 {
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
|
||||
/*!
|
||||
@brief Class to access PGF images. Exif and IPTC metadata are supported
|
||||
directly.
|
||||
*/
|
||||
class EXIV2API PgfImage : public Image {
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor that can either open an existing PGF image or create
|
||||
a new image from scratch. If a new image is to be created, any
|
||||
existing data is overwritten. Since the constructor can not return
|
||||
a result, callers should check the good() method after object
|
||||
construction to determine success or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
@param create Specifies if an existing image should be read (false)
|
||||
or if a new file should be created (true).
|
||||
*/
|
||||
PgfImage(BasicIo::UniquePtr io, bool create);
|
||||
//@}
|
||||
/*!
|
||||
@brief Class to access PGF images. Exif and IPTC metadata are supported
|
||||
directly.
|
||||
*/
|
||||
class EXIV2API PgfImage : public Image {
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor that can either open an existing PGF image or create
|
||||
a new image from scratch. If a new image is to be created, any
|
||||
existing data is overwritten. Since the constructor can not return
|
||||
a result, callers should check the good() method after object
|
||||
construction to determine success or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
@param create Specifies if an existing image should be read (false)
|
||||
or if a new file should be created (true).
|
||||
*/
|
||||
PgfImage(BasicIo::UniquePtr io, bool create);
|
||||
//@}
|
||||
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void readMetadata() override;
|
||||
void writeMetadata() override;
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void readMetadata() override;
|
||||
void writeMetadata() override;
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override
|
||||
{
|
||||
return "image/pgf";
|
||||
}
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override {
|
||||
return "image/pgf";
|
||||
}
|
||||
//@}
|
||||
|
||||
//! @name NOT implemented
|
||||
//@{
|
||||
//! Copy constructor
|
||||
PgfImage(const PgfImage& rhs) = delete;
|
||||
//! Assignment operator
|
||||
PgfImage& operator=(const PgfImage& rhs) = delete;
|
||||
//! @name NOT implemented
|
||||
//@{
|
||||
//! Copy constructor
|
||||
PgfImage(const PgfImage& rhs) = delete;
|
||||
//! Assignment operator
|
||||
PgfImage& operator=(const PgfImage& rhs) = delete;
|
||||
|
||||
private:
|
||||
bool bSwap_; // true for bigEndian hardware, else false
|
||||
/*!
|
||||
@brief Provides the main implementation of writeMetadata() by
|
||||
writing all buffered metadata to the provided BasicIo.
|
||||
@param oIo BasicIo instance to write to (a temporary location).
|
||||
private:
|
||||
bool bSwap_; // true for bigEndian hardware, else false
|
||||
/*!
|
||||
@brief Provides the main implementation of writeMetadata() by
|
||||
writing all buffered metadata to the provided BasicIo.
|
||||
@param oIo BasicIo instance to write to (a temporary location).
|
||||
|
||||
@return 4 if opening or writing to the associated BasicIo fails
|
||||
*/
|
||||
void doWriteMetadata(BasicIo& outIo);
|
||||
//! Read Magick number. Only version >= 6 is supported.
|
||||
static byte readPgfMagicNumber(BasicIo& iIo);
|
||||
//! Read PGF Header size encoded in 32 bits integer.
|
||||
size_t readPgfHeaderSize(BasicIo& iIo) const;
|
||||
//! Read header structure.
|
||||
DataBuf readPgfHeaderStructure(BasicIo& iIo, uint32_t& width, uint32_t& height) const;
|
||||
//@}
|
||||
@return 4 if opening or writing to the associated BasicIo fails
|
||||
*/
|
||||
void doWriteMetadata(BasicIo& outIo);
|
||||
//! Read Magick number. Only version >= 6 is supported.
|
||||
static byte readPgfMagicNumber(BasicIo& iIo);
|
||||
//! Read PGF Header size encoded in 32 bits integer.
|
||||
size_t readPgfHeaderSize(BasicIo& iIo) const;
|
||||
//! Read header structure.
|
||||
DataBuf readPgfHeaderStructure(BasicIo& iIo, uint32_t& width, uint32_t& height) const;
|
||||
//@}
|
||||
|
||||
}; // class PgfImage
|
||||
}; // class PgfImage
|
||||
|
||||
// *****************************************************************************
|
||||
// template, inline and free functions
|
||||
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new PgfImage instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newPgfInstance(BasicIo::UniquePtr io, bool create);
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new PgfImage instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newPgfInstance(BasicIo::UniquePtr io, bool create);
|
||||
|
||||
//! Check if the file iIo is a PGF image.
|
||||
EXIV2API bool isPgfType(BasicIo& iIo, bool advance);
|
||||
//! Check if the file iIo is a PGF image.
|
||||
EXIV2API bool isPgfType(BasicIo& iIo, bool advance);
|
||||
|
||||
} // namespace Exiv2
|
||||
} // namespace Exiv2
|
||||
|
||||
#endif // #ifndef PGFIMAGE_HPP_
|
||||
#endif // #ifndef PGFIMAGE_HPP_
|
||||
|
||||
+71
-73
@@ -11,94 +11,92 @@
|
||||
|
||||
// *****************************************************************************
|
||||
// namespace extensions
|
||||
namespace Exiv2
|
||||
{
|
||||
|
||||
namespace Exiv2 {
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
|
||||
/*!
|
||||
@brief Class to access PNG images. Exif and IPTC metadata are supported
|
||||
directly.
|
||||
*/
|
||||
class EXIV2API PngImage : public Image {
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor that can either open an existing PNG image or create
|
||||
a new image from scratch. If a new image is to be created, any
|
||||
existing data is overwritten. Since the constructor can not return
|
||||
a result, callers should check the good() method after object
|
||||
construction to determine success or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
@param create Specifies if an existing image should be read (false)
|
||||
or if a new file should be created (true).
|
||||
*/
|
||||
PngImage(BasicIo::UniquePtr io, bool create);
|
||||
//@}
|
||||
/*!
|
||||
@brief Class to access PNG images. Exif and IPTC metadata are supported
|
||||
directly.
|
||||
*/
|
||||
class EXIV2API PngImage : public Image {
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor that can either open an existing PNG image or create
|
||||
a new image from scratch. If a new image is to be created, any
|
||||
existing data is overwritten. Since the constructor can not return
|
||||
a result, callers should check the good() method after object
|
||||
construction to determine success or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
@param create Specifies if an existing image should be read (false)
|
||||
or if a new file should be created (true).
|
||||
*/
|
||||
PngImage(BasicIo::UniquePtr io, bool create);
|
||||
//@}
|
||||
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void readMetadata() override;
|
||||
void writeMetadata() override;
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void readMetadata() override;
|
||||
void writeMetadata() override;
|
||||
|
||||
/*!
|
||||
@brief Print out the structure of image file.
|
||||
@throw Error if reading of the file fails or the image data is
|
||||
not valid (does not look like data of the specific image type).
|
||||
@warning This function is not thread safe and intended for exiv2 -pS for debugging.
|
||||
*/
|
||||
void printStructure(std::ostream& out, PrintStructureOption option, int depth) override;
|
||||
//@}
|
||||
/*!
|
||||
@brief Print out the structure of image file.
|
||||
@throw Error if reading of the file fails or the image data is
|
||||
not valid (does not look like data of the specific image type).
|
||||
@warning This function is not thread safe and intended for exiv2 -pS for debugging.
|
||||
*/
|
||||
void printStructure(std::ostream& out, PrintStructureOption option, int depth) override;
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override;
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override;
|
||||
//@}
|
||||
|
||||
//! @name NOT implemented
|
||||
//@{
|
||||
//! Copy constructor
|
||||
PngImage(const PngImage& rhs) = delete;
|
||||
//! Assignment operator
|
||||
PngImage& operator=(const PngImage& rhs) = delete;
|
||||
//! @name NOT implemented
|
||||
//@{
|
||||
//! Copy constructor
|
||||
PngImage(const PngImage& rhs) = delete;
|
||||
//! Assignment operator
|
||||
PngImage& operator=(const PngImage& rhs) = delete;
|
||||
|
||||
private:
|
||||
/*!
|
||||
@brief Provides the main implementation of writeMetadata() by
|
||||
writing all buffered metadata to the provided BasicIo.
|
||||
@throw Error on input-output errors or when the image data is not valid.
|
||||
@param oIo BasicIo instance to write to (a temporary location).
|
||||
private:
|
||||
/*!
|
||||
@brief Provides the main implementation of writeMetadata() by
|
||||
writing all buffered metadata to the provided BasicIo.
|
||||
@throw Error on input-output errors or when the image data is not valid.
|
||||
@param oIo BasicIo instance to write to (a temporary location).
|
||||
|
||||
*/
|
||||
void doWriteMetadata(BasicIo& outIo);
|
||||
//@}
|
||||
*/
|
||||
void doWriteMetadata(BasicIo& outIo);
|
||||
//@}
|
||||
|
||||
std::string profileName_;
|
||||
std::string profileName_;
|
||||
|
||||
}; // class PngImage
|
||||
}; // class PngImage
|
||||
|
||||
// *****************************************************************************
|
||||
// template, inline and free functions
|
||||
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new PngImage instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newPngInstance(BasicIo::UniquePtr io, bool create);
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new PngImage instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newPngInstance(BasicIo::UniquePtr io, bool create);
|
||||
|
||||
//! Check if the file iIo is a PNG image.
|
||||
EXIV2API bool isPngType(BasicIo& iIo, bool advance);
|
||||
//! Check if the file iIo is a PNG image.
|
||||
EXIV2API bool isPngType(BasicIo& iIo, bool advance);
|
||||
|
||||
} // namespace Exiv2
|
||||
} // namespace Exiv2
|
||||
|
||||
#endif // #ifndef PNGIMAGE_HPP_
|
||||
#endif // #ifndef PNGIMAGE_HPP_
|
||||
|
||||
+112
-114
@@ -11,136 +11,134 @@
|
||||
// *****************************************************************************
|
||||
// namespace extensions
|
||||
namespace Exiv2 {
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
//! Type of preview image.
|
||||
using PreviewId = int;
|
||||
|
||||
//! Type of preview image.
|
||||
using PreviewId = int;
|
||||
/*!
|
||||
@brief Preview image properties.
|
||||
*/
|
||||
struct EXIV2API PreviewProperties {
|
||||
std::string mimeType_; //!< Preview image mime type.
|
||||
std::string extension_; //!< Preview image extension.
|
||||
size_t size_; //!< Preview image size in bytes.
|
||||
size_t width_; //!< Preview image width in pixels or 0 for unknown width.
|
||||
size_t height_; //!< Preview image height in pixels or 0 for unknown height.
|
||||
PreviewId id_; //!< Identifies type of preview image.
|
||||
};
|
||||
|
||||
/*!
|
||||
@brief Preview image properties.
|
||||
*/
|
||||
struct EXIV2API PreviewProperties
|
||||
{
|
||||
std::string mimeType_; //!< Preview image mime type.
|
||||
std::string extension_; //!< Preview image extension.
|
||||
size_t size_; //!< Preview image size in bytes.
|
||||
size_t width_; //!< Preview image width in pixels or 0 for unknown width.
|
||||
size_t height_; //!< Preview image height in pixels or 0 for unknown height.
|
||||
PreviewId id_; //!< Identifies type of preview image.
|
||||
};
|
||||
//! Container type to hold all preview images metadata.
|
||||
using PreviewPropertiesList = std::vector<PreviewProperties>;
|
||||
|
||||
//! Container type to hold all preview images metadata.
|
||||
using PreviewPropertiesList = std::vector<PreviewProperties>;
|
||||
/*!
|
||||
@brief Class that holds preview image properties and data buffer.
|
||||
*/
|
||||
class EXIV2API PreviewImage {
|
||||
friend class PreviewManager;
|
||||
|
||||
/*!
|
||||
@brief Class that holds preview image properties and data buffer.
|
||||
*/
|
||||
class EXIV2API PreviewImage {
|
||||
friend class PreviewManager;
|
||||
public:
|
||||
//! @name Constructors
|
||||
//@{
|
||||
//! Copy constructor
|
||||
PreviewImage(const PreviewImage& rhs);
|
||||
//@}
|
||||
|
||||
public:
|
||||
//! @name Constructors
|
||||
//@{
|
||||
//! Copy constructor
|
||||
PreviewImage(const PreviewImage& rhs);
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
//! Assignment operator
|
||||
PreviewImage& operator=(const PreviewImage& rhs);
|
||||
//@}
|
||||
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
//! Assignment operator
|
||||
PreviewImage& operator=(const PreviewImage& rhs);
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
/*!
|
||||
@brief Return a copy of the preview image data. The caller owns
|
||||
this copy and %DataBuf ensures that it will be deleted.
|
||||
*/
|
||||
DataBuf copy() const;
|
||||
/*!
|
||||
@brief Return a pointer to the image data for read-only access.
|
||||
*/
|
||||
const byte* pData() const;
|
||||
/*!
|
||||
@brief Return the size of the preview image in bytes.
|
||||
*/
|
||||
uint32_t size() const;
|
||||
/*!
|
||||
@brief Write the thumbnail image to a file.
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
/*!
|
||||
@brief Return a copy of the preview image data. The caller owns
|
||||
this copy and %DataBuf ensures that it will be deleted.
|
||||
*/
|
||||
DataBuf copy() const;
|
||||
/*!
|
||||
@brief Return a pointer to the image data for read-only access.
|
||||
*/
|
||||
const byte* pData() const;
|
||||
/*!
|
||||
@brief Return the size of the preview image in bytes.
|
||||
*/
|
||||
uint32_t size() const;
|
||||
/*!
|
||||
@brief Write the thumbnail image to a file.
|
||||
A filename extension is appended to \em path according to the image
|
||||
type of the preview image, so \em path should not include an extension.
|
||||
The function will overwrite an existing file of the same name.
|
||||
|
||||
A filename extension is appended to \em path according to the image
|
||||
type of the preview image, so \em path should not include an extension.
|
||||
The function will overwrite an existing file of the same name.
|
||||
@param path File name of the preview image without extension.
|
||||
@return The number of bytes written.
|
||||
*/
|
||||
size_t writeFile(const std::string& path) const;
|
||||
/*!
|
||||
@brief Return the MIME type of the preview image, usually either
|
||||
\c "image/tiff" or \c "image/jpeg".
|
||||
*/
|
||||
std::string mimeType() const;
|
||||
/*!
|
||||
@brief Return the file extension for the format of the preview image
|
||||
(".tif" or ".jpg").
|
||||
*/
|
||||
std::string extension() const;
|
||||
/*!
|
||||
@brief Return the width of the preview image in pixels.
|
||||
*/
|
||||
size_t width() const;
|
||||
/*!
|
||||
@brief Return the height of the preview image in pixels.
|
||||
*/
|
||||
size_t height() const;
|
||||
/*!
|
||||
@brief Return the preview image type identifier.
|
||||
*/
|
||||
PreviewId id() const;
|
||||
//@}
|
||||
|
||||
@param path File name of the preview image without extension.
|
||||
@return The number of bytes written.
|
||||
*/
|
||||
size_t writeFile(const std::string& path) const;
|
||||
/*!
|
||||
@brief Return the MIME type of the preview image, usually either
|
||||
\c "image/tiff" or \c "image/jpeg".
|
||||
*/
|
||||
std::string mimeType() const;
|
||||
/*!
|
||||
@brief Return the file extension for the format of the preview image
|
||||
(".tif" or ".jpg").
|
||||
*/
|
||||
std::string extension() const;
|
||||
/*!
|
||||
@brief Return the width of the preview image in pixels.
|
||||
*/
|
||||
size_t width() const;
|
||||
/*!
|
||||
@brief Return the height of the preview image in pixels.
|
||||
*/
|
||||
size_t height() const;
|
||||
/*!
|
||||
@brief Return the preview image type identifier.
|
||||
*/
|
||||
PreviewId id() const;
|
||||
//@}
|
||||
private:
|
||||
//! Private constructor
|
||||
PreviewImage(PreviewProperties properties, DataBuf&& data);
|
||||
|
||||
private:
|
||||
//! Private constructor
|
||||
PreviewImage(PreviewProperties properties, DataBuf&& data);
|
||||
PreviewProperties properties_; //!< Preview image properties
|
||||
DataBuf preview_; //!< Preview image data
|
||||
|
||||
PreviewProperties properties_; //!< Preview image properties
|
||||
DataBuf preview_; //!< Preview image data
|
||||
}; // class PreviewImage
|
||||
|
||||
}; // class PreviewImage
|
||||
/*!
|
||||
@brief Class for extracting preview images from image metadata.
|
||||
*/
|
||||
class EXIV2API PreviewManager {
|
||||
public:
|
||||
//! @name Constructors
|
||||
//@{
|
||||
//! Constructor.
|
||||
explicit PreviewManager(const Image& image);
|
||||
//@}
|
||||
|
||||
/*!
|
||||
@brief Class for extracting preview images from image metadata.
|
||||
*/
|
||||
class EXIV2API PreviewManager {
|
||||
public:
|
||||
//! @name Constructors
|
||||
//@{
|
||||
//! Constructor.
|
||||
explicit PreviewManager(const Image& image);
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
/*!
|
||||
@brief Return the properties of all preview images in a list
|
||||
sorted by preview width * height, starting with the smallest
|
||||
preview image.
|
||||
*/
|
||||
PreviewPropertiesList getPreviewProperties() const;
|
||||
/*!
|
||||
@brief Return the preview image for the given preview properties.
|
||||
*/
|
||||
PreviewImage getPreviewImage(const PreviewProperties& properties) const;
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
/*!
|
||||
@brief Return the properties of all preview images in a list
|
||||
sorted by preview width * height, starting with the smallest
|
||||
preview image.
|
||||
*/
|
||||
PreviewPropertiesList getPreviewProperties() const;
|
||||
/*!
|
||||
@brief Return the preview image for the given preview properties.
|
||||
*/
|
||||
PreviewImage getPreviewImage(const PreviewProperties& properties) const;
|
||||
//@}
|
||||
private:
|
||||
const Image& image_;
|
||||
|
||||
private:
|
||||
const Image& image_;
|
||||
|
||||
}; // class PreviewManager
|
||||
}; // class PreviewManager
|
||||
} // namespace Exiv2
|
||||
|
||||
#endif // #ifndef PREVIEW_HPP_
|
||||
|
||||
+235
-239
@@ -7,292 +7,288 @@
|
||||
#include "exiv2lib_export.h"
|
||||
|
||||
// included header files
|
||||
#include "datasets.hpp"
|
||||
#include <mutex>
|
||||
#include "datasets.hpp"
|
||||
|
||||
// *****************************************************************************
|
||||
// namespace extensions
|
||||
namespace Exiv2 {
|
||||
|
||||
// *****************************************************************************
|
||||
// class declarations
|
||||
class XmpKey;
|
||||
class XmpKey;
|
||||
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
|
||||
//! Category of an XMP property
|
||||
enum XmpCategory { xmpInternal, xmpExternal };
|
||||
//! Category of an XMP property
|
||||
enum XmpCategory { xmpInternal, xmpExternal };
|
||||
|
||||
//! Information about one XMP property.
|
||||
struct EXIV2API XmpPropertyInfo {
|
||||
//! Comparison operator for name
|
||||
bool operator==(const std::string& name) const;
|
||||
//! Information about one XMP property.
|
||||
struct EXIV2API XmpPropertyInfo {
|
||||
//! Comparison operator for name
|
||||
bool operator==(const std::string& name) const;
|
||||
|
||||
const char* name_; //!< Property name
|
||||
const char* title_; //!< Property title or label
|
||||
const char* xmpValueType_; //!< XMP value type (for info only)
|
||||
TypeId typeId_; //!< Exiv2 default type for the property
|
||||
XmpCategory xmpCategory_; //!< Category (internal or external)
|
||||
const char* desc_; //!< Property description
|
||||
};
|
||||
const char* name_; //!< Property name
|
||||
const char* title_; //!< Property title or label
|
||||
const char* xmpValueType_; //!< XMP value type (for info only)
|
||||
TypeId typeId_; //!< Exiv2 default type for the property
|
||||
XmpCategory xmpCategory_; //!< Category (internal or external)
|
||||
const char* desc_; //!< Property description
|
||||
};
|
||||
|
||||
//! Structure mapping XMP namespaces and (preferred) prefixes.
|
||||
struct EXIV2API XmpNsInfo {
|
||||
//! For comparison with prefix
|
||||
struct Prefix {
|
||||
//! Constructor.
|
||||
explicit Prefix(std::string prefix);
|
||||
//! The prefix string.
|
||||
std::string prefix_;
|
||||
};
|
||||
//! For comparison with namespace
|
||||
struct Ns {
|
||||
//! Constructor.
|
||||
explicit Ns(std::string ns);
|
||||
//! The namespace string
|
||||
std::string ns_;
|
||||
};
|
||||
//! Comparison operator for namespace
|
||||
bool operator==(const Ns& ns) const;
|
||||
//! Comparison operator for prefix
|
||||
bool operator==(const Prefix& prefix) const;
|
||||
//! Structure mapping XMP namespaces and (preferred) prefixes.
|
||||
struct EXIV2API XmpNsInfo {
|
||||
//! For comparison with prefix
|
||||
struct Prefix {
|
||||
//! Constructor.
|
||||
explicit Prefix(std::string prefix);
|
||||
//! The prefix string.
|
||||
std::string prefix_;
|
||||
};
|
||||
//! For comparison with namespace
|
||||
struct Ns {
|
||||
//! Constructor.
|
||||
explicit Ns(std::string ns);
|
||||
//! The namespace string
|
||||
std::string ns_;
|
||||
};
|
||||
//! Comparison operator for namespace
|
||||
bool operator==(const Ns& ns) const;
|
||||
//! Comparison operator for prefix
|
||||
bool operator==(const Prefix& prefix) const;
|
||||
|
||||
const char* ns_; //!< Namespace
|
||||
const char* prefix_; //!< (Preferred) prefix
|
||||
const XmpPropertyInfo* xmpPropertyInfo_; //!< List of known properties
|
||||
const char* desc_; //!< Brief description of the namespace
|
||||
};
|
||||
const char* ns_; //!< Namespace
|
||||
const char* prefix_; //!< (Preferred) prefix
|
||||
const XmpPropertyInfo* xmpPropertyInfo_; //!< List of known properties
|
||||
const char* desc_; //!< Brief description of the namespace
|
||||
};
|
||||
|
||||
//! XMP property reference, implemented as a static class.
|
||||
class EXIV2API XmpProperties {
|
||||
//! Prevent construction: not implemented.
|
||||
XmpProperties();
|
||||
//! Prevent copy-construction: not implemented.
|
||||
XmpProperties(const XmpProperties& rhs);
|
||||
//! Prevent assignment: not implemented.
|
||||
XmpProperties& operator=(const XmpProperties& rhs);
|
||||
//! XMP property reference, implemented as a static class.
|
||||
class EXIV2API XmpProperties {
|
||||
//! Prevent construction: not implemented.
|
||||
XmpProperties();
|
||||
//! Prevent copy-construction: not implemented.
|
||||
XmpProperties(const XmpProperties& rhs);
|
||||
//! Prevent assignment: not implemented.
|
||||
XmpProperties& operator=(const XmpProperties& rhs);
|
||||
|
||||
private:
|
||||
static const XmpNsInfo* nsInfoUnsafe(const std::string& prefix);
|
||||
static void unregisterNsUnsafe(const std::string& ns);
|
||||
static const XmpNsInfo* lookupNsRegistryUnsafe(const XmpNsInfo::Prefix& prefix);
|
||||
private:
|
||||
static const XmpNsInfo* nsInfoUnsafe(const std::string& prefix);
|
||||
static void unregisterNsUnsafe(const std::string& ns);
|
||||
static const XmpNsInfo* lookupNsRegistryUnsafe(const XmpNsInfo::Prefix& prefix);
|
||||
|
||||
public:
|
||||
/*!
|
||||
@brief Return the title (label) of the property.
|
||||
@param key The property key
|
||||
@return The title (label) of the property, 0 if the
|
||||
key is of an unknown property.
|
||||
*/
|
||||
static const char* propertyTitle(const XmpKey& key);
|
||||
/*!
|
||||
@brief Return the description of the property.
|
||||
@param key The property key
|
||||
@return The description of the property, 0 if the
|
||||
key is of an unknown property.
|
||||
*/
|
||||
static const char* propertyDesc(const XmpKey& key);
|
||||
/*!
|
||||
@brief Return the type for property \em key. The default
|
||||
for unknown keys is xmpText.
|
||||
@param key The property key
|
||||
@return The type of the property
|
||||
*/
|
||||
static TypeId propertyType(const XmpKey& key);
|
||||
/*!
|
||||
@brief Return information for the property for key.
|
||||
public:
|
||||
/*!
|
||||
@brief Return the title (label) of the property.
|
||||
@param key The property key
|
||||
@return The title (label) of the property, 0 if the
|
||||
key is of an unknown property.
|
||||
*/
|
||||
static const char* propertyTitle(const XmpKey& key);
|
||||
/*!
|
||||
@brief Return the description of the property.
|
||||
@param key The property key
|
||||
@return The description of the property, 0 if the
|
||||
key is of an unknown property.
|
||||
*/
|
||||
static const char* propertyDesc(const XmpKey& key);
|
||||
/*!
|
||||
@brief Return the type for property \em key. The default
|
||||
for unknown keys is xmpText.
|
||||
@param key The property key
|
||||
@return The type of the property
|
||||
*/
|
||||
static TypeId propertyType(const XmpKey& key);
|
||||
/*!
|
||||
@brief Return information for the property for key.
|
||||
|
||||
If the key is a path to a nested property (one which contains a slash,
|
||||
like \c Xmp.MP.RegionInfo/MPRI:Regions), determines the innermost element
|
||||
(\c Xmp.MPRI.Regions) and returns its property information.
|
||||
If the key is a path to a nested property (one which contains a slash,
|
||||
like \c Xmp.MP.RegionInfo/MPRI:Regions), determines the innermost element
|
||||
(\c Xmp.MPRI.Regions) and returns its property information.
|
||||
|
||||
@param key The property key
|
||||
@return A pointer to the property information, 0 if the
|
||||
key is of an unknown property.
|
||||
*/
|
||||
static const XmpPropertyInfo* propertyInfo(const XmpKey& key);
|
||||
/*!
|
||||
@brief Return the namespace name for the schema associated
|
||||
with \em prefix.
|
||||
@param prefix Prefix
|
||||
@return The namespace name
|
||||
@throw Error if no namespace is registered with \em prefix.
|
||||
*/
|
||||
static std::string ns(const std::string& prefix);
|
||||
/*!
|
||||
@brief Return the namespace description for the schema associated
|
||||
with \em prefix.
|
||||
@param prefix Prefix
|
||||
@return The namespace description
|
||||
@throw Error if no namespace is registered with \em prefix.
|
||||
*/
|
||||
static const char* nsDesc(const std::string& prefix);
|
||||
/*!
|
||||
@brief Return read-only list of built-in properties for \em prefix.
|
||||
@param prefix Prefix
|
||||
@return Pointer to the built-in properties for prefix, may be 0 if
|
||||
none is configured in the namespace info.
|
||||
@throw Error if no namespace is registered with \em prefix.
|
||||
*/
|
||||
static const XmpPropertyInfo* propertyList(const std::string& prefix);
|
||||
/*!
|
||||
@brief Return information about a schema namespace for \em prefix.
|
||||
Always returns a valid pointer.
|
||||
@param prefix The prefix
|
||||
@return A pointer to the related information
|
||||
@throw Error if no namespace is registered with \em prefix.
|
||||
*/
|
||||
static const XmpNsInfo* nsInfo(const std::string& prefix);
|
||||
@param key The property key
|
||||
@return A pointer to the property information, 0 if the
|
||||
key is of an unknown property.
|
||||
*/
|
||||
static const XmpPropertyInfo* propertyInfo(const XmpKey& key);
|
||||
/*!
|
||||
@brief Return the namespace name for the schema associated
|
||||
with \em prefix.
|
||||
@param prefix Prefix
|
||||
@return The namespace name
|
||||
@throw Error if no namespace is registered with \em prefix.
|
||||
*/
|
||||
static std::string ns(const std::string& prefix);
|
||||
/*!
|
||||
@brief Return the namespace description for the schema associated
|
||||
with \em prefix.
|
||||
@param prefix Prefix
|
||||
@return The namespace description
|
||||
@throw Error if no namespace is registered with \em prefix.
|
||||
*/
|
||||
static const char* nsDesc(const std::string& prefix);
|
||||
/*!
|
||||
@brief Return read-only list of built-in properties for \em prefix.
|
||||
@param prefix Prefix
|
||||
@return Pointer to the built-in properties for prefix, may be 0 if
|
||||
none is configured in the namespace info.
|
||||
@throw Error if no namespace is registered with \em prefix.
|
||||
*/
|
||||
static const XmpPropertyInfo* propertyList(const std::string& prefix);
|
||||
/*!
|
||||
@brief Return information about a schema namespace for \em prefix.
|
||||
Always returns a valid pointer.
|
||||
@param prefix The prefix
|
||||
@return A pointer to the related information
|
||||
@throw Error if no namespace is registered with \em prefix.
|
||||
*/
|
||||
static const XmpNsInfo* nsInfo(const std::string& prefix);
|
||||
|
||||
/*!
|
||||
@brief Return the (preferred) prefix for schema namespace \em ns.
|
||||
@param ns Schema namespace
|
||||
@return The prefix or an empty string if namespace \em ns is not
|
||||
registered.
|
||||
*/
|
||||
static std::string prefix(const std::string& ns);
|
||||
//! Print a list of properties of a schema namespace to output stream \em os.
|
||||
static void printProperties(std::ostream& os, const std::string& prefix);
|
||||
/*!
|
||||
@brief Return the (preferred) prefix for schema namespace \em ns.
|
||||
@param ns Schema namespace
|
||||
@return The prefix or an empty string if namespace \em ns is not
|
||||
registered.
|
||||
*/
|
||||
static std::string prefix(const std::string& ns);
|
||||
//! Print a list of properties of a schema namespace to output stream \em os.
|
||||
static void printProperties(std::ostream& os, const std::string& prefix);
|
||||
|
||||
//! Interpret and print the value of an XMP property
|
||||
static std::ostream& printProperty(std::ostream& os,
|
||||
const std::string& key,
|
||||
const Value& value);
|
||||
/*!
|
||||
@brief Register namespace \em ns with preferred prefix \em prefix.
|
||||
//! Interpret and print the value of an XMP property
|
||||
static std::ostream& printProperty(std::ostream& os, const std::string& key, const Value& value);
|
||||
/*!
|
||||
@brief Register namespace \em ns with preferred prefix \em prefix.
|
||||
|
||||
If the prefix is a known or previously registered prefix, the
|
||||
corresponding namespace URI is overwritten.
|
||||
If the prefix is a known or previously registered prefix, the
|
||||
corresponding namespace URI is overwritten.
|
||||
|
||||
@note This invalidates XMP keys generated with the previous prefix.
|
||||
*/
|
||||
static void registerNs(const std::string& ns, const std::string& prefix);
|
||||
/*!
|
||||
@brief Unregister a custom namespace \em ns.
|
||||
@note This invalidates XMP keys generated with the previous prefix.
|
||||
*/
|
||||
static void registerNs(const std::string& ns, const std::string& prefix);
|
||||
/*!
|
||||
@brief Unregister a custom namespace \em ns.
|
||||
|
||||
The function only has an effect if there is a namespace \em ns
|
||||
registered earlier, it does not unregister built-in namespaces.
|
||||
The function only has an effect if there is a namespace \em ns
|
||||
registered earlier, it does not unregister built-in namespaces.
|
||||
|
||||
@note This invalidates XMP keys generated in this namespace.
|
||||
*/
|
||||
static void unregisterNs(const std::string& ns);
|
||||
@note This invalidates XMP keys generated in this namespace.
|
||||
*/
|
||||
static void unregisterNs(const std::string& ns);
|
||||
|
||||
/*!
|
||||
@brief Lock to be used while modifying properties.
|
||||
/*!
|
||||
@brief Lock to be used while modifying properties.
|
||||
|
||||
@todo For a proper read-write lock, this shall be improved by a
|
||||
\em std::shared_timed_mutex (once C++14 is allowed) or
|
||||
\em std::shared_mutex (once C++17 is allowed). The
|
||||
read-access locks shall be updated to \em std::shared_lock then.
|
||||
*/
|
||||
static std::mutex mutex_;
|
||||
@todo For a proper read-write lock, this shall be improved by a
|
||||
\em std::shared_timed_mutex (once C++14 is allowed) or
|
||||
\em std::shared_mutex (once C++17 is allowed). The
|
||||
read-access locks shall be updated to \em std::shared_lock then.
|
||||
*/
|
||||
static std::mutex mutex_;
|
||||
|
||||
/*!
|
||||
@brief Unregister all custom namespaces.
|
||||
/*!
|
||||
@brief Unregister all custom namespaces.
|
||||
|
||||
The function only unregisters namespaces registered earlier, it does not
|
||||
unregister built-in namespaces.
|
||||
The function only unregisters namespaces registered earlier, it does not
|
||||
unregister built-in namespaces.
|
||||
|
||||
@note This invalidates XMP keys generated in any custom namespace.
|
||||
*/
|
||||
static void unregisterNs();
|
||||
//! Type for the namespace registry
|
||||
using NsRegistry = std::map<std::string, XmpNsInfo>;
|
||||
/*!
|
||||
@brief Get the registered namespace for a specific \em prefix from the registry.
|
||||
*/
|
||||
static const XmpNsInfo* lookupNsRegistry(const XmpNsInfo::Prefix& prefix);
|
||||
@note This invalidates XMP keys generated in any custom namespace.
|
||||
*/
|
||||
static void unregisterNs();
|
||||
//! Type for the namespace registry
|
||||
using NsRegistry = std::map<std::string, XmpNsInfo>;
|
||||
/*!
|
||||
@brief Get the registered namespace for a specific \em prefix from the registry.
|
||||
*/
|
||||
static const XmpNsInfo* lookupNsRegistry(const XmpNsInfo::Prefix& prefix);
|
||||
|
||||
// DATA
|
||||
static NsRegistry nsRegistry_; //!< Namespace registry
|
||||
// DATA
|
||||
static NsRegistry nsRegistry_; //!< Namespace registry
|
||||
|
||||
/*!
|
||||
@brief Get all registered namespaces (for both Exiv2 and XMPsdk)
|
||||
*/
|
||||
static void registeredNamespaces(Exiv2::Dictionary& nsDict);
|
||||
/*!
|
||||
@brief Get all registered namespaces (for both Exiv2 and XMPsdk)
|
||||
*/
|
||||
static void registeredNamespaces(Exiv2::Dictionary& nsDict);
|
||||
|
||||
}; // class XmpProperties
|
||||
}; // class XmpProperties
|
||||
|
||||
/*!
|
||||
@brief Concrete keys for XMP metadata.
|
||||
*/
|
||||
class EXIV2API XmpKey : public Key
|
||||
{
|
||||
public:
|
||||
//! Shortcut for an %XmpKey auto pointer.
|
||||
using UniquePtr = std::unique_ptr<XmpKey>;
|
||||
/*!
|
||||
@brief Concrete keys for XMP metadata.
|
||||
*/
|
||||
class EXIV2API XmpKey : public Key {
|
||||
public:
|
||||
//! Shortcut for an %XmpKey auto pointer.
|
||||
using UniquePtr = std::unique_ptr<XmpKey>;
|
||||
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor to create an XMP key from a key string.
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor to create an XMP key from a key string.
|
||||
|
||||
@param key The key string.
|
||||
@throw Error if the first part of the key is not '<b>Xmp</b>' or
|
||||
the second part of the key cannot be parsed and converted
|
||||
to a known (i.e., built-in or registered) schema prefix.
|
||||
*/
|
||||
explicit XmpKey(const std::string& key);
|
||||
/*!
|
||||
@brief Constructor to create an XMP key from a schema prefix
|
||||
and a property name.
|
||||
@param key The key string.
|
||||
@throw Error if the first part of the key is not '<b>Xmp</b>' or
|
||||
the second part of the key cannot be parsed and converted
|
||||
to a known (i.e., built-in or registered) schema prefix.
|
||||
*/
|
||||
explicit XmpKey(const std::string& key);
|
||||
/*!
|
||||
@brief Constructor to create an XMP key from a schema prefix
|
||||
and a property name.
|
||||
|
||||
@param prefix Schema prefix name
|
||||
@param property Property name
|
||||
@param prefix Schema prefix name
|
||||
@param property Property name
|
||||
|
||||
@throw Error if the schema prefix is not known.
|
||||
*/
|
||||
XmpKey(const std::string& prefix, const std::string& property);
|
||||
//! Copy constructor.
|
||||
XmpKey(const XmpKey& rhs);
|
||||
//! Virtual destructor.
|
||||
~XmpKey() override;
|
||||
//@}
|
||||
@throw Error if the schema prefix is not known.
|
||||
*/
|
||||
XmpKey(const std::string& prefix, const std::string& property);
|
||||
//! Copy constructor.
|
||||
XmpKey(const XmpKey& rhs);
|
||||
//! Virtual destructor.
|
||||
~XmpKey() override;
|
||||
//@}
|
||||
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
//! Assignment operator.
|
||||
XmpKey& operator=(const XmpKey& rhs);
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
//! Assignment operator.
|
||||
XmpKey& operator=(const XmpKey& rhs);
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string key() const override;
|
||||
const char* familyName() const override;
|
||||
/*!
|
||||
@brief Return the name of the group (the second part of the key).
|
||||
For XMP keys, the group name is the schema prefix name.
|
||||
*/
|
||||
std::string groupName() const override;
|
||||
std::string tagName() const override;
|
||||
std::string tagLabel() const override;
|
||||
//! Properties don't have a tag number. Return 0.
|
||||
uint16_t tag() const override;
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string key() const override;
|
||||
const char* familyName() const override;
|
||||
/*!
|
||||
@brief Return the name of the group (the second part of the key).
|
||||
For XMP keys, the group name is the schema prefix name.
|
||||
*/
|
||||
std::string groupName() const override;
|
||||
std::string tagName() const override;
|
||||
std::string tagLabel() const override;
|
||||
//! Properties don't have a tag number. Return 0.
|
||||
uint16_t tag() const override;
|
||||
|
||||
UniquePtr clone() const;
|
||||
UniquePtr clone() const;
|
||||
|
||||
// Todo: Should this be removed? What about tagLabel then?
|
||||
//! Return the schema namespace for the prefix of the key
|
||||
std::string ns() const;
|
||||
//@}
|
||||
// Todo: Should this be removed? What about tagLabel then?
|
||||
//! Return the schema namespace for the prefix of the key
|
||||
std::string ns() const;
|
||||
//@}
|
||||
|
||||
private:
|
||||
//! Internal virtual copy constructor.
|
||||
XmpKey* clone_() const override;
|
||||
private:
|
||||
//! Internal virtual copy constructor.
|
||||
XmpKey* clone_() const override;
|
||||
|
||||
// Pimpl idiom
|
||||
struct Impl;
|
||||
std::unique_ptr<Impl> p_;
|
||||
// Pimpl idiom
|
||||
struct Impl;
|
||||
std::unique_ptr<Impl> p_;
|
||||
|
||||
}; // class XmpKey
|
||||
}; // class XmpKey
|
||||
|
||||
// *****************************************************************************
|
||||
// free functions
|
||||
// *****************************************************************************
|
||||
// free functions
|
||||
|
||||
//! Output operator for property info
|
||||
EXIV2API std::ostream& operator<<(std::ostream& os, const XmpPropertyInfo& propertyInfo);
|
||||
//! Output operator for property info
|
||||
EXIV2API std::ostream& operator<<(std::ostream& os, const XmpPropertyInfo& propertyInfo);
|
||||
|
||||
} // namespace Exiv2
|
||||
} // namespace Exiv2
|
||||
|
||||
#endif // #ifndef PROPERTIES_HPP_
|
||||
#endif // #ifndef PROPERTIES_HPP_
|
||||
|
||||
+81
-82
@@ -12,104 +12,103 @@
|
||||
// *****************************************************************************
|
||||
// namespace extensions
|
||||
namespace Exiv2 {
|
||||
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
|
||||
/*!
|
||||
@brief Class to access raw Photoshop images.
|
||||
*/
|
||||
class EXIV2API PsdImage : public Image {
|
||||
public:
|
||||
//! @name NOT Implemented
|
||||
//@{
|
||||
//! Copy constructor
|
||||
PsdImage(const PsdImage& rhs) = delete;
|
||||
//! Assignment operator
|
||||
PsdImage& operator=(const PsdImage& rhs) = delete;
|
||||
//@}
|
||||
/*!
|
||||
@brief Class to access raw Photoshop images.
|
||||
*/
|
||||
class EXIV2API PsdImage : public Image {
|
||||
public:
|
||||
//! @name NOT Implemented
|
||||
//@{
|
||||
//! Copy constructor
|
||||
PsdImage(const PsdImage& rhs) = delete;
|
||||
//! Assignment operator
|
||||
PsdImage& operator=(const PsdImage& rhs) = delete;
|
||||
//@}
|
||||
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor to open a Photoshop image. Since the
|
||||
constructor can not return a result, callers should check the
|
||||
good() method after object construction to determine success
|
||||
or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
*/
|
||||
explicit PsdImage(BasicIo::UniquePtr io);
|
||||
//@}
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor to open a Photoshop image. Since the
|
||||
constructor can not return a result, callers should check the
|
||||
good() method after object construction to determine success
|
||||
or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
*/
|
||||
explicit PsdImage(BasicIo::UniquePtr io);
|
||||
//@}
|
||||
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void readMetadata() override;
|
||||
void writeMetadata() override;
|
||||
/*!
|
||||
@brief Not supported. Calling this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setComment(std::string_view comment) override;
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void readMetadata() override;
|
||||
void writeMetadata() override;
|
||||
/*!
|
||||
@brief Not supported. Calling this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setComment(std::string_view comment) override;
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
/*!
|
||||
@brief Return the MIME type of the image.
|
||||
//! @name Accessors
|
||||
//@{
|
||||
/*!
|
||||
@brief Return the MIME type of the image.
|
||||
|
||||
The MIME type returned for Photoshop images is "image/x-photoshop".
|
||||
The MIME type returned for Photoshop images is "image/x-photoshop".
|
||||
|
||||
@note This should really be "image/vnd.adobe.photoshop"
|
||||
(officially registered with IANA in December 2005 -- see
|
||||
http://www.iana.org/assignments/media-types/image/vnd.adobe.photoshop)
|
||||
but Apple, as of Tiger (10.4.8), maps this official MIME type to a
|
||||
dynamic UTI, rather than "com.adobe.photoshop-image" as it should.
|
||||
*/
|
||||
std::string mimeType() const override;
|
||||
//@}
|
||||
@note This should really be "image/vnd.adobe.photoshop"
|
||||
(officially registered with IANA in December 2005 -- see
|
||||
http://www.iana.org/assignments/media-types/image/vnd.adobe.photoshop)
|
||||
but Apple, as of Tiger (10.4.8), maps this official MIME type to a
|
||||
dynamic UTI, rather than "com.adobe.photoshop-image" as it should.
|
||||
*/
|
||||
std::string mimeType() const override;
|
||||
//@}
|
||||
|
||||
private:
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void readResourceBlock(uint16_t resourceId, uint32_t resourceSize);
|
||||
/*!
|
||||
@brief Provides the main implementation of writeMetadata() by
|
||||
writing all buffered metadata to the provided BasicIo.
|
||||
@param oIo BasicIo instance to write to (a temporary location).
|
||||
private:
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void readResourceBlock(uint16_t resourceId, uint32_t resourceSize);
|
||||
/*!
|
||||
@brief Provides the main implementation of writeMetadata() by
|
||||
writing all buffered metadata to the provided BasicIo.
|
||||
@param oIo BasicIo instance to write to (a temporary location).
|
||||
|
||||
@return 4 if opening or writing to the associated BasicIo fails
|
||||
*/
|
||||
void doWriteMetadata(BasicIo& outIo);
|
||||
uint32_t writeExifData(const ExifData& exifData, BasicIo& out);
|
||||
//@}
|
||||
@return 4 if opening or writing to the associated BasicIo fails
|
||||
*/
|
||||
void doWriteMetadata(BasicIo& outIo);
|
||||
uint32_t writeExifData(const ExifData& exifData, BasicIo& out);
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
static uint32_t writeIptcData(const IptcData& iptcData, BasicIo& out);
|
||||
uint32_t writeXmpData(const XmpData& xmpData, BasicIo& out) const;
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
static uint32_t writeIptcData(const IptcData& iptcData, BasicIo& out);
|
||||
uint32_t writeXmpData(const XmpData& xmpData, BasicIo& out) const;
|
||||
//@}
|
||||
|
||||
}; // class PsdImage
|
||||
}; // class PsdImage
|
||||
|
||||
// *****************************************************************************
|
||||
// template, inline and free functions
|
||||
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new PsdImage instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newPsdInstance(BasicIo::UniquePtr io, bool create);
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new PsdImage instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newPsdInstance(BasicIo::UniquePtr io, bool create);
|
||||
|
||||
//! Check if the file iIo is a Photoshop image.
|
||||
EXIV2API bool isPsdType(BasicIo& iIo, bool advance);
|
||||
//! Check if the file iIo is a Photoshop image.
|
||||
EXIV2API bool isPsdType(BasicIo& iIo, bool advance);
|
||||
|
||||
} // namespace Exiv2
|
||||
} // namespace Exiv2
|
||||
|
||||
#endif // #ifndef PSDIMAGE_HPP_
|
||||
#endif // #ifndef PSDIMAGE_HPP_
|
||||
|
||||
+76
-77
@@ -12,94 +12,93 @@
|
||||
// *****************************************************************************
|
||||
// namespace extensions
|
||||
namespace Exiv2 {
|
||||
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
|
||||
/*!
|
||||
@brief Class to access raw Fujifilm RAF images. Exif metadata is
|
||||
supported directly, IPTC is read from the Exif data, if present.
|
||||
*/
|
||||
class EXIV2API RafImage : public Image {
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor that can either open an existing RAF image or create
|
||||
a new image from scratch. If a new image is to be created, any
|
||||
existing data is overwritten. Since the constructor can not return
|
||||
a result, callers should check the good() method after object
|
||||
construction to determine success or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
@param create Specifies if an existing image should be read (false)
|
||||
or if a new file should be created (true).
|
||||
*/
|
||||
RafImage(BasicIo::UniquePtr io, bool create);
|
||||
//@}
|
||||
/*!
|
||||
@brief Class to access raw Fujifilm RAF images. Exif metadata is
|
||||
supported directly, IPTC is read from the Exif data, if present.
|
||||
*/
|
||||
class EXIV2API RafImage : public Image {
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor that can either open an existing RAF image or create
|
||||
a new image from scratch. If a new image is to be created, any
|
||||
existing data is overwritten. Since the constructor can not return
|
||||
a result, callers should check the good() method after object
|
||||
construction to determine success or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
@param create Specifies if an existing image should be read (false)
|
||||
or if a new file should be created (true).
|
||||
*/
|
||||
RafImage(BasicIo::UniquePtr io, bool create);
|
||||
//@}
|
||||
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void printStructure(std::ostream& out, PrintStructureOption option, int depth) override;
|
||||
void readMetadata() override;
|
||||
/*!
|
||||
@brief Todo: Write metadata back to the image. This method is not
|
||||
yet implemented. Calling it will throw an Error(ErrorCode::kerWritingImageFormatUnsupported).
|
||||
*/
|
||||
void writeMetadata() override;
|
||||
/*!
|
||||
@brief Todo: Not supported yet, requires writeMetadata(). Calling
|
||||
this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setExifData(const ExifData& exifData) override;
|
||||
/*!
|
||||
@brief Todo: Not supported yet, requires writeMetadata(). Calling
|
||||
this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setIptcData(const IptcData& iptcData) override;
|
||||
/*!
|
||||
@brief Not supported. RAF format does not contain a comment.
|
||||
Calling this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setComment(std::string_view comment) override;
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void printStructure(std::ostream& out, PrintStructureOption option, int depth) override;
|
||||
void readMetadata() override;
|
||||
/*!
|
||||
@brief Todo: Write metadata back to the image. This method is not
|
||||
yet implemented. Calling it will throw an Error(ErrorCode::kerWritingImageFormatUnsupported).
|
||||
*/
|
||||
void writeMetadata() override;
|
||||
/*!
|
||||
@brief Todo: Not supported yet, requires writeMetadata(). Calling
|
||||
this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setExifData(const ExifData& exifData) override;
|
||||
/*!
|
||||
@brief Todo: Not supported yet, requires writeMetadata(). Calling
|
||||
this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setIptcData(const IptcData& iptcData) override;
|
||||
/*!
|
||||
@brief Not supported. RAF format does not contain a comment.
|
||||
Calling this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setComment(std::string_view comment) override;
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override;
|
||||
uint32_t pixelWidth() const override;
|
||||
uint32_t pixelHeight() const override;
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override;
|
||||
uint32_t pixelWidth() const override;
|
||||
uint32_t pixelHeight() const override;
|
||||
//@}
|
||||
|
||||
//! @name NOT implemented
|
||||
//@{
|
||||
//! Copy constructor
|
||||
RafImage(const RafImage& rhs) = delete;
|
||||
//! Assignment operator
|
||||
RafImage& operator=(const RafImage& rhs) = delete;
|
||||
//@}
|
||||
//! @name NOT implemented
|
||||
//@{
|
||||
//! Copy constructor
|
||||
RafImage(const RafImage& rhs) = delete;
|
||||
//! Assignment operator
|
||||
RafImage& operator=(const RafImage& rhs) = delete;
|
||||
//@}
|
||||
|
||||
}; // class RafImage
|
||||
}; // class RafImage
|
||||
|
||||
// *****************************************************************************
|
||||
// template, inline and free functions
|
||||
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new RafImage instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newRafInstance(BasicIo::UniquePtr io, bool create);
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new RafImage instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newRafInstance(BasicIo::UniquePtr io, bool create);
|
||||
|
||||
//! Check if the file iIo is a RAF image.
|
||||
EXIV2API bool isRafType(BasicIo& iIo, bool advance);
|
||||
//! Check if the file iIo is a RAF image.
|
||||
EXIV2API bool isRafType(BasicIo& iIo, bool advance);
|
||||
|
||||
} // namespace Exiv2
|
||||
} // namespace Exiv2
|
||||
|
||||
#endif // #ifndef RAFIMAGE_HPP_
|
||||
#endif // #ifndef RAFIMAGE_HPP_
|
||||
|
||||
+88
-94
@@ -12,113 +12,107 @@
|
||||
// *****************************************************************************
|
||||
// namespace extensions
|
||||
namespace Exiv2 {
|
||||
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
|
||||
/*!
|
||||
@brief Class to access raw Panasonic RW2 images. Exif metadata is
|
||||
supported directly, IPTC and XMP are read from the Exif data, if
|
||||
present.
|
||||
*/
|
||||
class EXIV2API Rw2Image : public Image {
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor to open an existing RW2 image. Since the
|
||||
constructor can not return a result, callers should check the
|
||||
good() method after object construction to determine success or
|
||||
failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
*/
|
||||
explicit Rw2Image(BasicIo::UniquePtr io);
|
||||
//@}
|
||||
/*!
|
||||
@brief Class to access raw Panasonic RW2 images. Exif metadata is
|
||||
supported directly, IPTC and XMP are read from the Exif data, if
|
||||
present.
|
||||
*/
|
||||
class EXIV2API Rw2Image : public Image {
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor to open an existing RW2 image. Since the
|
||||
constructor can not return a result, callers should check the
|
||||
good() method after object construction to determine success or
|
||||
failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
*/
|
||||
explicit Rw2Image(BasicIo::UniquePtr io);
|
||||
//@}
|
||||
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void printStructure(std::ostream& out, PrintStructureOption option, int depth) override;
|
||||
void readMetadata() override;
|
||||
/*!
|
||||
@brief Todo: Write metadata back to the image. This method is not
|
||||
yet implemented. Calling it will throw an Error(ErrorCode::kerWritingImageFormatUnsupported).
|
||||
*/
|
||||
void writeMetadata() override;
|
||||
/*!
|
||||
@brief Todo: Not supported yet, requires writeMetadata(). Calling
|
||||
this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setExifData(const ExifData& exifData) override;
|
||||
/*!
|
||||
@brief Todo: Not supported yet, requires writeMetadata(). Calling
|
||||
this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setIptcData(const IptcData& iptcData) override;
|
||||
/*!
|
||||
@brief Not supported. RW2 format does not contain a comment.
|
||||
Calling this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setComment(std::string_view comment) override;
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void printStructure(std::ostream& out, PrintStructureOption option, int depth) override;
|
||||
void readMetadata() override;
|
||||
/*!
|
||||
@brief Todo: Write metadata back to the image. This method is not
|
||||
yet implemented. Calling it will throw an Error(ErrorCode::kerWritingImageFormatUnsupported).
|
||||
*/
|
||||
void writeMetadata() override;
|
||||
/*!
|
||||
@brief Todo: Not supported yet, requires writeMetadata(). Calling
|
||||
this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setExifData(const ExifData& exifData) override;
|
||||
/*!
|
||||
@brief Todo: Not supported yet, requires writeMetadata(). Calling
|
||||
this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setIptcData(const IptcData& iptcData) override;
|
||||
/*!
|
||||
@brief Not supported. RW2 format does not contain a comment.
|
||||
Calling this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setComment(std::string_view comment) override;
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override;
|
||||
uint32_t pixelWidth() const override;
|
||||
uint32_t pixelHeight() const override;
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override;
|
||||
uint32_t pixelWidth() const override;
|
||||
uint32_t pixelHeight() const override;
|
||||
//@}
|
||||
|
||||
//! @name NOT implemented
|
||||
//@{
|
||||
//! Copy constructor
|
||||
Rw2Image(const Rw2Image& rhs) = delete;
|
||||
//! Assignment operator
|
||||
Rw2Image& operator=(const Rw2Image& rhs) = delete;
|
||||
//@}
|
||||
//! @name NOT implemented
|
||||
//@{
|
||||
//! Copy constructor
|
||||
Rw2Image(const Rw2Image& rhs) = delete;
|
||||
//! Assignment operator
|
||||
Rw2Image& operator=(const Rw2Image& rhs) = delete;
|
||||
//@}
|
||||
|
||||
}; // class Rw2Image
|
||||
}; // class Rw2Image
|
||||
|
||||
/*!
|
||||
@brief Stateless parser class for data in RW2 format. Images use this
|
||||
class to decode and encode RW2 data. Only decoding is currently
|
||||
implemented. See class TiffParser for details.
|
||||
*/
|
||||
class EXIV2API Rw2Parser {
|
||||
public:
|
||||
/*!
|
||||
@brief Decode metadata from a buffer \em pData of length \em size
|
||||
with data in RW2 format to the provided metadata containers.
|
||||
See TiffParser::decode().
|
||||
*/
|
||||
static ByteOrder decode(ExifData& exifData,
|
||||
IptcData& iptcData,
|
||||
XmpData& xmpData,
|
||||
const byte* pData,
|
||||
size_t size
|
||||
);
|
||||
/*!
|
||||
@brief Stateless parser class for data in RW2 format. Images use this
|
||||
class to decode and encode RW2 data. Only decoding is currently
|
||||
implemented. See class TiffParser for details.
|
||||
*/
|
||||
class EXIV2API Rw2Parser {
|
||||
public:
|
||||
/*!
|
||||
@brief Decode metadata from a buffer \em pData of length \em size
|
||||
with data in RW2 format to the provided metadata containers.
|
||||
See TiffParser::decode().
|
||||
*/
|
||||
static ByteOrder decode(ExifData& exifData, IptcData& iptcData, XmpData& xmpData, const byte* pData, size_t size);
|
||||
|
||||
}; // class Rw2Parser
|
||||
}; // class Rw2Parser
|
||||
|
||||
// *****************************************************************************
|
||||
// template, inline and free functions
|
||||
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new Rw2Image instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newRw2Instance(BasicIo::UniquePtr io, bool create);
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new Rw2Image instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newRw2Instance(BasicIo::UniquePtr io, bool create);
|
||||
|
||||
//! Check if the file iIo is a RW2 image.
|
||||
EXIV2API bool isRw2Type(BasicIo& iIo, bool advance);
|
||||
//! Check if the file iIo is a RW2 image.
|
||||
EXIV2API bool isRw2Type(BasicIo& iIo, bool advance);
|
||||
|
||||
} // namespace Exiv2
|
||||
} // namespace Exiv2
|
||||
|
||||
#endif // #ifndef RW2IMAGE_HPP_
|
||||
#endif // #ifndef RW2IMAGE_HPP_
|
||||
|
||||
+574
-629
File diff suppressed because it is too large
Load Diff
+148
-149
@@ -12,183 +12,182 @@
|
||||
// *****************************************************************************
|
||||
// namespace extensions
|
||||
namespace Exiv2 {
|
||||
|
||||
// *****************************************************************************
|
||||
// class declarations
|
||||
class ExifData;
|
||||
class ExifKey;
|
||||
class Value;
|
||||
struct TagInfo;
|
||||
class ExifData;
|
||||
class ExifKey;
|
||||
class Value;
|
||||
struct TagInfo;
|
||||
|
||||
// *****************************************************************************
|
||||
// type definitions
|
||||
|
||||
//! Type for a function pointer for functions interpreting the tag value
|
||||
using PrintFct = std::ostream& (*)(std::ostream&, const Value&, const ExifData* pExifData);
|
||||
//! A function returning a tag list.
|
||||
using TagListFct = const TagInfo* (*)();
|
||||
//! Type for a function pointer for functions interpreting the tag value
|
||||
using PrintFct = std::ostream& (*)(std::ostream&, const Value&, const ExifData* pExifData);
|
||||
//! A function returning a tag list.
|
||||
using TagListFct = const TagInfo* (*)();
|
||||
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
|
||||
//! The details of an Exif group. Groups include IFDs and binary arrays.
|
||||
struct EXIV2API GroupInfo {
|
||||
struct GroupName;
|
||||
bool operator==(int ifdId) const; //!< Comparison operator for IFD id
|
||||
bool operator==(const GroupName& groupName) const; //!< Comparison operator for group name
|
||||
int ifdId_; //!< IFD id
|
||||
const char* ifdName_; //!< IFD name
|
||||
const char* groupName_; //!< Group name, unique for each group.
|
||||
TagListFct tagList_; //!< Tag list
|
||||
};
|
||||
//! The details of an Exif group. Groups include IFDs and binary arrays.
|
||||
struct EXIV2API GroupInfo {
|
||||
struct GroupName;
|
||||
bool operator==(int ifdId) const; //!< Comparison operator for IFD id
|
||||
bool operator==(const GroupName& groupName) const; //!< Comparison operator for group name
|
||||
int ifdId_; //!< IFD id
|
||||
const char* ifdName_; //!< IFD name
|
||||
const char* groupName_; //!< Group name, unique for each group.
|
||||
TagListFct tagList_; //!< Tag list
|
||||
};
|
||||
|
||||
//! Search key to find a GroupInfo by its group name.
|
||||
struct EXIV2API GroupInfo::GroupName {
|
||||
explicit GroupName(std::string groupName);
|
||||
std::string g_; //!< Group name
|
||||
};
|
||||
//! Search key to find a GroupInfo by its group name.
|
||||
struct EXIV2API GroupInfo::GroupName {
|
||||
explicit GroupName(std::string groupName);
|
||||
std::string g_; //!< Group name
|
||||
};
|
||||
|
||||
//! Tag information
|
||||
struct EXIV2API TagInfo {
|
||||
uint16_t tag_; //!< Tag
|
||||
const char* name_; //!< One word tag label
|
||||
const char* title_; //!< Tag title
|
||||
const char* desc_; //!< Short tag description
|
||||
int ifdId_; //!< Link to the (preferred) IFD
|
||||
int sectionId_; //!< Section id
|
||||
TypeId typeId_; //!< Type id
|
||||
int16_t count_; //!< The number of values (not bytes!), 0=any, -1=count not known.
|
||||
PrintFct printFct_; //!< Pointer to tag print function
|
||||
}; // struct TagInfo
|
||||
//! Tag information
|
||||
struct EXIV2API TagInfo {
|
||||
uint16_t tag_; //!< Tag
|
||||
const char* name_; //!< One word tag label
|
||||
const char* title_; //!< Tag title
|
||||
const char* desc_; //!< Short tag description
|
||||
int ifdId_; //!< Link to the (preferred) IFD
|
||||
int sectionId_; //!< Section id
|
||||
TypeId typeId_; //!< Type id
|
||||
int16_t count_; //!< The number of values (not bytes!), 0=any, -1=count not known.
|
||||
PrintFct printFct_; //!< Pointer to tag print function
|
||||
}; // struct TagInfo
|
||||
|
||||
//! Access to Exif group and tag lists and misc. tag reference methods, implemented as a static class.
|
||||
class EXIV2API ExifTags {
|
||||
public:
|
||||
//! Prevent construction: not implemented.
|
||||
ExifTags() = delete;
|
||||
//! Prevent copy-construction: not implemented.
|
||||
ExifTags(const ExifTags& rhs) = delete;
|
||||
//! Prevent assignment: not implemented.
|
||||
ExifTags& operator=(const ExifTags& rhs) = delete;
|
||||
//! Access to Exif group and tag lists and misc. tag reference methods, implemented as a static class.
|
||||
class EXIV2API ExifTags {
|
||||
public:
|
||||
//! Prevent construction: not implemented.
|
||||
ExifTags() = delete;
|
||||
//! Prevent copy-construction: not implemented.
|
||||
ExifTags(const ExifTags& rhs) = delete;
|
||||
//! Prevent assignment: not implemented.
|
||||
ExifTags& operator=(const ExifTags& rhs) = delete;
|
||||
|
||||
//! Return read-only list of built-in groups
|
||||
static const GroupInfo* groupList();
|
||||
//! Return read-only list of built-in \em groupName tags.
|
||||
static const TagInfo* tagList(const std::string& groupName);
|
||||
//! Print a list of all standard Exif tags to output stream
|
||||
static void taglist(std::ostream& os);
|
||||
//! Print the list of tags for \em groupName
|
||||
static void taglist(std::ostream& os, const std::string& groupName);
|
||||
//! Return read-only list of built-in groups
|
||||
static const GroupInfo* groupList();
|
||||
//! Return read-only list of built-in \em groupName tags.
|
||||
static const TagInfo* tagList(const std::string& groupName);
|
||||
//! Print a list of all standard Exif tags to output stream
|
||||
static void taglist(std::ostream& os);
|
||||
//! Print the list of tags for \em groupName
|
||||
static void taglist(std::ostream& os, const std::string& groupName);
|
||||
|
||||
//! Return the name of the section for an Exif \em key.
|
||||
static const char* sectionName(const ExifKey& key);
|
||||
//! Return the default number of components (not bytes!) \em key has. (0=any, -1=count not known)
|
||||
static uint16_t defaultCount(const ExifKey& key);
|
||||
//! Return the name of the IFD for the group.
|
||||
static const char* ifdName(const std::string& groupName);
|
||||
//! Return the name of the section for an Exif \em key.
|
||||
static const char* sectionName(const ExifKey& key);
|
||||
//! Return the default number of components (not bytes!) \em key has. (0=any, -1=count not known)
|
||||
static uint16_t defaultCount(const ExifKey& key);
|
||||
//! Return the name of the IFD for the group.
|
||||
static const char* ifdName(const std::string& groupName);
|
||||
|
||||
/*!
|
||||
@brief Return true if \em groupName is a makernote group.
|
||||
*/
|
||||
static bool isMakerGroup(const std::string& groupName);
|
||||
/*!
|
||||
@brief Return true if \em groupName is a TIFF or Exif IFD, else false.
|
||||
This is used to differentiate between standard Exif IFDs
|
||||
and IFDs associated with the makernote.
|
||||
*/
|
||||
static bool isExifGroup(const std::string& groupName);
|
||||
/*!
|
||||
@brief Return true if \em groupName is a makernote group.
|
||||
*/
|
||||
static bool isMakerGroup(const std::string& groupName);
|
||||
/*!
|
||||
@brief Return true if \em groupName is a TIFF or Exif IFD, else false.
|
||||
This is used to differentiate between standard Exif IFDs
|
||||
and IFDs associated with the makernote.
|
||||
*/
|
||||
static bool isExifGroup(const std::string& groupName);
|
||||
|
||||
}; // class ExifTags
|
||||
}; // class ExifTags
|
||||
|
||||
/*!
|
||||
@brief Concrete keys for Exif metadata and access to Exif tag reference data.
|
||||
*/
|
||||
class EXIV2API ExifKey : public Key {
|
||||
public:
|
||||
//! Shortcut for an %ExifKey auto pointer.
|
||||
using UniquePtr = std::unique_ptr<ExifKey>;
|
||||
/*!
|
||||
@brief Concrete keys for Exif metadata and access to Exif tag reference data.
|
||||
*/
|
||||
class EXIV2API ExifKey : public Key {
|
||||
public:
|
||||
//! Shortcut for an %ExifKey auto pointer.
|
||||
using UniquePtr = std::unique_ptr<ExifKey>;
|
||||
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor to create an Exif key from a key string.
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor to create an Exif key from a key string.
|
||||
|
||||
@param key The key string.
|
||||
@throw Error if the first part of the key is not '<b>Exif</b>' or
|
||||
the remaining parts of the key cannot be parsed and
|
||||
converted to a group name and tag name.
|
||||
*/
|
||||
explicit ExifKey(const std::string& key);
|
||||
/*!
|
||||
@brief Constructor to create an Exif key from the tag number and
|
||||
group name.
|
||||
@param tag The tag value
|
||||
@param groupName The name of the group, i.e., the second part of
|
||||
the Exif key.
|
||||
@throw Error if the key cannot be constructed from the tag number
|
||||
and group name.
|
||||
*/
|
||||
ExifKey(uint16_t tag, const std::string& groupName);
|
||||
/*!
|
||||
@brief Constructor to create an Exif key from a TagInfo instance.
|
||||
@param ti The TagInfo instance
|
||||
@throw Error if the key cannot be constructed from the tag number
|
||||
and group name.
|
||||
*/
|
||||
explicit ExifKey(const TagInfo& ti);
|
||||
@param key The key string.
|
||||
@throw Error if the first part of the key is not '<b>Exif</b>' or
|
||||
the remaining parts of the key cannot be parsed and
|
||||
converted to a group name and tag name.
|
||||
*/
|
||||
explicit ExifKey(const std::string& key);
|
||||
/*!
|
||||
@brief Constructor to create an Exif key from the tag number and
|
||||
group name.
|
||||
@param tag The tag value
|
||||
@param groupName The name of the group, i.e., the second part of
|
||||
the Exif key.
|
||||
@throw Error if the key cannot be constructed from the tag number
|
||||
and group name.
|
||||
*/
|
||||
ExifKey(uint16_t tag, const std::string& groupName);
|
||||
/*!
|
||||
@brief Constructor to create an Exif key from a TagInfo instance.
|
||||
@param ti The TagInfo instance
|
||||
@throw Error if the key cannot be constructed from the tag number
|
||||
and group name.
|
||||
*/
|
||||
explicit ExifKey(const TagInfo& ti);
|
||||
|
||||
//! Copy constructor
|
||||
ExifKey(const ExifKey& rhs);
|
||||
//! Destructor
|
||||
~ExifKey() override;
|
||||
//@}
|
||||
//! Copy constructor
|
||||
ExifKey(const ExifKey& rhs);
|
||||
//! Destructor
|
||||
~ExifKey() override;
|
||||
//@}
|
||||
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
/*!
|
||||
@brief Assignment operator.
|
||||
*/
|
||||
ExifKey& operator=(const ExifKey& rhs);
|
||||
//! Set the index.
|
||||
void setIdx(int idx);
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
/*!
|
||||
@brief Assignment operator.
|
||||
*/
|
||||
ExifKey& operator=(const ExifKey& rhs);
|
||||
//! Set the index.
|
||||
void setIdx(int idx);
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string key() const override;
|
||||
const char* familyName() const override;
|
||||
std::string groupName() const override;
|
||||
//! Return the IFD id as an integer. (Do not use, this is meant for library internal use.)
|
||||
int ifdId() const;
|
||||
std::string tagName() const override;
|
||||
uint16_t tag() const override;
|
||||
std::string tagLabel() const override;
|
||||
//! Return the tag description.
|
||||
std::string tagDesc() const; // Todo: should be in the base class
|
||||
//! Return the default type id for this tag.
|
||||
TypeId defaultTypeId() const; // Todo: should be in the base class
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string key() const override;
|
||||
const char* familyName() const override;
|
||||
std::string groupName() const override;
|
||||
//! Return the IFD id as an integer. (Do not use, this is meant for library internal use.)
|
||||
int ifdId() const;
|
||||
std::string tagName() const override;
|
||||
uint16_t tag() const override;
|
||||
std::string tagLabel() const override;
|
||||
//! Return the tag description.
|
||||
std::string tagDesc() const; // Todo: should be in the base class
|
||||
//! Return the default type id for this tag.
|
||||
TypeId defaultTypeId() const; // Todo: should be in the base class
|
||||
|
||||
UniquePtr clone() const;
|
||||
//! Return the index (unique id of this key within the original Exif data, 0 if not set)
|
||||
int idx() const;
|
||||
//@}
|
||||
UniquePtr clone() const;
|
||||
//! Return the index (unique id of this key within the original Exif data, 0 if not set)
|
||||
int idx() const;
|
||||
//@}
|
||||
|
||||
private:
|
||||
//! Internal virtual copy constructor.
|
||||
ExifKey* clone_() const override;
|
||||
private:
|
||||
//! Internal virtual copy constructor.
|
||||
ExifKey* clone_() const override;
|
||||
|
||||
// Pimpl idiom
|
||||
struct Impl;
|
||||
std::unique_ptr<Impl> p_;
|
||||
// Pimpl idiom
|
||||
struct Impl;
|
||||
std::unique_ptr<Impl> p_;
|
||||
|
||||
}; // class ExifKey
|
||||
}; // class ExifKey
|
||||
|
||||
// *****************************************************************************
|
||||
// free functions
|
||||
|
||||
//! Output operator for TagInfo
|
||||
EXIV2API std::ostream& operator<<(std::ostream& os, const TagInfo& ti);
|
||||
//! Output operator for TagInfo
|
||||
EXIV2API std::ostream& operator<<(std::ostream& os, const TagInfo& ti);
|
||||
|
||||
} // namespace Exiv2
|
||||
} // namespace Exiv2
|
||||
|
||||
#endif // #ifndef TAGS_HPP_
|
||||
#endif // #ifndef TAGS_HPP_
|
||||
|
||||
+70
-71
@@ -11,88 +11,87 @@
|
||||
// *****************************************************************************
|
||||
// namespace extensions
|
||||
namespace Exiv2 {
|
||||
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
|
||||
/*!
|
||||
@brief Class to access raw TARGA images. This is just a stub - we only
|
||||
read width and height.
|
||||
*/
|
||||
class EXIV2API TgaImage : public Image {
|
||||
public:
|
||||
//! @name NOT Implemented
|
||||
//@{
|
||||
//! Copy constructor
|
||||
TgaImage(const TgaImage& rhs) = delete;
|
||||
//! Assignment operator
|
||||
TgaImage& operator=(const TgaImage& rhs) = delete;
|
||||
//@}
|
||||
/*!
|
||||
@brief Class to access raw TARGA images. This is just a stub - we only
|
||||
read width and height.
|
||||
*/
|
||||
class EXIV2API TgaImage : public Image {
|
||||
public:
|
||||
//! @name NOT Implemented
|
||||
//@{
|
||||
//! Copy constructor
|
||||
TgaImage(const TgaImage& rhs) = delete;
|
||||
//! Assignment operator
|
||||
TgaImage& operator=(const TgaImage& rhs) = delete;
|
||||
//@}
|
||||
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor to open a Targa image. Since the
|
||||
constructor can not return a result, callers should check the
|
||||
good() method after object construction to determine success
|
||||
or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
*/
|
||||
explicit TgaImage(BasicIo::UniquePtr io);
|
||||
//@}
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor to open a Targa image. Since the
|
||||
constructor can not return a result, callers should check the
|
||||
good() method after object construction to determine success
|
||||
or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
*/
|
||||
explicit TgaImage(BasicIo::UniquePtr io);
|
||||
//@}
|
||||
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void readMetadata() override;
|
||||
/*!
|
||||
@brief Todo: Write metadata back to the image. This method is not
|
||||
yet(?) implemented. Calling it will throw an Error(ErrorCode::kerWritingImageFormatUnsupported).
|
||||
*/
|
||||
void writeMetadata() override;
|
||||
/*!
|
||||
@brief Todo: Not supported yet(?). Calling this function will throw
|
||||
an instance of Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setExifData(const ExifData& exifData) override;
|
||||
/*!
|
||||
@brief Todo: Not supported yet(?). Calling this function will throw
|
||||
an instance of Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setIptcData(const IptcData& iptcData) override;
|
||||
/*!
|
||||
@brief Not supported. Calling this function will throw an instance
|
||||
of Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setComment(std::string_view comment) override;
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void readMetadata() override;
|
||||
/*!
|
||||
@brief Todo: Write metadata back to the image. This method is not
|
||||
yet(?) implemented. Calling it will throw an Error(ErrorCode::kerWritingImageFormatUnsupported).
|
||||
*/
|
||||
void writeMetadata() override;
|
||||
/*!
|
||||
@brief Todo: Not supported yet(?). Calling this function will throw
|
||||
an instance of Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setExifData(const ExifData& exifData) override;
|
||||
/*!
|
||||
@brief Todo: Not supported yet(?). Calling this function will throw
|
||||
an instance of Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setIptcData(const IptcData& iptcData) override;
|
||||
/*!
|
||||
@brief Not supported. Calling this function will throw an instance
|
||||
of Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setComment(std::string_view comment) override;
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override;
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override;
|
||||
//@}
|
||||
|
||||
}; // class TgaImage
|
||||
}; // class TgaImage
|
||||
|
||||
// *****************************************************************************
|
||||
// template, inline and free functions
|
||||
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new TgaImage instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newTgaInstance(BasicIo::UniquePtr io, bool create);
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new TgaImage instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newTgaInstance(BasicIo::UniquePtr io, bool create);
|
||||
|
||||
//! Check if the file iIo is a Targa v2 image.
|
||||
EXIV2API bool isTgaType(BasicIo& iIo, bool advance);
|
||||
//! Check if the file iIo is a Targa v2 image.
|
||||
EXIV2API bool isTgaType(BasicIo& iIo, bool advance);
|
||||
|
||||
} // namespace Exiv2
|
||||
} // namespace Exiv2
|
||||
|
||||
#endif // #ifndef TGAIMAGE_HPP_
|
||||
#endif // #ifndef TGAIMAGE_HPP_
|
||||
|
||||
+130
-143
@@ -12,172 +12,159 @@
|
||||
// *****************************************************************************
|
||||
// namespace extensions
|
||||
namespace Exiv2 {
|
||||
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
|
||||
/*!
|
||||
@brief Class to access TIFF images. Exif metadata is
|
||||
supported directly, IPTC is read from the Exif data, if present.
|
||||
*/
|
||||
class EXIV2API TiffImage : public Image {
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor that can either open an existing TIFF image or create
|
||||
a new image from scratch. If a new image is to be created, any
|
||||
existing data is overwritten. Since the constructor can not return
|
||||
a result, callers should check the good() method after object
|
||||
construction to determine success or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
@param create Specifies if an existing image should be read (false)
|
||||
or if a new file should be created (true).
|
||||
*/
|
||||
TiffImage(BasicIo::UniquePtr io, bool create);
|
||||
//@}
|
||||
/*!
|
||||
@brief Class to access TIFF images. Exif metadata is
|
||||
supported directly, IPTC is read from the Exif data, if present.
|
||||
*/
|
||||
class EXIV2API TiffImage : public Image {
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor that can either open an existing TIFF image or create
|
||||
a new image from scratch. If a new image is to be created, any
|
||||
existing data is overwritten. Since the constructor can not return
|
||||
a result, callers should check the good() method after object
|
||||
construction to determine success or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
@param create Specifies if an existing image should be read (false)
|
||||
or if a new file should be created (true).
|
||||
*/
|
||||
TiffImage(BasicIo::UniquePtr io, bool create);
|
||||
//@}
|
||||
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void readMetadata() override;
|
||||
void writeMetadata() override;
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void readMetadata() override;
|
||||
void writeMetadata() override;
|
||||
|
||||
/*!
|
||||
@brief Print out the structure of image file.
|
||||
@throw Error if reading of the file fails or the image data is
|
||||
not valid (does not look like data of the specific image type).
|
||||
@warning This function is not thread safe and intended for exiv2 -p{S|R} as a file debugging aid
|
||||
*/
|
||||
void printStructure(std::ostream& out, PrintStructureOption option, int depth = 0) override;
|
||||
/*!
|
||||
@brief Print out the structure of image file.
|
||||
@throw Error if reading of the file fails or the image data is
|
||||
not valid (does not look like data of the specific image type).
|
||||
@warning This function is not thread safe and intended for exiv2 -p{S|R} as a file debugging aid
|
||||
*/
|
||||
void printStructure(std::ostream& out, PrintStructureOption option, int depth = 0) override;
|
||||
|
||||
/*!
|
||||
@brief Not supported. TIFF format does not contain a comment.
|
||||
Calling this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setComment(std::string_view comment) override;
|
||||
//@}
|
||||
/*!
|
||||
@brief Not supported. TIFF format does not contain a comment.
|
||||
Calling this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setComment(std::string_view comment) override;
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override;
|
||||
uint32_t pixelWidth() const override;
|
||||
uint32_t pixelHeight() const override;
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override;
|
||||
uint32_t pixelWidth() const override;
|
||||
uint32_t pixelHeight() const override;
|
||||
//@}
|
||||
|
||||
//! @name NOT Implemented
|
||||
//@{
|
||||
//! Copy constructor
|
||||
TiffImage(const TiffImage& rhs) = delete;
|
||||
//! Assignment operator
|
||||
TiffImage& operator=(const TiffImage& rhs) = delete;
|
||||
//@}
|
||||
//! @name NOT Implemented
|
||||
//@{
|
||||
//! Copy constructor
|
||||
TiffImage(const TiffImage& rhs) = delete;
|
||||
//! Assignment operator
|
||||
TiffImage& operator=(const TiffImage& rhs) = delete;
|
||||
//@}
|
||||
|
||||
private:
|
||||
//! @name Accessors
|
||||
//@{
|
||||
//! Return the group name of the group with the primary image.
|
||||
std::string primaryGroup() const;
|
||||
//@}
|
||||
private:
|
||||
//! @name Accessors
|
||||
//@{
|
||||
//! Return the group name of the group with the primary image.
|
||||
std::string primaryGroup() const;
|
||||
//@}
|
||||
|
||||
// DATA
|
||||
mutable std::string primaryGroup_; //!< The primary group
|
||||
mutable std::string mimeType_; //!< The MIME type
|
||||
mutable uint32_t pixelWidthPrimary_; //!< Width of the primary image in pixels
|
||||
mutable uint32_t pixelHeightPrimary_; //!< Height of the primary image in pixels
|
||||
// DATA
|
||||
mutable std::string primaryGroup_; //!< The primary group
|
||||
mutable std::string mimeType_; //!< The MIME type
|
||||
mutable uint32_t pixelWidthPrimary_; //!< Width of the primary image in pixels
|
||||
mutable uint32_t pixelHeightPrimary_; //!< Height of the primary image in pixels
|
||||
|
||||
}; // class TiffImage
|
||||
}; // class TiffImage
|
||||
|
||||
/*!
|
||||
@brief Stateless parser class for data in TIFF format. Images use this
|
||||
class to decode and encode TIFF data. It is a wrapper of the
|
||||
internal class Internal::TiffParserWorker.
|
||||
*/
|
||||
class EXIV2API TiffParser {
|
||||
public:
|
||||
/*!
|
||||
@brief Decode metadata from a buffer \em pData of length \em size
|
||||
with data in TIFF format to the provided metadata containers.
|
||||
/*!
|
||||
@brief Stateless parser class for data in TIFF format. Images use this
|
||||
class to decode and encode TIFF data. It is a wrapper of the
|
||||
internal class Internal::TiffParserWorker.
|
||||
*/
|
||||
class EXIV2API TiffParser {
|
||||
public:
|
||||
/*!
|
||||
@brief Decode metadata from a buffer \em pData of length \em size
|
||||
with data in TIFF format to the provided metadata containers.
|
||||
|
||||
@param exifData Exif metadata container.
|
||||
@param iptcData IPTC metadata container.
|
||||
@param xmpData XMP metadata container.
|
||||
@param pData Pointer to the data buffer. Must point to data in TIFF
|
||||
format; no checks are performed.
|
||||
@param size Length of the data buffer.
|
||||
@param exifData Exif metadata container.
|
||||
@param iptcData IPTC metadata container.
|
||||
@param xmpData XMP metadata container.
|
||||
@param pData Pointer to the data buffer. Must point to data in TIFF
|
||||
format; no checks are performed.
|
||||
@param size Length of the data buffer.
|
||||
|
||||
@return Byte order in which the data is encoded.
|
||||
*/
|
||||
static ByteOrder decode(
|
||||
ExifData& exifData,
|
||||
IptcData& iptcData,
|
||||
XmpData& xmpData,
|
||||
const byte* pData,
|
||||
size_t size
|
||||
);
|
||||
/*!
|
||||
@brief Encode metadata from the provided metadata to TIFF format.
|
||||
@return Byte order in which the data is encoded.
|
||||
*/
|
||||
static ByteOrder decode(ExifData& exifData, IptcData& iptcData, XmpData& xmpData, const byte* pData, size_t size);
|
||||
/*!
|
||||
@brief Encode metadata from the provided metadata to TIFF format.
|
||||
|
||||
The original binary image in the memory block \em pData, \em size is
|
||||
parsed and updated in-place if possible ("non-intrusive" writing).
|
||||
If that is not possible (e.g., if new tags were added), the entire
|
||||
TIFF structure is re-written to the \em io instance ("intrusive" writing).<br>
|
||||
The return value indicates which write method was used. If it is
|
||||
\c wmNonIntrusive, the original memory \em pData, \em size contains
|
||||
the result and nothing is written to \em io. If the return value is
|
||||
\c wmIntrusive, a new TIFF structure was created and written to
|
||||
\em io. The memory block \em pData, \em size may be partly updated
|
||||
in this case and should not be used anymore.
|
||||
The original binary image in the memory block \em pData, \em size is
|
||||
parsed and updated in-place if possible ("non-intrusive" writing).
|
||||
If that is not possible (e.g., if new tags were added), the entire
|
||||
TIFF structure is re-written to the \em io instance ("intrusive" writing).<br>
|
||||
The return value indicates which write method was used. If it is
|
||||
\c wmNonIntrusive, the original memory \em pData, \em size contains
|
||||
the result and nothing is written to \em io. If the return value is
|
||||
\c wmIntrusive, a new TIFF structure was created and written to
|
||||
\em io. The memory block \em pData, \em size may be partly updated
|
||||
in this case and should not be used anymore.
|
||||
|
||||
@note If there is no metadata to encode, i.e., all metadata
|
||||
containers are empty, then the return value is \c wmIntrusive
|
||||
and nothing is written to \em io, i.e., no TIFF header is written.
|
||||
@note If there is no metadata to encode, i.e., all metadata
|
||||
containers are empty, then the return value is \c wmIntrusive
|
||||
and nothing is written to \em io, i.e., no TIFF header is written.
|
||||
|
||||
@param io IO instance to write the binary image to in case of
|
||||
"intrusive" writing. Nothing is written to \em io in
|
||||
the case of "non-intrusive" writing.
|
||||
@param pData Pointer to the binary image data buffer. Must
|
||||
point to data in TIFF format; no checks are
|
||||
performed. Will be modified if "non-intrusive"
|
||||
writing is possible.
|
||||
@param size Length of the data buffer.
|
||||
@param byteOrder Byte order to use.
|
||||
@param exifData Exif metadata container.
|
||||
@param iptcData IPTC metadata container.
|
||||
@param xmpData XMP metadata container.
|
||||
@param io IO instance to write the binary image to in case of
|
||||
"intrusive" writing. Nothing is written to \em io in
|
||||
the case of "non-intrusive" writing.
|
||||
@param pData Pointer to the binary image data buffer. Must
|
||||
point to data in TIFF format; no checks are
|
||||
performed. Will be modified if "non-intrusive"
|
||||
writing is possible.
|
||||
@param size Length of the data buffer.
|
||||
@param byteOrder Byte order to use.
|
||||
@param exifData Exif metadata container.
|
||||
@param iptcData IPTC metadata container.
|
||||
@param xmpData XMP metadata container.
|
||||
|
||||
@return Write method used.
|
||||
*/
|
||||
static WriteMethod encode(BasicIo& io,
|
||||
const byte* pData,
|
||||
size_t size,
|
||||
ByteOrder byteOrder,
|
||||
const ExifData& exifData,
|
||||
const IptcData& iptcData,
|
||||
const XmpData& xmpData
|
||||
);
|
||||
@return Write method used.
|
||||
*/
|
||||
static WriteMethod encode(BasicIo& io, const byte* pData, size_t size, ByteOrder byteOrder, const ExifData& exifData,
|
||||
const IptcData& iptcData, const XmpData& xmpData);
|
||||
|
||||
}; // class TiffParser
|
||||
}; // class TiffParser
|
||||
|
||||
// *****************************************************************************
|
||||
// template, inline and free functions
|
||||
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new TiffImage instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newTiffInstance(BasicIo::UniquePtr io, bool create);
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new TiffImage instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newTiffInstance(BasicIo::UniquePtr io, bool create);
|
||||
|
||||
//! Check if the file iIo is a TIFF image.
|
||||
EXIV2API bool isTiffType(BasicIo& iIo, bool advance);
|
||||
//! Check if the file iIo is a TIFF image.
|
||||
EXIV2API bool isTiffType(BasicIo& iIo, bool advance);
|
||||
|
||||
} // namespace Exiv2
|
||||
} // namespace Exiv2
|
||||
|
||||
#endif // #ifndef TIFFIMAGE_HPP_
|
||||
#endif // #ifndef TIFFIMAGE_HPP_
|
||||
|
||||
+483
-469
@@ -29,511 +29,525 @@
|
||||
// *****************************************************************************
|
||||
// namespace extensions
|
||||
namespace Exiv2 {
|
||||
// *****************************************************************************
|
||||
// type definitions
|
||||
|
||||
// *****************************************************************************
|
||||
// type definitions
|
||||
//! 1 byte unsigned integer type.
|
||||
using byte = uint8_t;
|
||||
|
||||
//! 1 byte unsigned integer type.
|
||||
using byte = uint8_t;
|
||||
//! 8 byte unsigned rational type.
|
||||
using URational = std::pair<uint32_t, uint32_t>;
|
||||
//! 8 byte signed rational type.
|
||||
using Rational = std::pair<int32_t, int32_t>;
|
||||
|
||||
//! 8 byte unsigned rational type.
|
||||
using URational = std::pair<uint32_t, uint32_t>;
|
||||
//! 8 byte signed rational type.
|
||||
using Rational = std::pair<int32_t, int32_t>;
|
||||
//! Type to express the byte order (little or big endian)
|
||||
enum ByteOrder {
|
||||
invalidByteOrder,
|
||||
littleEndian,
|
||||
bigEndian,
|
||||
};
|
||||
|
||||
//! Type to express the byte order (little or big endian)
|
||||
enum ByteOrder {
|
||||
invalidByteOrder,
|
||||
littleEndian,
|
||||
bigEndian,
|
||||
};
|
||||
//! Type to indicate write method used by TIFF parsers
|
||||
enum WriteMethod {
|
||||
wmIntrusive,
|
||||
wmNonIntrusive,
|
||||
};
|
||||
|
||||
//! Type to indicate write method used by TIFF parsers
|
||||
enum WriteMethod {
|
||||
wmIntrusive,
|
||||
wmNonIntrusive,
|
||||
};
|
||||
//! An identifier for each type of metadata
|
||||
enum MetadataId {
|
||||
mdNone = 0,
|
||||
mdExif = 1,
|
||||
mdIptc = 2,
|
||||
mdComment = 4,
|
||||
mdXmp = 8,
|
||||
mdIccProfile = 16,
|
||||
};
|
||||
|
||||
//! An identifier for each type of metadata
|
||||
enum MetadataId {
|
||||
mdNone = 0,
|
||||
mdExif = 1,
|
||||
mdIptc = 2,
|
||||
mdComment = 4,
|
||||
mdXmp = 8,
|
||||
mdIccProfile = 16,
|
||||
};
|
||||
//! An identifier for each mode of metadata support
|
||||
enum AccessMode {
|
||||
amNone = 0,
|
||||
amRead = 1,
|
||||
amWrite = 2,
|
||||
amReadWrite = 3,
|
||||
};
|
||||
|
||||
//! An identifier for each mode of metadata support
|
||||
enum AccessMode {
|
||||
amNone = 0,
|
||||
amRead = 1,
|
||||
amWrite = 2,
|
||||
amReadWrite = 3,
|
||||
};
|
||||
/*!
|
||||
@brief %Exiv2 value type identifiers.
|
||||
|
||||
/*!
|
||||
@brief %Exiv2 value type identifiers.
|
||||
Used primarily as identifiers when creating %Exiv2 Value instances.
|
||||
See Value::create. 0x0000 to 0xffff are reserved for TIFF (Exif) types.
|
||||
*/
|
||||
enum TypeId {
|
||||
unsignedByte = 1, //!< Exif BYTE type, 8-bit unsigned integer.
|
||||
asciiString = 2, //!< Exif ASCII type, 8-bit byte.
|
||||
unsignedShort = 3, //!< Exif SHORT type, 16-bit (2-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.
|
||||
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.
|
||||
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.
|
||||
signedRational = 10, //!< Exif SRATIONAL type, two SLONGs: numerator and denominator of a fraction.
|
||||
tiffFloat = 11, //!< TIFF FLOAT type, single precision (4-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.
|
||||
unsignedLongLong = 16, //!< Exif LONG LONG type, 64-bit (8-byte) unsigned integer.
|
||||
signedLongLong = 17, //!< Exif LONG LONG type, 64-bit (8-byte) signed integer.
|
||||
tiffIfd8 = 18, //!< TIFF IFD type, 64-bit (8-byte) unsigned integer.
|
||||
string = 0x10000, //!< IPTC string type.
|
||||
date = 0x10001, //!< IPTC date type.
|
||||
time = 0x10002, //!< IPTC time type.
|
||||
comment = 0x10003, //!< %Exiv2 type for the Exif user comment.
|
||||
directory = 0x10004, //!< %Exiv2 type for a CIFF directory.
|
||||
xmpText = 0x10005, //!< XMP text type.
|
||||
xmpAlt = 0x10006, //!< XMP alternative type.
|
||||
xmpBag = 0x10007, //!< XMP bag type.
|
||||
xmpSeq = 0x10008, //!< XMP sequence type.
|
||||
langAlt = 0x10009, //!< XMP language alternative type.
|
||||
invalidTypeId = 0x1fffe, //!< Invalid type id.
|
||||
lastTypeId = 0x1ffff //!< Last type id.
|
||||
};
|
||||
|
||||
Used primarily as identifiers when creating %Exiv2 Value instances.
|
||||
See Value::create. 0x0000 to 0xffff are reserved for TIFF (Exif) types.
|
||||
*/
|
||||
enum TypeId {
|
||||
unsignedByte = 1, //!< Exif BYTE type, 8-bit unsigned integer.
|
||||
asciiString = 2, //!< Exif ASCII type, 8-bit byte.
|
||||
unsignedShort = 3, //!< Exif SHORT type, 16-bit (2-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.
|
||||
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.
|
||||
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.
|
||||
signedRational = 10, //!< Exif SRATIONAL type, two SLONGs: numerator and denominator of a fraction.
|
||||
tiffFloat = 11, //!< TIFF FLOAT type, single precision (4-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.
|
||||
unsignedLongLong = 16, //!< Exif LONG LONG type, 64-bit (8-byte) unsigned integer.
|
||||
signedLongLong = 17, //!< Exif LONG LONG type, 64-bit (8-byte) signed integer.
|
||||
tiffIfd8 = 18, //!< TIFF IFD type, 64-bit (8-byte) unsigned integer.
|
||||
string = 0x10000, //!< IPTC string type.
|
||||
date = 0x10001, //!< IPTC date type.
|
||||
time = 0x10002, //!< IPTC time type.
|
||||
comment = 0x10003, //!< %Exiv2 type for the Exif user comment.
|
||||
directory = 0x10004, //!< %Exiv2 type for a CIFF directory.
|
||||
xmpText = 0x10005, //!< XMP text type.
|
||||
xmpAlt = 0x10006, //!< XMP alternative type.
|
||||
xmpBag = 0x10007, //!< XMP bag type.
|
||||
xmpSeq = 0x10008, //!< XMP sequence type.
|
||||
langAlt = 0x10009, //!< XMP language alternative type.
|
||||
invalidTypeId = 0x1fffe, //!< Invalid type id.
|
||||
lastTypeId = 0x1ffff //!< Last type id.
|
||||
};
|
||||
//! Container for binary data
|
||||
using Blob = std::vector<byte>;
|
||||
|
||||
//! Container for binary data
|
||||
using Blob = std::vector<byte>;
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
//! Type information lookup functions. Implemented as a static class.
|
||||
class EXIV2API TypeInfo {
|
||||
public:
|
||||
//! Prevent construction: not implemented.
|
||||
TypeInfo() = delete;
|
||||
//! Prevent copy-construction: not implemented.
|
||||
TypeInfo(const TypeInfo& rhs) = delete;
|
||||
//! Prevent assignment: not implemented.
|
||||
TypeInfo& operator=(const TypeInfo& rhs) = delete;
|
||||
|
||||
//! Type information lookup functions. Implemented as a static class.
|
||||
class EXIV2API TypeInfo {
|
||||
public:
|
||||
//! Prevent construction: not implemented.
|
||||
TypeInfo() = delete;
|
||||
//! Prevent copy-construction: not implemented.
|
||||
TypeInfo(const TypeInfo& rhs) = delete;
|
||||
//! Prevent assignment: not implemented.
|
||||
TypeInfo& operator=(const TypeInfo& rhs) = delete;
|
||||
//! Return the name of the type, 0 if unknown.
|
||||
static const char* typeName(TypeId typeId);
|
||||
//! Return the type id for a type name
|
||||
static TypeId typeId(const std::string& typeName);
|
||||
//! Return the size in bytes of one element of this type
|
||||
static size_t typeSize(TypeId typeId);
|
||||
};
|
||||
|
||||
//! Return the name of the type, 0 if unknown.
|
||||
static const char* typeName(TypeId typeId);
|
||||
//! Return the type id for a type name
|
||||
static TypeId typeId(const std::string& typeName);
|
||||
//! Return the size in bytes of one element of this type
|
||||
static size_t typeSize(TypeId typeId);
|
||||
};
|
||||
/*!
|
||||
@brief Utility class containing a character array. All it does is to take
|
||||
care of memory allocation and deletion. Its primary use is meant to
|
||||
be as a stack variable in functions that need a temporary data
|
||||
buffer.
|
||||
*/
|
||||
struct EXIV2API DataBuf {
|
||||
//! @name Creators
|
||||
//@{
|
||||
//! Default constructor
|
||||
DataBuf() = default;
|
||||
//! Constructor with an initial buffer size
|
||||
explicit DataBuf(size_t size);
|
||||
//! Constructor, copies an existing buffer
|
||||
DataBuf(const byte* pData, size_t size);
|
||||
//@}
|
||||
|
||||
/*!
|
||||
@brief Utility class containing a character array. All it does is to take
|
||||
care of memory allocation and deletion. Its primary use is meant to
|
||||
be as a stack variable in functions that need a temporary data
|
||||
buffer.
|
||||
*/
|
||||
struct EXIV2API DataBuf {
|
||||
//! @name Creators
|
||||
//@{
|
||||
//! Default constructor
|
||||
DataBuf() = default;
|
||||
//! Constructor with an initial buffer size
|
||||
explicit DataBuf(size_t size);
|
||||
//! Constructor, copies an existing buffer
|
||||
DataBuf(const byte* pData, size_t size);
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
/*!
|
||||
@brief Allocate a data buffer of at least the given size. Note that if
|
||||
the requested \em size is less than the current buffer size, no
|
||||
new memory is allocated and the buffer size doesn't change.
|
||||
*/
|
||||
void alloc(size_t size);
|
||||
/*!
|
||||
@brief Resize the buffer. Existing data is preserved (like std::realloc()).
|
||||
*/
|
||||
void resize(size_t size);
|
||||
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
/*!
|
||||
@brief Allocate a data buffer of at least the given size. Note that if
|
||||
the requested \em size is less than the current buffer size, no
|
||||
new memory is allocated and the buffer size doesn't change.
|
||||
*/
|
||||
void alloc(size_t size);
|
||||
/*!
|
||||
@brief Resize the buffer. Existing data is preserved (like std::realloc()).
|
||||
*/
|
||||
void resize(size_t size);
|
||||
//! Reset value
|
||||
void reset();
|
||||
//@}
|
||||
|
||||
//! Reset value
|
||||
void reset();
|
||||
//@}
|
||||
using iterator = std::vector<byte>::iterator;
|
||||
using const_iterator = std::vector<byte>::const_iterator;
|
||||
|
||||
using iterator = std::vector<byte>::iterator;
|
||||
using const_iterator = std::vector<byte>::const_iterator;
|
||||
inline iterator begin() noexcept {
|
||||
return pData_.begin();
|
||||
}
|
||||
inline const_iterator cbegin() const noexcept {
|
||||
return pData_.cbegin();
|
||||
}
|
||||
inline iterator end() noexcept {
|
||||
return pData_.end();
|
||||
}
|
||||
inline const_iterator cend() const noexcept {
|
||||
return pData_.end();
|
||||
}
|
||||
|
||||
inline iterator begin() noexcept { return pData_.begin(); }
|
||||
inline const_iterator cbegin() const noexcept { return pData_.cbegin(); }
|
||||
inline iterator end() noexcept { return pData_.end(); }
|
||||
inline const_iterator cend() const noexcept { return pData_.end(); }
|
||||
size_t size() const {
|
||||
return pData_.size();
|
||||
}
|
||||
|
||||
size_t size() const { return pData_.size(); }
|
||||
uint8_t read_uint8(size_t offset) const;
|
||||
void write_uint8(size_t offset, uint8_t x);
|
||||
|
||||
uint8_t read_uint8(size_t offset) const;
|
||||
void write_uint8(size_t offset, uint8_t x);
|
||||
uint16_t read_uint16(size_t offset, ByteOrder byteOrder) const;
|
||||
void write_uint16(size_t offset, uint16_t x, ByteOrder byteOrder);
|
||||
|
||||
uint16_t read_uint16(size_t offset, ByteOrder byteOrder) const;
|
||||
void write_uint16(size_t offset, uint16_t x, ByteOrder byteOrder);
|
||||
uint32_t read_uint32(size_t offset, ByteOrder byteOrder) const;
|
||||
void write_uint32(size_t offset, uint32_t x, ByteOrder byteOrder);
|
||||
|
||||
uint32_t read_uint32(size_t offset, ByteOrder byteOrder) const;
|
||||
void write_uint32(size_t offset, uint32_t x, ByteOrder byteOrder);
|
||||
uint64_t read_uint64(size_t offset, ByteOrder byteOrder) const;
|
||||
void write_uint64(size_t offset, uint64_t x, ByteOrder byteOrder);
|
||||
|
||||
uint64_t read_uint64(size_t offset, ByteOrder byteOrder) const;
|
||||
void write_uint64(size_t offset, uint64_t x, ByteOrder byteOrder);
|
||||
//! Copy bytes into the buffer (starting at address &pData_[offset]).
|
||||
void copyBytes(size_t offset, const void* buf, size_t bufsize);
|
||||
|
||||
//! Copy bytes into the buffer (starting at address &pData_[offset]).
|
||||
void copyBytes(size_t offset, const void* buf, size_t bufsize);
|
||||
//! Equivalent to: memcmp(&pData_[offset], buf, bufsize)
|
||||
int cmpBytes(size_t offset, const void* buf, size_t bufsize) const;
|
||||
|
||||
//! Equivalent to: memcmp(&pData_[offset], buf, bufsize)
|
||||
int cmpBytes(size_t offset, const void* buf, size_t bufsize) const;
|
||||
//! Returns a data pointer.
|
||||
byte* data(size_t offset = 0);
|
||||
|
||||
//! Returns a data pointer.
|
||||
byte* data(size_t offset = 0);
|
||||
//! Returns a (read-only) data pointer.
|
||||
const byte* c_data(size_t offset = 0) const;
|
||||
|
||||
//! Returns a (read-only) data pointer.
|
||||
const byte* c_data(size_t offset = 0) const;
|
||||
//! Returns a (read-only) C-style string pointer.
|
||||
const char* c_str(size_t offset = 0) const;
|
||||
|
||||
//! Returns a (read-only) C-style string pointer.
|
||||
const char* c_str(size_t offset = 0) const;
|
||||
bool empty() const {
|
||||
return pData_.empty();
|
||||
}
|
||||
|
||||
bool empty() const { return pData_.empty(); }
|
||||
private:
|
||||
std::vector<byte> pData_;
|
||||
};
|
||||
|
||||
private:
|
||||
std::vector<byte> pData_;
|
||||
};
|
||||
/*!
|
||||
* @brief Create a new Slice from a DataBuf given the bounds.
|
||||
*
|
||||
* @param[in] begin, end Bounds of the new Slice. `begin` must be smaller
|
||||
* than `end` and both must not be larger than LONG_MAX.
|
||||
* @param[in] buf The DataBuf from which' data the Slice will be
|
||||
* constructed
|
||||
*
|
||||
* @throw std::invalid_argument when `end` is larger than `LONG_MAX` or
|
||||
* anything that the constructor of @ref Slice throws
|
||||
*/
|
||||
EXIV2API Slice<byte*> makeSlice(DataBuf& buf, size_t begin, size_t end);
|
||||
|
||||
/*!
|
||||
* @brief Create a new Slice from a DataBuf given the bounds.
|
||||
*
|
||||
* @param[in] begin, end Bounds of the new Slice. `begin` must be smaller
|
||||
* than `end` and both must not be larger than LONG_MAX.
|
||||
* @param[in] buf The DataBuf from which' data the Slice will be
|
||||
* constructed
|
||||
*
|
||||
* @throw std::invalid_argument when `end` is larger than `LONG_MAX` or
|
||||
* anything that the constructor of @ref Slice throws
|
||||
*/
|
||||
EXIV2API Slice<byte*> makeSlice(DataBuf& buf, size_t begin, size_t end);
|
||||
//! Overload of makeSlice for `const DataBuf`, returning an immutable Slice
|
||||
EXIV2API Slice<const byte*> makeSlice(const DataBuf& buf, size_t begin, size_t end);
|
||||
|
||||
//! Overload of makeSlice for `const DataBuf`, returning an immutable Slice
|
||||
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
|
||||
EXIV2API uint16_t getUShort(const byte* buf, ByteOrder byteOrder);
|
||||
//! Read a 2 byte unsigned short value from a Slice
|
||||
template <typename T>
|
||||
uint16_t getUShort(const Slice<T>& buf, ByteOrder byteOrder) {
|
||||
if (byteOrder == littleEndian) {
|
||||
return static_cast<byte>(buf.at(1)) << 8 | static_cast<byte>(buf.at(0));
|
||||
}
|
||||
return static_cast<byte>(buf.at(0)) << 8 | static_cast<byte>(buf.at(1));
|
||||
}
|
||||
|
||||
//! Read a 2 byte unsigned short value from the data buffer
|
||||
EXIV2API uint16_t getUShort(const byte* buf, ByteOrder byteOrder);
|
||||
//! Read a 2 byte unsigned short value from a Slice
|
||||
template <typename T>
|
||||
uint16_t getUShort(const Slice<T>& buf, ByteOrder byteOrder) {
|
||||
if (byteOrder == littleEndian) {
|
||||
return static_cast<byte>(buf.at(1)) << 8 | static_cast<byte>(buf.at(0));
|
||||
}
|
||||
return static_cast<byte>(buf.at(0)) << 8 | static_cast<byte>(buf.at(1));
|
||||
//! Read a 4 byte unsigned long value from the data buffer
|
||||
EXIV2API uint32_t getULong(const byte* buf, ByteOrder byteOrder);
|
||||
//! Read a 8 byte unsigned long value from the data buffer
|
||||
EXIV2API uint64_t getULongLong(const byte* buf, ByteOrder byteOrder);
|
||||
//! Read an 8 byte unsigned rational value from the data buffer
|
||||
EXIV2API URational getURational(const byte* buf, ByteOrder byteOrder);
|
||||
//! Read a 2 byte signed short value from the data buffer
|
||||
EXIV2API int16_t getShort(const byte* buf, ByteOrder byteOrder);
|
||||
//! Read a 4 byte signed long value from the data buffer
|
||||
EXIV2API int32_t getLong(const byte* buf, ByteOrder byteOrder);
|
||||
//! Read an 8 byte signed rational value from the data buffer
|
||||
EXIV2API Rational getRational(const byte* buf, ByteOrder byteOrder);
|
||||
//! Read a 4 byte single precision floating point value (IEEE 754 binary32) from the data buffer
|
||||
EXIV2API float getFloat(const byte* buf, ByteOrder byteOrder);
|
||||
//! Read an 8 byte double precision floating point value (IEEE 754 binary64) from the data buffer
|
||||
EXIV2API double getDouble(const byte* buf, ByteOrder byteOrder);
|
||||
|
||||
//! Output operator for our fake rational
|
||||
EXIV2API std::ostream& operator<<(std::ostream& os, const Rational& r);
|
||||
//! Input operator for our fake rational
|
||||
EXIV2API std::istream& operator>>(std::istream& is, Rational& r);
|
||||
//! Output operator for our fake unsigned rational
|
||||
EXIV2API std::ostream& operator<<(std::ostream& os, const URational& r);
|
||||
//! Input operator for our fake unsigned rational
|
||||
EXIV2API std::istream& operator>>(std::istream& is, URational& r);
|
||||
|
||||
/*!
|
||||
@brief Convert an unsigned short to data, write the data to the buffer,
|
||||
return number of bytes written.
|
||||
*/
|
||||
EXIV2API long us2Data(byte* buf, uint16_t s, ByteOrder byteOrder);
|
||||
/*!
|
||||
@brief Convert an unsigned long to data, write the data to the buffer,
|
||||
return number of bytes written.
|
||||
*/
|
||||
EXIV2API long ul2Data(byte* buf, uint32_t l, ByteOrder byteOrder);
|
||||
/*!
|
||||
@brief Convert an uint64_t to data, write the data to the buffer,
|
||||
return number of bytes written.
|
||||
*/
|
||||
EXIV2API long ull2Data(byte* buf, uint64_t l, ByteOrder byteOrder);
|
||||
/*!
|
||||
@brief Convert an unsigned rational to data, write the data to the buffer,
|
||||
return number of bytes written.
|
||||
*/
|
||||
EXIV2API long ur2Data(byte* buf, URational l, ByteOrder byteOrder);
|
||||
/*!
|
||||
@brief Convert a signed short to data, write the data to the buffer,
|
||||
return number of bytes written.
|
||||
*/
|
||||
EXIV2API long s2Data(byte* buf, int16_t s, ByteOrder byteOrder);
|
||||
/*!
|
||||
@brief Convert a signed long to data, write the data to the buffer,
|
||||
return number of bytes written.
|
||||
*/
|
||||
EXIV2API long l2Data(byte* buf, int32_t l, ByteOrder byteOrder);
|
||||
/*!
|
||||
@brief Convert a signed rational to data, write the data to the buffer,
|
||||
return number of bytes written.
|
||||
*/
|
||||
EXIV2API long r2Data(byte* buf, Rational l, ByteOrder byteOrder);
|
||||
/*!
|
||||
@brief Convert a single precision floating point (IEEE 754 binary32) float
|
||||
to data, write the data to the buffer, return number of bytes written.
|
||||
*/
|
||||
EXIV2API long f2Data(byte* buf, float f, ByteOrder byteOrder);
|
||||
/*!
|
||||
@brief Convert a double precision floating point (IEEE 754 binary64) double
|
||||
to data, write the data to the buffer, return number of bytes written.
|
||||
*/
|
||||
EXIV2API long d2Data(byte* buf, double d, ByteOrder byteOrder);
|
||||
|
||||
/*!
|
||||
@brief Print len bytes from buf in hex and ASCII format to the given
|
||||
stream, prefixed with the position in the buffer adjusted by
|
||||
offset.
|
||||
*/
|
||||
EXIV2API void hexdump(std::ostream& os, const byte* buf, size_t len, size_t offset = 0);
|
||||
|
||||
/*!
|
||||
@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
|
||||
digits is allowed and all are checked.
|
||||
*/
|
||||
EXIV2API bool isHex(const std::string& str, size_t size = 0, const std::string& prefix = "");
|
||||
|
||||
/*!
|
||||
@brief Converts a string in the form "%Y:%m:%d %H:%M:%S", e.g.,
|
||||
"2007:05:24 12:31:55" to broken down time format,
|
||||
returns 0 if successful, else 1.
|
||||
*/
|
||||
EXIV2API int exifTime(const char* buf, struct tm* tm);
|
||||
|
||||
/*!
|
||||
@brief Translate a string using the gettext framework. This wrapper hides
|
||||
all the implementation details from the interface.
|
||||
*/
|
||||
EXIV2API const char* exvGettext(const char* str);
|
||||
|
||||
/*!
|
||||
@brief Return a \em int64_t set to the value represented by \em s.
|
||||
|
||||
Besides strings that represent \em int64_t values, the function also
|
||||
handles \em float, \em Rational and boolean
|
||||
(see also: stringTo(const std::string& s, bool& ok)).
|
||||
|
||||
@param s String to parse
|
||||
@param ok Output variable indicating the success of the operation.
|
||||
@return Returns the \em int64_t value represented by \em s and sets \em ok
|
||||
to \c true if the conversion was successful or \c false if not.
|
||||
*/
|
||||
EXIV2API int64_t parseInt64(const std::string& s, bool& ok);
|
||||
|
||||
/*!
|
||||
@brief Return a \em uint32_t set to the value represented by \em s.
|
||||
|
||||
Besides strings that represent \em uint32_t values, the function also
|
||||
handles \em float, \em Rational and boolean
|
||||
(see also: stringTo(const std::string& s, bool& ok)).
|
||||
|
||||
@param s String to parse
|
||||
@param ok Output variable indicating the success of the operation.
|
||||
@return Returns the \em uint32_t value represented by \em s and sets \em ok
|
||||
to \c true if the conversion was successful or \c false if not.
|
||||
*/
|
||||
EXIV2API uint32_t parseUint32(const std::string& s, bool& ok);
|
||||
|
||||
/*!
|
||||
@brief Return a \em float set to the value represented by \em s.
|
||||
|
||||
Besides strings that represent \em float values, the function also
|
||||
handles \em long, \em Rational and boolean
|
||||
(see also: stringTo(const std::string& s, bool& ok)).
|
||||
|
||||
@param s String to parse
|
||||
@param ok Output variable indicating the success of the operation.
|
||||
@return Returns the \em float value represented by \em s and sets \em ok
|
||||
to \c true if the conversion was successful or \c false if not.
|
||||
*/
|
||||
EXIV2API float parseFloat(const std::string& s, bool& ok);
|
||||
|
||||
/*!
|
||||
@brief Return a \em Rational set to the value represented by \em s.
|
||||
|
||||
Besides strings that represent \em Rational values, the function also
|
||||
handles \em long, \em float and boolean
|
||||
(see also: stringTo(const std::string& s, bool& ok)).
|
||||
Uses floatToRationalCast(float f) if the string can be parsed into a
|
||||
\em float.
|
||||
|
||||
@param s String to parse
|
||||
@param ok Output variable indicating the success of the operation.
|
||||
@return Returns the \em Rational value represented by \em s and sets \em ok
|
||||
to \c true if the conversion was successful or \c false if not.
|
||||
*/
|
||||
EXIV2API Rational parseRational(const std::string& s, bool& ok);
|
||||
|
||||
/*!
|
||||
@brief Very simple conversion of a \em float to a \em Rational.
|
||||
|
||||
Test it with the values that you expect and check the implementation
|
||||
to see if this is really what you want!
|
||||
*/
|
||||
EXIV2API Rational floatToRationalCast(float f);
|
||||
|
||||
// *****************************************************************************
|
||||
// template and inline definitions
|
||||
|
||||
/*!
|
||||
@brief Find an element that matches \em key in the array \em src.
|
||||
|
||||
Designed to be used with lookup tables as shown in the example below.
|
||||
Requires a %Key structure (ideally in the array) and a comparison operator
|
||||
to compare a key with an array element. The size of the array is
|
||||
determined automagically. Thanks to Stephan Broennimann for this nifty
|
||||
implementation.
|
||||
|
||||
@code
|
||||
struct Bar {
|
||||
int i;
|
||||
int k;
|
||||
const char* data;
|
||||
|
||||
struct Key;
|
||||
bool operator==(const Bar::Key& rhs) const;
|
||||
};
|
||||
|
||||
struct Bar::Key {
|
||||
Key(int a, int b) : i(a), k(b) {}
|
||||
int i;
|
||||
int k;
|
||||
};
|
||||
|
||||
bool Bar::operator==(const Bar::Key& key) const // definition
|
||||
{
|
||||
return i == key.i && k == key.k;
|
||||
}
|
||||
|
||||
const Bar bars[] = {
|
||||
{ 1, 1, "bar data 1" },
|
||||
{ 1, 2, "bar data 2" },
|
||||
{ 1, 3, "bar data 3" }
|
||||
};
|
||||
|
||||
int main ( void ) {
|
||||
const Bar* bar = find(bars, Bar::Key(1, 3));
|
||||
if (bar) std::cout << bar->data << "\n";
|
||||
else std::cout << "Key not found.\n";
|
||||
return 0;
|
||||
}
|
||||
@endcode
|
||||
*/
|
||||
template <typename T, typename K, int N>
|
||||
const T* find(T (&src)[N], const K& key) {
|
||||
const T* rc = std::find(src, src + N, key);
|
||||
return rc == src + N ? nullptr : rc;
|
||||
}
|
||||
|
||||
//! Utility function to convert the argument of any type to a string
|
||||
template <typename T>
|
||||
std::string toString(const T& arg) {
|
||||
std::ostringstream os;
|
||||
os << arg;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief Utility function to convert a string to a value of type \c T.
|
||||
|
||||
The string representation of the value must match that recognized by
|
||||
the input operator for \c T for this function to succeed.
|
||||
|
||||
@param s String to convert
|
||||
@param ok Output variable indicating the success of the operation.
|
||||
@return Returns the converted value and sets \em ok to \c true if the
|
||||
conversion was successful or \c false if not.
|
||||
*/
|
||||
template <typename T>
|
||||
T stringTo(const std::string& s, bool& ok) {
|
||||
std::istringstream is(s);
|
||||
T tmp = T();
|
||||
ok = bool(is >> tmp);
|
||||
std::string rest;
|
||||
is >> std::skipws >> rest;
|
||||
if (!rest.empty())
|
||||
ok = false;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief Specialization of stringTo(const std::string& s, bool& ok) for \em bool.
|
||||
|
||||
Handles the same string values as the XMP SDK. Converts the string to lowercase
|
||||
and returns \c true if it is "true", "t" or "1", and \c false if it is
|
||||
"false", "f" or "0".
|
||||
*/
|
||||
template <>
|
||||
bool stringTo<bool>(const std::string& s, bool& ok);
|
||||
|
||||
/*!
|
||||
@brief Return the greatest common denominator of n and m.
|
||||
(Implementation from Boost rational.hpp)
|
||||
|
||||
@note We use n and m as temporaries in this function, so there is no
|
||||
value in using const IntType& as we would only need to make a copy
|
||||
anyway...
|
||||
*/
|
||||
template <typename IntType>
|
||||
IntType gcd(IntType n, IntType m) {
|
||||
// Avoid repeated construction
|
||||
IntType zero(0);
|
||||
|
||||
// This is abs() - given the existence of broken compilers with Koenig
|
||||
// lookup issues and other problems, I code this explicitly. (Remember,
|
||||
// IntType may be a user-defined type).
|
||||
if (n < zero) {
|
||||
if (n == std::numeric_limits<IntType>::min()) {
|
||||
n = std::numeric_limits<IntType>::max();
|
||||
} else {
|
||||
n = -n;
|
||||
}
|
||||
}
|
||||
if (m < zero)
|
||||
m = -m;
|
||||
|
||||
//! Read a 4 byte unsigned long value from the data buffer
|
||||
EXIV2API uint32_t getULong(const byte* buf, ByteOrder byteOrder);
|
||||
//! Read a 8 byte unsigned long value from the data buffer
|
||||
EXIV2API uint64_t getULongLong(const byte* buf, ByteOrder byteOrder);
|
||||
//! Read an 8 byte unsigned rational value from the data buffer
|
||||
EXIV2API URational getURational(const byte* buf, ByteOrder byteOrder);
|
||||
//! Read a 2 byte signed short value from the data buffer
|
||||
EXIV2API int16_t getShort(const byte* buf, ByteOrder byteOrder);
|
||||
//! Read a 4 byte signed long value from the data buffer
|
||||
EXIV2API int32_t getLong(const byte* buf, ByteOrder byteOrder);
|
||||
//! Read an 8 byte signed rational value from the data buffer
|
||||
EXIV2API Rational getRational(const byte* buf, ByteOrder byteOrder);
|
||||
//! Read a 4 byte single precision floating point value (IEEE 754 binary32) from the data buffer
|
||||
EXIV2API float getFloat(const byte* buf, ByteOrder byteOrder);
|
||||
//! Read an 8 byte double precision floating point value (IEEE 754 binary64) from the data buffer
|
||||
EXIV2API double getDouble(const byte* buf, ByteOrder byteOrder);
|
||||
|
||||
//! Output operator for our fake rational
|
||||
EXIV2API std::ostream& operator<<(std::ostream& os, const Rational& r);
|
||||
//! Input operator for our fake rational
|
||||
EXIV2API std::istream& operator>>(std::istream& is, Rational& r);
|
||||
//! Output operator for our fake unsigned rational
|
||||
EXIV2API std::ostream& operator<<(std::ostream& os, const URational& r);
|
||||
//! Input operator for our fake unsigned rational
|
||||
EXIV2API std::istream& operator>>(std::istream& is, URational& r);
|
||||
|
||||
/*!
|
||||
@brief Convert an unsigned short to data, write the data to the buffer,
|
||||
return number of bytes written.
|
||||
*/
|
||||
EXIV2API long us2Data(byte* buf, uint16_t s, ByteOrder byteOrder);
|
||||
/*!
|
||||
@brief Convert an unsigned long to data, write the data to the buffer,
|
||||
return number of bytes written.
|
||||
*/
|
||||
EXIV2API long ul2Data(byte* buf, uint32_t l, ByteOrder byteOrder);
|
||||
/*!
|
||||
@brief Convert an uint64_t to data, write the data to the buffer,
|
||||
return number of bytes written.
|
||||
*/
|
||||
EXIV2API long ull2Data(byte* buf, uint64_t l, ByteOrder byteOrder);
|
||||
/*!
|
||||
@brief Convert an unsigned rational to data, write the data to the buffer,
|
||||
return number of bytes written.
|
||||
*/
|
||||
EXIV2API long ur2Data(byte* buf, URational l, ByteOrder byteOrder);
|
||||
/*!
|
||||
@brief Convert a signed short to data, write the data to the buffer,
|
||||
return number of bytes written.
|
||||
*/
|
||||
EXIV2API long s2Data(byte* buf, int16_t s, ByteOrder byteOrder);
|
||||
/*!
|
||||
@brief Convert a signed long to data, write the data to the buffer,
|
||||
return number of bytes written.
|
||||
*/
|
||||
EXIV2API long l2Data(byte* buf, int32_t l, ByteOrder byteOrder);
|
||||
/*!
|
||||
@brief Convert a signed rational to data, write the data to the buffer,
|
||||
return number of bytes written.
|
||||
*/
|
||||
EXIV2API long r2Data(byte* buf, Rational l, ByteOrder byteOrder);
|
||||
/*!
|
||||
@brief Convert a single precision floating point (IEEE 754 binary32) float
|
||||
to data, write the data to the buffer, return number of bytes written.
|
||||
*/
|
||||
EXIV2API long f2Data(byte* buf, float f, ByteOrder byteOrder);
|
||||
/*!
|
||||
@brief Convert a double precision floating point (IEEE 754 binary64) double
|
||||
to data, write the data to the buffer, return number of bytes written.
|
||||
*/
|
||||
EXIV2API long d2Data(byte* buf, double d, ByteOrder byteOrder);
|
||||
|
||||
/*!
|
||||
@brief Print len bytes from buf in hex and ASCII format to the given
|
||||
stream, prefixed with the position in the buffer adjusted by
|
||||
offset.
|
||||
*/
|
||||
EXIV2API void hexdump(std::ostream& os, const byte* buf, size_t len, size_t offset = 0);
|
||||
|
||||
/*!
|
||||
@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
|
||||
digits is allowed and all are checked.
|
||||
*/
|
||||
EXIV2API bool isHex(const std::string& str, size_t size = 0, const std::string& prefix = "");
|
||||
|
||||
/*!
|
||||
@brief Converts a string in the form "%Y:%m:%d %H:%M:%S", e.g.,
|
||||
"2007:05:24 12:31:55" to broken down time format,
|
||||
returns 0 if successful, else 1.
|
||||
*/
|
||||
EXIV2API int exifTime(const char* buf, struct tm* tm);
|
||||
|
||||
/*!
|
||||
@brief Translate a string using the gettext framework. This wrapper hides
|
||||
all the implementation details from the interface.
|
||||
*/
|
||||
EXIV2API const char* exvGettext(const char* str);
|
||||
|
||||
/*!
|
||||
@brief Return a \em int64_t set to the value represented by \em s.
|
||||
|
||||
Besides strings that represent \em int64_t values, the function also
|
||||
handles \em float, \em Rational and boolean
|
||||
(see also: stringTo(const std::string& s, bool& ok)).
|
||||
|
||||
@param s String to parse
|
||||
@param ok Output variable indicating the success of the operation.
|
||||
@return Returns the \em int64_t value represented by \em s and sets \em ok
|
||||
to \c true if the conversion was successful or \c false if not.
|
||||
*/
|
||||
EXIV2API int64_t parseInt64(const std::string& s, bool& ok);
|
||||
|
||||
/*!
|
||||
@brief Return a \em uint32_t set to the value represented by \em s.
|
||||
|
||||
Besides strings that represent \em uint32_t values, the function also
|
||||
handles \em float, \em Rational and boolean
|
||||
(see also: stringTo(const std::string& s, bool& ok)).
|
||||
|
||||
@param s String to parse
|
||||
@param ok Output variable indicating the success of the operation.
|
||||
@return Returns the \em uint32_t value represented by \em s and sets \em ok
|
||||
to \c true if the conversion was successful or \c false if not.
|
||||
*/
|
||||
EXIV2API uint32_t parseUint32(const std::string& s, bool& ok);
|
||||
|
||||
/*!
|
||||
@brief Return a \em float set to the value represented by \em s.
|
||||
|
||||
Besides strings that represent \em float values, the function also
|
||||
handles \em long, \em Rational and boolean
|
||||
(see also: stringTo(const std::string& s, bool& ok)).
|
||||
|
||||
@param s String to parse
|
||||
@param ok Output variable indicating the success of the operation.
|
||||
@return Returns the \em float value represented by \em s and sets \em ok
|
||||
to \c true if the conversion was successful or \c false if not.
|
||||
*/
|
||||
EXIV2API float parseFloat(const std::string& s, bool& ok);
|
||||
|
||||
/*!
|
||||
@brief Return a \em Rational set to the value represented by \em s.
|
||||
|
||||
Besides strings that represent \em Rational values, the function also
|
||||
handles \em long, \em float and boolean
|
||||
(see also: stringTo(const std::string& s, bool& ok)).
|
||||
Uses floatToRationalCast(float f) if the string can be parsed into a
|
||||
\em float.
|
||||
|
||||
@param s String to parse
|
||||
@param ok Output variable indicating the success of the operation.
|
||||
@return Returns the \em Rational value represented by \em s and sets \em ok
|
||||
to \c true if the conversion was successful or \c false if not.
|
||||
*/
|
||||
EXIV2API Rational parseRational(const std::string& s, bool& ok);
|
||||
|
||||
/*!
|
||||
@brief Very simple conversion of a \em float to a \em Rational.
|
||||
|
||||
Test it with the values that you expect and check the implementation
|
||||
to see if this is really what you want!
|
||||
*/
|
||||
EXIV2API Rational floatToRationalCast(float f);
|
||||
|
||||
// *****************************************************************************
|
||||
// template and inline definitions
|
||||
|
||||
/*!
|
||||
@brief Find an element that matches \em key in the array \em src.
|
||||
|
||||
Designed to be used with lookup tables as shown in the example below.
|
||||
Requires a %Key structure (ideally in the array) and a comparison operator
|
||||
to compare a key with an array element. The size of the array is
|
||||
determined automagically. Thanks to Stephan Broennimann for this nifty
|
||||
implementation.
|
||||
|
||||
@code
|
||||
struct Bar {
|
||||
int i;
|
||||
int k;
|
||||
const char* data;
|
||||
|
||||
struct Key;
|
||||
bool operator==(const Bar::Key& rhs) const;
|
||||
};
|
||||
|
||||
struct Bar::Key {
|
||||
Key(int a, int b) : i(a), k(b) {}
|
||||
int i;
|
||||
int k;
|
||||
};
|
||||
|
||||
bool Bar::operator==(const Bar::Key& key) const // definition
|
||||
{
|
||||
return i == key.i && k == key.k;
|
||||
}
|
||||
|
||||
const Bar bars[] = {
|
||||
{ 1, 1, "bar data 1" },
|
||||
{ 1, 2, "bar data 2" },
|
||||
{ 1, 3, "bar data 3" }
|
||||
};
|
||||
|
||||
int main ( void ) {
|
||||
const Bar* bar = find(bars, Bar::Key(1, 3));
|
||||
if (bar) std::cout << bar->data << "\n";
|
||||
else std::cout << "Key not found.\n";
|
||||
return 0;
|
||||
}
|
||||
@endcode
|
||||
*/
|
||||
template <typename T, typename K, int N>
|
||||
const T* find(T (&src)[N], const K& key) {
|
||||
const T* rc = std::find(src, src + N, key);
|
||||
return rc == src + N ? nullptr : rc;
|
||||
}
|
||||
|
||||
//! Utility function to convert the argument of any type to a string
|
||||
template <typename T>
|
||||
std::string toString(const T& arg) {
|
||||
std::ostringstream os;
|
||||
os << arg;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief Utility function to convert a string to a value of type \c T.
|
||||
|
||||
The string representation of the value must match that recognized by
|
||||
the input operator for \c T for this function to succeed.
|
||||
|
||||
@param s String to convert
|
||||
@param ok Output variable indicating the success of the operation.
|
||||
@return Returns the converted value and sets \em ok to \c true if the
|
||||
conversion was successful or \c false if not.
|
||||
*/
|
||||
template <typename T>
|
||||
T stringTo(const std::string& s, bool& ok) {
|
||||
std::istringstream is(s);
|
||||
T tmp = T();
|
||||
ok = bool(is >> tmp);
|
||||
std::string rest;
|
||||
is >> std::skipws >> rest;
|
||||
if (!rest.empty()) ok = false;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief Specialization of stringTo(const std::string& s, bool& ok) for \em bool.
|
||||
|
||||
Handles the same string values as the XMP SDK. Converts the string to lowercase
|
||||
and returns \c true if it is "true", "t" or "1", and \c false if it is
|
||||
"false", "f" or "0".
|
||||
*/
|
||||
template <>
|
||||
bool stringTo<bool>(const std::string& s, bool& ok);
|
||||
|
||||
/*!
|
||||
@brief Return the greatest common denominator of n and m.
|
||||
(Implementation from Boost rational.hpp)
|
||||
|
||||
@note We use n and m as temporaries in this function, so there is no
|
||||
value in using const IntType& as we would only need to make a copy
|
||||
anyway...
|
||||
*/
|
||||
template <typename IntType>
|
||||
IntType gcd(IntType n, IntType m) {
|
||||
// Avoid repeated construction
|
||||
IntType zero(0);
|
||||
|
||||
// This is abs() - given the existence of broken compilers with Koenig
|
||||
// lookup issues and other problems, I code this explicitly. (Remember,
|
||||
// IntType may be a user-defined type).
|
||||
if (n < zero) {
|
||||
if (n == std::numeric_limits<IntType>::min()) {
|
||||
n = std::numeric_limits<IntType>::max();
|
||||
} else {
|
||||
n = -n;
|
||||
}
|
||||
}
|
||||
if (m < zero)
|
||||
m = -m;
|
||||
|
||||
// As n and m are now positive, we can be sure that %= returns a
|
||||
// positive value (the standard guarantees this for built-in types,
|
||||
// and we require it of user-defined types).
|
||||
for (;;) {
|
||||
if (m == zero) return n;
|
||||
n %= m;
|
||||
if (n == zero) return m;
|
||||
m %= n;
|
||||
}
|
||||
}
|
||||
// As n and m are now positive, we can be sure that %= returns a
|
||||
// positive value (the standard guarantees this for built-in types,
|
||||
// and we require it of user-defined types).
|
||||
for (;;) {
|
||||
if (m == zero)
|
||||
return n;
|
||||
n %= m;
|
||||
if (n == zero)
|
||||
return m;
|
||||
m %= n;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Exiv2
|
||||
|
||||
|
||||
+1655
-1664
File diff suppressed because it is too large
Load Diff
+34
-39
@@ -9,21 +9,19 @@
|
||||
// *****************************************************************************
|
||||
// included header files
|
||||
// + standard includes
|
||||
#include <vector>
|
||||
#include <regex>
|
||||
#include <vector>
|
||||
|
||||
/*!
|
||||
@brief Make an integer version number for comparison from a major, minor and
|
||||
a patch version number.
|
||||
*/
|
||||
#define EXIV2_MAKE_VERSION(major,minor,patch) \
|
||||
(((major) << 16) | ((minor) << 8) | (patch))
|
||||
#define EXIV2_MAKE_VERSION(major, minor, patch) (((major) << 16) | ((minor) << 8) | (patch))
|
||||
/*!
|
||||
@brief The %Exiv2 version number of the library used at compile-time as
|
||||
an integer number for easy comparison.
|
||||
*/
|
||||
#define EXIV2_VERSION \
|
||||
EXIV2_MAKE_VERSION(EXIV2_MAJOR_VERSION,EXIV2_MINOR_VERSION,EXIV2_PATCH_VERSION)
|
||||
#define EXIV2_VERSION EXIV2_MAKE_VERSION(EXIV2_MAJOR_VERSION, EXIV2_MINOR_VERSION, EXIV2_PATCH_VERSION)
|
||||
|
||||
/*!
|
||||
@brief Macro to test the version the %Exiv2 library at compile-time.
|
||||
@@ -68,45 +66,42 @@
|
||||
#endif
|
||||
@endcode
|
||||
*/
|
||||
#define EXIV2_TEST_VERSION(major,minor,patch) \
|
||||
( EXIV2_VERSION >= EXIV2_MAKE_VERSION(major,minor,patch) )
|
||||
#define EXIV2_TEST_VERSION(major, minor, patch) (EXIV2_VERSION >= EXIV2_MAKE_VERSION(major, minor, patch))
|
||||
|
||||
// *****************************************************************************
|
||||
// namespace extensions
|
||||
namespace Exiv2 {
|
||||
/*!
|
||||
@brief Return the version of %Exiv2 available at runtime as an integer.
|
||||
*/
|
||||
EXIV2API int versionNumber();
|
||||
/*!
|
||||
@brief Return the version string Example: "0.25.0" (major.minor.patch)
|
||||
*/
|
||||
EXIV2API std::string versionString();
|
||||
/*!
|
||||
@brief Return the version of %Exiv2 as hex string of fixed length 6.
|
||||
*/
|
||||
EXIV2API std::string versionNumberHexString();
|
||||
/*!
|
||||
@brief Return the version of %Exiv2 available at runtime as an integer.
|
||||
*/
|
||||
EXIV2API int versionNumber();
|
||||
/*!
|
||||
@brief Return the version string Example: "0.25.0" (major.minor.patch)
|
||||
*/
|
||||
EXIV2API std::string versionString();
|
||||
/*!
|
||||
@brief Return the version of %Exiv2 as hex string of fixed length 6.
|
||||
*/
|
||||
EXIV2API std::string versionNumberHexString();
|
||||
|
||||
/*!
|
||||
@brief Return the version of %Exiv2 as "C" string eg "0.27.0.2".
|
||||
*/
|
||||
EXIV2API const char* version();
|
||||
/*!
|
||||
@brief Return the version of %Exiv2 as "C" string eg "0.27.0.2".
|
||||
*/
|
||||
EXIV2API const char* version();
|
||||
|
||||
/*!
|
||||
@brief Test the version of the available %Exiv2 library at runtime. Return
|
||||
true if it is the same as or newer than the passed-in version.
|
||||
/*!
|
||||
@brief Test the version of the available %Exiv2 library at runtime. Return
|
||||
true if it is the same as or newer than the passed-in version.
|
||||
|
||||
Versions are denoted using a triplet of integers: \em major.minor.patch .
|
||||
The fourth version number is designated a "tweak" an used by Release Candidates
|
||||
*/
|
||||
EXIV2API bool testVersion(int major, int minor, int patch);
|
||||
/*!
|
||||
@brief dumpLibraryInfo implements the exiv2 option --version --verbose
|
||||
used by exiv2 test suite to inspect libraries loaded at run-time
|
||||
*/
|
||||
EXIV2API void dumpLibraryInfo(std::ostream& os,const std::vector<std::regex>& keys);
|
||||
} // namespace Exiv2
|
||||
Versions are denoted using a triplet of integers: \em major.minor.patch .
|
||||
The fourth version number is designated a "tweak" an used by Release Candidates
|
||||
*/
|
||||
EXIV2API bool testVersion(int major, int minor, int patch);
|
||||
/*!
|
||||
@brief dumpLibraryInfo implements the exiv2 option --version --verbose
|
||||
used by exiv2 test suite to inspect libraries loaded at run-time
|
||||
*/
|
||||
EXIV2API void dumpLibraryInfo(std::ostream& os, const std::vector<std::regex>& keys);
|
||||
} // namespace Exiv2
|
||||
|
||||
|
||||
|
||||
#endif // VERSION_HPP_
|
||||
#endif // VERSION_HPP_
|
||||
|
||||
+76
-80
@@ -12,100 +12,96 @@
|
||||
// *****************************************************************************
|
||||
// namespace extensions
|
||||
namespace Exiv2 {
|
||||
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
|
||||
/*!
|
||||
@brief Class to access WEBP video files.
|
||||
*/
|
||||
class EXIV2API WebPImage:public Image
|
||||
{
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor for a WebP video. Since the constructor
|
||||
can not return a result, callers should check the good() method
|
||||
after object construction to determine success or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
*/
|
||||
explicit WebPImage(BasicIo::UniquePtr io);
|
||||
//@}
|
||||
/*!
|
||||
@brief Class to access WEBP video files.
|
||||
*/
|
||||
class EXIV2API WebPImage : public Image {
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor for a WebP video. Since the constructor
|
||||
can not return a result, callers should check the good() method
|
||||
after object construction to determine success or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
*/
|
||||
explicit WebPImage(BasicIo::UniquePtr io);
|
||||
//@}
|
||||
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void readMetadata() override;
|
||||
void writeMetadata() override;
|
||||
void printStructure(std::ostream& out, PrintStructureOption option, int depth) override;
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void readMetadata() override;
|
||||
void writeMetadata() override;
|
||||
void printStructure(std::ostream& out, PrintStructureOption option, int depth) override;
|
||||
//@}
|
||||
|
||||
/*!
|
||||
@brief Not supported. Calling this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setComment(std::string_view comment) override;
|
||||
void setIptcData(const IptcData& /*iptcData*/) override;
|
||||
/*!
|
||||
@brief Not supported. Calling this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setComment(std::string_view comment) override;
|
||||
void setIptcData(const IptcData& /*iptcData*/) override;
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override;
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override;
|
||||
//@}
|
||||
|
||||
//! Copy constructor
|
||||
WebPImage(const WebPImage& rhs) = delete;
|
||||
//! Assignment operator
|
||||
WebPImage& operator=(const WebPImage& rhs) = delete;
|
||||
//@}
|
||||
//! Copy constructor
|
||||
WebPImage(const WebPImage& rhs) = delete;
|
||||
//! Assignment operator
|
||||
WebPImage& operator=(const WebPImage& rhs) = delete;
|
||||
//@}
|
||||
|
||||
private:
|
||||
void doWriteMetadata(BasicIo& outIo);
|
||||
//! @name NOT Implemented
|
||||
//@{
|
||||
static long getHeaderOffset(const byte* data, long data_size, const byte* header, long header_size);
|
||||
static bool equalsWebPTag(Exiv2::DataBuf& buf, const char* str);
|
||||
void debugPrintHex(byte *data, long size);
|
||||
void decodeChunks(long filesize);
|
||||
void inject_VP8X(BasicIo& iIo, bool has_xmp, bool has_exif,
|
||||
bool has_alpha, bool has_icc, int width,
|
||||
int height);
|
||||
private:
|
||||
void doWriteMetadata(BasicIo& outIo);
|
||||
//! @name NOT Implemented
|
||||
//@{
|
||||
static long getHeaderOffset(const byte* data, long data_size, const byte* header, long header_size);
|
||||
static bool equalsWebPTag(Exiv2::DataBuf& buf, const char* str);
|
||||
void debugPrintHex(byte* data, long size);
|
||||
void decodeChunks(long filesize);
|
||||
void inject_VP8X(BasicIo& iIo, bool has_xmp, bool has_exif, bool has_alpha, bool has_icc, int width, int height);
|
||||
|
||||
static const byte WEBP_PAD_ODD;
|
||||
static const int WEBP_TAG_SIZE;
|
||||
static const int WEBP_VP8X_ICC_BIT;
|
||||
static const int WEBP_VP8X_ALPHA_BIT;
|
||||
static const int WEBP_VP8X_EXIF_BIT;
|
||||
static const int WEBP_VP8X_XMP_BIT;
|
||||
static const char* const WEBP_CHUNK_HEADER_VP8X;
|
||||
static const char* const WEBP_CHUNK_HEADER_VP8L;
|
||||
static const char* const WEBP_CHUNK_HEADER_VP8;
|
||||
static const char* const WEBP_CHUNK_HEADER_ANMF;
|
||||
static const char* const WEBP_CHUNK_HEADER_ANIM;
|
||||
static const char* const WEBP_CHUNK_HEADER_ICCP;
|
||||
static const char* const WEBP_CHUNK_HEADER_EXIF;
|
||||
static const char* const WEBP_CHUNK_HEADER_XMP;
|
||||
static const byte WEBP_PAD_ODD;
|
||||
static const int WEBP_TAG_SIZE;
|
||||
static const int WEBP_VP8X_ICC_BIT;
|
||||
static const int WEBP_VP8X_ALPHA_BIT;
|
||||
static const int WEBP_VP8X_EXIF_BIT;
|
||||
static const int WEBP_VP8X_XMP_BIT;
|
||||
static const char* const WEBP_CHUNK_HEADER_VP8X;
|
||||
static const char* const WEBP_CHUNK_HEADER_VP8L;
|
||||
static const char* const WEBP_CHUNK_HEADER_VP8;
|
||||
static const char* const WEBP_CHUNK_HEADER_ANMF;
|
||||
static const char* const WEBP_CHUNK_HEADER_ANIM;
|
||||
static const char* const WEBP_CHUNK_HEADER_ICCP;
|
||||
static const char* const WEBP_CHUNK_HEADER_EXIF;
|
||||
static const char* const WEBP_CHUNK_HEADER_XMP;
|
||||
|
||||
}; //Class WebPImage
|
||||
}; // Class WebPImage
|
||||
|
||||
// *****************************************************************************
|
||||
// template, inline and free functions
|
||||
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new WebPImage instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newWebPInstance(BasicIo::UniquePtr io, bool create);
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new WebPImage instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newWebPInstance(BasicIo::UniquePtr io, bool create);
|
||||
|
||||
//! Check if the file iIo is a WebP Video.
|
||||
EXIV2API bool isWebPType(BasicIo& iIo, bool advance);
|
||||
//! Check if the file iIo is a WebP Video.
|
||||
EXIV2API bool isWebPType(BasicIo& iIo, bool advance);
|
||||
|
||||
} // namespace Exiv2
|
||||
} // namespace Exiv2
|
||||
|
||||
#endif // WEBPIMAGE_HPP
|
||||
#endif // WEBPIMAGE_HPP
|
||||
|
||||
+352
-349
@@ -13,406 +13,409 @@
|
||||
// *****************************************************************************
|
||||
// namespace extensions
|
||||
namespace Exiv2 {
|
||||
|
||||
// *****************************************************************************
|
||||
// class declarations
|
||||
class ExifData;
|
||||
class ExifData;
|
||||
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
|
||||
/*!
|
||||
@brief Information related to an XMP property. An XMP metadatum consists
|
||||
of an XmpKey and a Value and provides methods to manipulate these.
|
||||
*/
|
||||
class EXIV2API Xmpdatum : public Metadatum {
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor for new tags created by an application. The
|
||||
%Xmpdatum is created from a key / value pair. %Xmpdatum
|
||||
copies (clones) the value if one is provided. Alternatively, a
|
||||
program can create an 'empty' %Xmpdatum with only a key and
|
||||
set the value using setValue().
|
||||
/*!
|
||||
@brief Information related to an XMP property. An XMP metadatum consists
|
||||
of an XmpKey and a Value and provides methods to manipulate these.
|
||||
*/
|
||||
class EXIV2API Xmpdatum : public Metadatum {
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor for new tags created by an application. The
|
||||
%Xmpdatum is created from a key / value pair. %Xmpdatum
|
||||
copies (clones) the value if one is provided. Alternatively, a
|
||||
program can create an 'empty' %Xmpdatum with only a key and
|
||||
set the value using setValue().
|
||||
|
||||
@param key The key of the %Xmpdatum.
|
||||
@param pValue Pointer to a %Xmpdatum value.
|
||||
@throw Error if the key cannot be parsed and converted
|
||||
to a known schema namespace prefix and property name.
|
||||
*/
|
||||
explicit Xmpdatum(const XmpKey& key, const Value* pValue = nullptr);
|
||||
//! Copy constructor
|
||||
Xmpdatum(const Xmpdatum& rhs);
|
||||
//! Destructor
|
||||
~Xmpdatum() override;
|
||||
//@}
|
||||
@param key The key of the %Xmpdatum.
|
||||
@param pValue Pointer to a %Xmpdatum value.
|
||||
@throw Error if the key cannot be parsed and converted
|
||||
to a known schema namespace prefix and property name.
|
||||
*/
|
||||
explicit Xmpdatum(const XmpKey& key, const Value* pValue = nullptr);
|
||||
//! Copy constructor
|
||||
Xmpdatum(const Xmpdatum& rhs);
|
||||
//! Destructor
|
||||
~Xmpdatum() override;
|
||||
//@}
|
||||
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
//! Assignment operator
|
||||
Xmpdatum& operator=(const Xmpdatum& rhs);
|
||||
/*!
|
||||
@brief Assign std::string \em value to the %Xmpdatum.
|
||||
Calls setValue(const std::string&).
|
||||
*/
|
||||
Xmpdatum& operator=(const std::string& value);
|
||||
/*!
|
||||
@brief Assign const char* \em value to the %Xmpdatum.
|
||||
Calls operator=(const std::string&).
|
||||
*/
|
||||
Xmpdatum& operator=(const char* value);
|
||||
/*!
|
||||
@brief Assign a boolean \em value to the %Xmpdatum.
|
||||
Translates the value to a string "true" or "false".
|
||||
*/
|
||||
Xmpdatum& operator=(const bool& value);
|
||||
/*!
|
||||
@brief Assign a \em value of any type with an output operator
|
||||
to the %Xmpdatum. Calls operator=(const std::string&).
|
||||
*/
|
||||
template<typename T>
|
||||
Xmpdatum& operator=(const T& value);
|
||||
/*!
|
||||
@brief Assign Value \em value to the %Xmpdatum.
|
||||
Calls setValue(const Value*).
|
||||
*/
|
||||
Xmpdatum& operator=(const Value& value);
|
||||
void setValue(const Value* pValue) override;
|
||||
/*!
|
||||
@brief Set the value to the string \em value. Uses Value::read(const
|
||||
std::string&). If the %Xmpdatum does not have a Value yet,
|
||||
then a %Value of the correct type for this %Xmpdatum is
|
||||
created. If the key is unknown, a XmpTextValue is used as
|
||||
default. Return 0 if the value was read successfully.
|
||||
*/
|
||||
int setValue(const std::string& value) override;
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
//! Assignment operator
|
||||
Xmpdatum& operator=(const Xmpdatum& rhs);
|
||||
/*!
|
||||
@brief Assign std::string \em value to the %Xmpdatum.
|
||||
Calls setValue(const std::string&).
|
||||
*/
|
||||
Xmpdatum& operator=(const std::string& value);
|
||||
/*!
|
||||
@brief Assign const char* \em value to the %Xmpdatum.
|
||||
Calls operator=(const std::string&).
|
||||
*/
|
||||
Xmpdatum& operator=(const char* value);
|
||||
/*!
|
||||
@brief Assign a boolean \em value to the %Xmpdatum.
|
||||
Translates the value to a string "true" or "false".
|
||||
*/
|
||||
Xmpdatum& operator=(const bool& value);
|
||||
/*!
|
||||
@brief Assign a \em value of any type with an output operator
|
||||
to the %Xmpdatum. Calls operator=(const std::string&).
|
||||
*/
|
||||
template <typename T>
|
||||
Xmpdatum& operator=(const T& value);
|
||||
/*!
|
||||
@brief Assign Value \em value to the %Xmpdatum.
|
||||
Calls setValue(const Value*).
|
||||
*/
|
||||
Xmpdatum& operator=(const Value& value);
|
||||
void setValue(const Value* pValue) override;
|
||||
/*!
|
||||
@brief Set the value to the string \em value. Uses Value::read(const
|
||||
std::string&). If the %Xmpdatum does not have a Value yet,
|
||||
then a %Value of the correct type for this %Xmpdatum is
|
||||
created. If the key is unknown, a XmpTextValue is used as
|
||||
default. Return 0 if the value was read successfully.
|
||||
*/
|
||||
int setValue(const std::string& value) override;
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
//! Not implemented. Calling this method will raise an exception.
|
||||
size_t copy(byte* buf, ByteOrder byteOrder) const override;
|
||||
std::ostream& write(std::ostream& os, const ExifData* pMetadata = nullptr) const override;
|
||||
/*!
|
||||
@brief Return the key of the Xmpdatum. The key is of the form
|
||||
'<b>Xmp</b>.prefix.property'. Note however that the
|
||||
key is not necessarily unique, i.e., an XmpData object may
|
||||
contain multiple metadata with the same key.
|
||||
*/
|
||||
std::string key() const override;
|
||||
const char* familyName() const override;
|
||||
//! Return the (preferred) schema namespace prefix.
|
||||
std::string groupName() const override;
|
||||
//! Return the property name.
|
||||
std::string tagName() const override;
|
||||
std::string tagLabel() const override;
|
||||
//! Properties don't have a tag number. Return 0.
|
||||
uint16_t tag() const override;
|
||||
TypeId typeId() const override;
|
||||
const char* typeName() const override;
|
||||
// Todo: Remove this method from the baseclass
|
||||
//! The Exif typeSize doesn't make sense here. Return 0.
|
||||
size_t typeSize() const override;
|
||||
size_t count() const override;
|
||||
size_t size() const override;
|
||||
std::string toString() const override;
|
||||
std::string toString(size_t n) const override;
|
||||
int64_t toInt64(size_t n = 0) const override;
|
||||
float toFloat(size_t n = 0) const override;
|
||||
Rational toRational(size_t n = 0) const override;
|
||||
Value::UniquePtr getValue() const override;
|
||||
const Value& value() const override;
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
//! Not implemented. Calling this method will raise an exception.
|
||||
size_t copy(byte* buf, ByteOrder byteOrder) const override;
|
||||
std::ostream& write(std::ostream& os, const ExifData* pMetadata = nullptr) const override;
|
||||
/*!
|
||||
@brief Return the key of the Xmpdatum. The key is of the form
|
||||
'<b>Xmp</b>.prefix.property'. Note however that the
|
||||
key is not necessarily unique, i.e., an XmpData object may
|
||||
contain multiple metadata with the same key.
|
||||
*/
|
||||
std::string key() const override;
|
||||
const char* familyName() const override;
|
||||
//! Return the (preferred) schema namespace prefix.
|
||||
std::string groupName() const override;
|
||||
//! Return the property name.
|
||||
std::string tagName() const override;
|
||||
std::string tagLabel() const override;
|
||||
//! Properties don't have a tag number. Return 0.
|
||||
uint16_t tag() const override;
|
||||
TypeId typeId() const override;
|
||||
const char* typeName() const override;
|
||||
// Todo: Remove this method from the baseclass
|
||||
//! The Exif typeSize doesn't make sense here. Return 0.
|
||||
size_t typeSize() const override;
|
||||
size_t count() const override;
|
||||
size_t size() const override;
|
||||
std::string toString() const override;
|
||||
std::string toString(size_t n) const override;
|
||||
int64_t toInt64(size_t n = 0) const override;
|
||||
float toFloat(size_t n = 0) const override;
|
||||
Rational toRational(size_t n = 0) const override;
|
||||
Value::UniquePtr getValue() const override;
|
||||
const Value& value() const override;
|
||||
//@}
|
||||
|
||||
private:
|
||||
// Pimpl idiom
|
||||
struct Impl;
|
||||
std::unique_ptr<Impl> p_;
|
||||
private:
|
||||
// Pimpl idiom
|
||||
struct Impl;
|
||||
std::unique_ptr<Impl> p_;
|
||||
|
||||
}; // class Xmpdatum
|
||||
}; // class Xmpdatum
|
||||
|
||||
//! Container type to hold all metadata
|
||||
using XmpMetadata = std::vector<Xmpdatum>;
|
||||
//! Container type to hold all metadata
|
||||
using XmpMetadata = std::vector<Xmpdatum>;
|
||||
|
||||
/*!
|
||||
@brief A container for XMP data. This is a top-level class of
|
||||
the %Exiv2 library.
|
||||
/*!
|
||||
@brief A container for XMP data. This is a top-level class of
|
||||
the %Exiv2 library.
|
||||
|
||||
Provide high-level access to the XMP data of an image:
|
||||
- read XMP information from an XML block
|
||||
- access metadata through keys and standard C++ iterators
|
||||
- add, modify and delete metadata
|
||||
- serialize XMP data to an XML block
|
||||
*/
|
||||
class EXIV2API XmpData {
|
||||
public:
|
||||
//! Default constructor
|
||||
XmpData() = default;
|
||||
Provide high-level access to the XMP data of an image:
|
||||
- read XMP information from an XML block
|
||||
- access metadata through keys and standard C++ iterators
|
||||
- add, modify and delete metadata
|
||||
- serialize XMP data to an XML block
|
||||
*/
|
||||
class EXIV2API XmpData {
|
||||
public:
|
||||
//! Default constructor
|
||||
XmpData() = default;
|
||||
|
||||
//! XmpMetadata iterator type
|
||||
using iterator = XmpMetadata::iterator;
|
||||
//! XmpMetadata const iterator type
|
||||
using const_iterator = XmpMetadata::const_iterator;
|
||||
//! XmpMetadata iterator type
|
||||
using iterator = XmpMetadata::iterator;
|
||||
//! XmpMetadata const iterator type
|
||||
using const_iterator = XmpMetadata::const_iterator;
|
||||
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
/*!
|
||||
@brief Returns a reference to the %Xmpdatum that is associated with a
|
||||
particular \em key. If %XmpData does not already contain such
|
||||
an %Xmpdatum, operator[] adds object \em Xmpdatum(key).
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
/*!
|
||||
@brief Returns a reference to the %Xmpdatum that is associated with a
|
||||
particular \em key. If %XmpData does not already contain such
|
||||
an %Xmpdatum, operator[] adds object \em Xmpdatum(key).
|
||||
|
||||
@note Since operator[] might insert a new element, it can't be a const
|
||||
member function.
|
||||
*/
|
||||
Xmpdatum& operator[](const std::string& key);
|
||||
/*!
|
||||
@brief Add an %Xmpdatum from the supplied key and value pair. This
|
||||
method copies (clones) the value.
|
||||
@return 0 if successful.
|
||||
*/
|
||||
int add(const XmpKey& key, const Value* value);
|
||||
/*!
|
||||
@brief Add a copy of the Xmpdatum to the XMP metadata.
|
||||
@return 0 if successful.
|
||||
*/
|
||||
int add(const Xmpdatum& xmpdatum);
|
||||
/*
|
||||
@brief Delete the Xmpdatum at iterator position pos, return the
|
||||
position of the next Xmpdatum.
|
||||
@note Since operator[] might insert a new element, it can't be a const
|
||||
member function.
|
||||
*/
|
||||
Xmpdatum& operator[](const std::string& key);
|
||||
/*!
|
||||
@brief Add an %Xmpdatum from the supplied key and value pair. This
|
||||
method copies (clones) the value.
|
||||
@return 0 if successful.
|
||||
*/
|
||||
int add(const XmpKey& key, const Value* value);
|
||||
/*!
|
||||
@brief Add a copy of the Xmpdatum to the XMP metadata.
|
||||
@return 0 if successful.
|
||||
*/
|
||||
int add(const Xmpdatum& xmpdatum);
|
||||
/*
|
||||
@brief Delete the Xmpdatum at iterator position pos, return the
|
||||
position of the next Xmpdatum.
|
||||
|
||||
@note Iterators into the metadata, including pos, are potentially
|
||||
invalidated by this call.
|
||||
@brief Delete the Xmpdatum at iterator position pos and update pos
|
||||
*/
|
||||
iterator erase(XmpData::iterator pos);
|
||||
/*!
|
||||
@brief Delete the Xmpdatum at iterator position pos and update pos
|
||||
erases all following keys from the same family
|
||||
See: https://github.com/Exiv2/exiv2/issues/521
|
||||
*/
|
||||
void eraseFamily(XmpData::iterator& pos);
|
||||
//! Delete all Xmpdatum instances resulting in an empty container.
|
||||
void clear();
|
||||
//! Sort metadata by key
|
||||
void sortByKey();
|
||||
//! Begin of the metadata
|
||||
iterator begin();
|
||||
//! End of the metadata
|
||||
iterator end();
|
||||
/*!
|
||||
@brief Find the first Xmpdatum with the given key, return an iterator
|
||||
to it.
|
||||
*/
|
||||
iterator findKey(const XmpKey& key);
|
||||
//@}
|
||||
@note Iterators into the metadata, including pos, are potentially
|
||||
invalidated by this call.
|
||||
@brief Delete the Xmpdatum at iterator position pos and update pos
|
||||
*/
|
||||
iterator erase(XmpData::iterator pos);
|
||||
/*!
|
||||
@brief Delete the Xmpdatum at iterator position pos and update pos
|
||||
erases all following keys from the same family
|
||||
See: https://github.com/Exiv2/exiv2/issues/521
|
||||
*/
|
||||
void eraseFamily(XmpData::iterator& pos);
|
||||
//! Delete all Xmpdatum instances resulting in an empty container.
|
||||
void clear();
|
||||
//! Sort metadata by key
|
||||
void sortByKey();
|
||||
//! Begin of the metadata
|
||||
iterator begin();
|
||||
//! End of the metadata
|
||||
iterator end();
|
||||
/*!
|
||||
@brief Find the first Xmpdatum with the given key, return an iterator
|
||||
to it.
|
||||
*/
|
||||
iterator findKey(const XmpKey& key);
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
//! Begin of the metadata
|
||||
const_iterator begin() const;
|
||||
//! End of the metadata
|
||||
const_iterator end() const;
|
||||
/*!
|
||||
@brief Find the first Xmpdatum with the given key, return a const
|
||||
iterator to it.
|
||||
*/
|
||||
const_iterator findKey(const XmpKey& key) const;
|
||||
//! Return true if there is no XMP metadata
|
||||
bool empty() const;
|
||||
//! Get the number of metadata entries
|
||||
long count() const;
|
||||
//! @name Accessors
|
||||
//@{
|
||||
//! Begin of the metadata
|
||||
const_iterator begin() const;
|
||||
//! End of the metadata
|
||||
const_iterator end() const;
|
||||
/*!
|
||||
@brief Find the first Xmpdatum with the given key, return a const
|
||||
iterator to it.
|
||||
*/
|
||||
const_iterator findKey(const XmpKey& key) const;
|
||||
//! Return true if there is no XMP metadata
|
||||
bool empty() const;
|
||||
//! Get the number of metadata entries
|
||||
long count() const;
|
||||
|
||||
//! are we to use the packet?
|
||||
bool usePacket() const { return usePacket_; } ;
|
||||
//! are we to use the packet?
|
||||
bool usePacket() const {
|
||||
return usePacket_;
|
||||
};
|
||||
|
||||
//! set usePacket_
|
||||
bool usePacket(bool b) { bool r = usePacket_; usePacket_=b ; return r; };
|
||||
//! setPacket
|
||||
void setPacket(const std::string& xmpPacket) { xmpPacket_ = xmpPacket ; usePacket(false); };
|
||||
// ! getPacket
|
||||
const std::string& xmpPacket() const { return xmpPacket_ ; };
|
||||
//! set usePacket_
|
||||
bool usePacket(bool b) {
|
||||
bool r = usePacket_;
|
||||
usePacket_ = b;
|
||||
return r;
|
||||
};
|
||||
//! setPacket
|
||||
void setPacket(const std::string& xmpPacket) {
|
||||
xmpPacket_ = xmpPacket;
|
||||
usePacket(false);
|
||||
};
|
||||
// ! getPacket
|
||||
const std::string& xmpPacket() const {
|
||||
return xmpPacket_;
|
||||
};
|
||||
|
||||
//@}
|
||||
//@}
|
||||
|
||||
private:
|
||||
// DATA
|
||||
XmpMetadata xmpMetadata_;
|
||||
std::string xmpPacket_ ;
|
||||
bool usePacket_{};
|
||||
}; // class XmpData
|
||||
private:
|
||||
// DATA
|
||||
XmpMetadata xmpMetadata_;
|
||||
std::string xmpPacket_;
|
||||
bool usePacket_{};
|
||||
}; // class XmpData
|
||||
|
||||
/*!
|
||||
@brief Stateless parser class for XMP packets. Images use this
|
||||
class to parse and serialize XMP packets. The parser uses
|
||||
the XMP toolkit to do the job.
|
||||
*/
|
||||
class EXIV2API XmpParser {
|
||||
public:
|
||||
//! Options to control the format of the serialized XMP packet.
|
||||
enum XmpFormatFlags {
|
||||
omitPacketWrapper = 0x0010UL, //!< Omit the XML packet wrapper.
|
||||
readOnlyPacket = 0x0020UL, //!< Default is a writeable packet.
|
||||
useCompactFormat = 0x0040UL, //!< Use a compact form of RDF.
|
||||
includeThumbnailPad = 0x0100UL, //!< Include a padding allowance for a thumbnail image.
|
||||
exactPacketLength = 0x0200UL, //!< The padding parameter is the overall packet length.
|
||||
writeAliasComments = 0x0400UL, //!< Show aliases as XML comments.
|
||||
omitAllFormatting = 0x0800UL //!< Omit all formatting whitespace.
|
||||
};
|
||||
/*!
|
||||
@brief Decode XMP metadata from an XMP packet \em xmpPacket into
|
||||
\em xmpData. The format of the XMP packet must follow the
|
||||
XMP specification. This method clears any previous contents
|
||||
of \em xmpData.
|
||||
/*!
|
||||
@brief Stateless parser class for XMP packets. Images use this
|
||||
class to parse and serialize XMP packets. The parser uses
|
||||
the XMP toolkit to do the job.
|
||||
*/
|
||||
class EXIV2API XmpParser {
|
||||
public:
|
||||
//! Options to control the format of the serialized XMP packet.
|
||||
enum XmpFormatFlags {
|
||||
omitPacketWrapper = 0x0010UL, //!< Omit the XML packet wrapper.
|
||||
readOnlyPacket = 0x0020UL, //!< Default is a writeable packet.
|
||||
useCompactFormat = 0x0040UL, //!< Use a compact form of RDF.
|
||||
includeThumbnailPad = 0x0100UL, //!< Include a padding allowance for a thumbnail image.
|
||||
exactPacketLength = 0x0200UL, //!< The padding parameter is the overall packet length.
|
||||
writeAliasComments = 0x0400UL, //!< Show aliases as XML comments.
|
||||
omitAllFormatting = 0x0800UL //!< Omit all formatting whitespace.
|
||||
};
|
||||
/*!
|
||||
@brief Decode XMP metadata from an XMP packet \em xmpPacket into
|
||||
\em xmpData. The format of the XMP packet must follow the
|
||||
XMP specification. This method clears any previous contents
|
||||
of \em xmpData.
|
||||
|
||||
@param xmpData Container for the decoded XMP properties
|
||||
@param xmpPacket The raw XMP packet to decode
|
||||
@return 0 if successful;<BR>
|
||||
1 if XMP support has not been compiled-in;<BR>
|
||||
2 if the XMP toolkit failed to initialize;<BR>
|
||||
3 if the XMP toolkit failed and raised an XMP_Error
|
||||
*/
|
||||
static int decode( XmpData& xmpData,
|
||||
const std::string& xmpPacket);
|
||||
/*!
|
||||
@brief Encode (serialize) XMP metadata from \em xmpData into a
|
||||
string xmpPacket. The XMP packet returned in the string
|
||||
follows the XMP specification. This method only modifies
|
||||
\em xmpPacket if the operations succeeds (return code 0).
|
||||
@param xmpData Container for the decoded XMP properties
|
||||
@param xmpPacket The raw XMP packet to decode
|
||||
@return 0 if successful;<BR>
|
||||
1 if XMP support has not been compiled-in;<BR>
|
||||
2 if the XMP toolkit failed to initialize;<BR>
|
||||
3 if the XMP toolkit failed and raised an XMP_Error
|
||||
*/
|
||||
static int decode(XmpData& xmpData, const std::string& xmpPacket);
|
||||
/*!
|
||||
@brief Encode (serialize) XMP metadata from \em xmpData into a
|
||||
string xmpPacket. The XMP packet returned in the string
|
||||
follows the XMP specification. This method only modifies
|
||||
\em xmpPacket if the operations succeeds (return code 0).
|
||||
|
||||
@param xmpPacket Reference to a string to hold the encoded XMP
|
||||
packet.
|
||||
@param xmpData XMP properties to encode.
|
||||
@param formatFlags Flags that control the format of the XMP packet,
|
||||
see enum XmpFormatFlags.
|
||||
@param padding Padding length.
|
||||
@return 0 if successful;<BR>
|
||||
1 if XMP support has not been compiled-in;<BR>
|
||||
2 if the XMP toolkit failed to initialize;<BR>
|
||||
3 if the XMP toolkit failed and raised an XMP_Error
|
||||
*/
|
||||
static int encode( std::string& xmpPacket,
|
||||
const XmpData& xmpData,
|
||||
uint16_t formatFlags =useCompactFormat,
|
||||
uint32_t padding =0);
|
||||
/*!
|
||||
@brief Lock/unlock function type
|
||||
@param xmpPacket Reference to a string to hold the encoded XMP
|
||||
packet.
|
||||
@param xmpData XMP properties to encode.
|
||||
@param formatFlags Flags that control the format of the XMP packet,
|
||||
see enum XmpFormatFlags.
|
||||
@param padding Padding length.
|
||||
@return 0 if successful;<BR>
|
||||
1 if XMP support has not been compiled-in;<BR>
|
||||
2 if the XMP toolkit failed to initialize;<BR>
|
||||
3 if the XMP toolkit failed and raised an XMP_Error
|
||||
*/
|
||||
static int encode(std::string& xmpPacket, const XmpData& xmpData, uint16_t formatFlags = useCompactFormat,
|
||||
uint32_t padding = 0);
|
||||
/*!
|
||||
@brief Lock/unlock function type
|
||||
|
||||
A function of this type can be passed to initialize() to
|
||||
make subsequent registration of XMP namespaces thread-safe.
|
||||
See the initialize() function for more information.
|
||||
A function of this type can be passed to initialize() to
|
||||
make subsequent registration of XMP namespaces thread-safe.
|
||||
See the initialize() function for more information.
|
||||
|
||||
@param pLockData Pointer to the pLockData passed to initialize()
|
||||
@param lockUnlock Indicates whether to lock (true) or unlock (false)
|
||||
*/
|
||||
using XmpLockFct = void (*)(void* pLockData, bool lockUnlock);
|
||||
@param pLockData Pointer to the pLockData passed to initialize()
|
||||
@param lockUnlock Indicates whether to lock (true) or unlock (false)
|
||||
*/
|
||||
using XmpLockFct = void (*)(void* pLockData, bool lockUnlock);
|
||||
|
||||
/*!
|
||||
@brief Initialize the XMP Toolkit.
|
||||
/*!
|
||||
@brief Initialize the XMP Toolkit.
|
||||
|
||||
Calling this method is usually not needed, as encode() and
|
||||
decode() will initialize the XMP Toolkit if necessary.
|
||||
Calling this method is usually not needed, as encode() and
|
||||
decode() will initialize the XMP Toolkit if necessary.
|
||||
|
||||
The function takes optional pointers to a callback function
|
||||
\em xmpLockFct and related data \em pLockData that the parser
|
||||
uses when XMP namespaces are subsequently registered.
|
||||
The function takes optional pointers to a callback function
|
||||
\em xmpLockFct and related data \em pLockData that the parser
|
||||
uses when XMP namespaces are subsequently registered.
|
||||
|
||||
The initialize() function itself still is not thread-safe and
|
||||
needs to be called in a thread-safe manner (e.g., on program
|
||||
startup), but if used with suitable additional locking
|
||||
parameters, any subsequent registration of namespaces will be
|
||||
thread-safe.
|
||||
The initialize() function itself still is not thread-safe and
|
||||
needs to be called in a thread-safe manner (e.g., on program
|
||||
startup), but if used with suitable additional locking
|
||||
parameters, any subsequent registration of namespaces will be
|
||||
thread-safe.
|
||||
|
||||
Example usage on Windows using a critical section:
|
||||
Example usage on Windows using a critical section:
|
||||
|
||||
@code
|
||||
void main()
|
||||
{
|
||||
struct XmpLock
|
||||
{
|
||||
CRITICAL_SECTION cs;
|
||||
XmpLock() { InitializeCriticalSection(&cs); }
|
||||
~XmpLock() { DeleteCriticalSection(&cs); }
|
||||
@code
|
||||
void main()
|
||||
{
|
||||
struct XmpLock
|
||||
{
|
||||
CRITICAL_SECTION cs;
|
||||
XmpLock() { InitializeCriticalSection(&cs); }
|
||||
~XmpLock() { DeleteCriticalSection(&cs); }
|
||||
|
||||
static void LockUnlock(void* pData, bool fLock)
|
||||
{
|
||||
XmpLock* pThis = reinterpret_cast<XmpLock*>(pData);
|
||||
if (pThis)
|
||||
{
|
||||
(fLock) ? EnterCriticalSection(&pThis->cs)
|
||||
: LeaveCriticalSection(&pThis->cs);
|
||||
}
|
||||
}
|
||||
} xmpLock;
|
||||
static void LockUnlock(void* pData, bool fLock)
|
||||
{
|
||||
XmpLock* pThis = reinterpret_cast<XmpLock*>(pData);
|
||||
if (pThis)
|
||||
{
|
||||
(fLock) ? EnterCriticalSection(&pThis->cs)
|
||||
: LeaveCriticalSection(&pThis->cs);
|
||||
}
|
||||
}
|
||||
} xmpLock;
|
||||
|
||||
// Pass the locking mechanism to the XMP parser on initialization.
|
||||
// Note however that this call itself is still not thread-safe.
|
||||
Exiv2::XmpParser::initialize(XmpLock::LockUnlock, &xmpLock);
|
||||
// Pass the locking mechanism to the XMP parser on initialization.
|
||||
// Note however that this call itself is still not thread-safe.
|
||||
Exiv2::XmpParser::initialize(XmpLock::LockUnlock, &xmpLock);
|
||||
|
||||
// Program continues here, subsequent registrations of XMP
|
||||
// namespaces are serialized using xmpLock.
|
||||
// Program continues here, subsequent registrations of XMP
|
||||
// namespaces are serialized using xmpLock.
|
||||
|
||||
}
|
||||
@endcode
|
||||
}
|
||||
@endcode
|
||||
|
||||
@return True if the initialization was successful, else false.
|
||||
*/
|
||||
static bool initialize(XmpParser::XmpLockFct xmpLockFct = nullptr, void* pLockData = nullptr);
|
||||
/*!
|
||||
@brief Terminate the XMP Toolkit and unregister custom namespaces.
|
||||
@return True if the initialization was successful, else false.
|
||||
*/
|
||||
static bool initialize(XmpParser::XmpLockFct xmpLockFct = nullptr, void* pLockData = nullptr);
|
||||
/*!
|
||||
@brief Terminate the XMP Toolkit and unregister custom namespaces.
|
||||
|
||||
Call this method when the XmpParser is no longer needed to
|
||||
allow the XMP Toolkit to cleanly shutdown.
|
||||
*/
|
||||
static void terminate();
|
||||
Call this method when the XmpParser is no longer needed to
|
||||
allow the XMP Toolkit to cleanly shutdown.
|
||||
*/
|
||||
static void terminate();
|
||||
|
||||
private:
|
||||
/*!
|
||||
@brief Register a namespace with the XMP Toolkit.
|
||||
*/
|
||||
static void registerNs(const std::string& ns,
|
||||
const std::string& prefix);
|
||||
/*!
|
||||
@brief Delete a namespace from the XMP Toolkit.
|
||||
private:
|
||||
/*!
|
||||
@brief Register a namespace with the XMP Toolkit.
|
||||
*/
|
||||
static void registerNs(const std::string& ns, const std::string& prefix);
|
||||
/*!
|
||||
@brief Delete a namespace from the XMP Toolkit.
|
||||
|
||||
XmpProperties::unregisterNs calls this to synchronize namespaces.
|
||||
*/
|
||||
static void unregisterNs(const std::string& ns);
|
||||
XmpProperties::unregisterNs calls this to synchronize namespaces.
|
||||
*/
|
||||
static void unregisterNs(const std::string& ns);
|
||||
|
||||
/*!
|
||||
@brief Get namespaces registered with XMPsdk
|
||||
*/
|
||||
static void registeredNamespaces(Exiv2::Dictionary&);
|
||||
/*!
|
||||
@brief Get namespaces registered with XMPsdk
|
||||
*/
|
||||
static void registeredNamespaces(Exiv2::Dictionary&);
|
||||
|
||||
// DATA
|
||||
static bool initialized_; //! Indicates if the XMP Toolkit has been initialized
|
||||
static XmpLockFct xmpLockFct_;
|
||||
static void* pLockData_;
|
||||
// DATA
|
||||
static bool initialized_; //! Indicates if the XMP Toolkit has been initialized
|
||||
static XmpLockFct xmpLockFct_;
|
||||
static void* pLockData_;
|
||||
|
||||
friend class XmpProperties; // permit XmpProperties -> registerNs() and registeredNamespaces()
|
||||
friend class XmpProperties; // permit XmpProperties -> registerNs() and registeredNamespaces()
|
||||
|
||||
}; // class XmpParser
|
||||
}; // class XmpParser
|
||||
|
||||
// *****************************************************************************
|
||||
// free functions, template and inline definitions
|
||||
|
||||
inline Xmpdatum& Xmpdatum::operator=(const char* value)
|
||||
{
|
||||
return Xmpdatum::operator=(std::string(value));
|
||||
}
|
||||
inline Xmpdatum& Xmpdatum::operator=(const char* value) {
|
||||
return Xmpdatum::operator=(std::string(value));
|
||||
}
|
||||
|
||||
inline Xmpdatum& Xmpdatum::operator=(const bool& value)
|
||||
{
|
||||
return operator=(value ? "True" : "False");
|
||||
}
|
||||
inline Xmpdatum& Xmpdatum::operator=(const bool& value) {
|
||||
return operator=(value ? "True" : "False");
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Xmpdatum& Xmpdatum::operator=(const T& value)
|
||||
{
|
||||
setValue(Exiv2::toString(value));
|
||||
return *this;
|
||||
}
|
||||
template <typename T>
|
||||
Xmpdatum& Xmpdatum::operator=(const T& value) {
|
||||
setValue(Exiv2::toString(value));
|
||||
return *this;
|
||||
}
|
||||
|
||||
} // namespace Exiv2
|
||||
} // namespace Exiv2
|
||||
|
||||
#endif // #ifndef XMP_HPP_
|
||||
#endif // #ifndef XMP_HPP_
|
||||
|
||||
@@ -12,77 +12,76 @@
|
||||
// *****************************************************************************
|
||||
// namespace extensions
|
||||
namespace Exiv2 {
|
||||
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
|
||||
/*!
|
||||
@brief Class to access XMP sidecar files. They contain only XMP metadata.
|
||||
*/
|
||||
class EXIV2API XmpSidecar : public Image {
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor for an XMP sidecar file. Since the constructor
|
||||
can not return a result, callers should check the good() method
|
||||
after object construction to determine success or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
@param create Specifies if an existing image should be read (false)
|
||||
or if a new image should be created (true).
|
||||
*/
|
||||
XmpSidecar(BasicIo::UniquePtr io, bool create);
|
||||
//@}
|
||||
/*!
|
||||
@brief Class to access XMP sidecar files. They contain only XMP metadata.
|
||||
*/
|
||||
class EXIV2API XmpSidecar : public Image {
|
||||
public:
|
||||
//! @name Creators
|
||||
//@{
|
||||
/*!
|
||||
@brief Constructor for an XMP sidecar file. Since the constructor
|
||||
can not return a result, callers should check the good() method
|
||||
after object construction to determine success or failure.
|
||||
@param io An auto-pointer that owns a BasicIo instance used for
|
||||
reading and writing image metadata. \b Important: The constructor
|
||||
takes ownership of the passed in BasicIo instance through the
|
||||
auto-pointer. Callers should not continue to use the BasicIo
|
||||
instance after it is passed to this method. Use the Image::io()
|
||||
method to get a temporary reference.
|
||||
@param create Specifies if an existing image should be read (false)
|
||||
or if a new image should be created (true).
|
||||
*/
|
||||
XmpSidecar(BasicIo::UniquePtr io, bool create);
|
||||
//@}
|
||||
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void readMetadata() override;
|
||||
void writeMetadata() override;
|
||||
/*!
|
||||
@brief Not supported. XMP sidecar files do not contain a comment.
|
||||
Calling this function will throw an instance of Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setComment(std::string_view comment) override;
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void readMetadata() override;
|
||||
void writeMetadata() override;
|
||||
/*!
|
||||
@brief Not supported. XMP sidecar files do not contain a comment.
|
||||
Calling this function will throw an instance of Error(ErrorCode::kerInvalidSettingForImage).
|
||||
*/
|
||||
void setComment(std::string_view comment) override;
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override;
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
std::string mimeType() const override;
|
||||
//@}
|
||||
|
||||
private:
|
||||
//! @name NOT Implemented
|
||||
//@{
|
||||
//! Copy constructor
|
||||
XmpSidecar(const XmpSidecar& rhs);
|
||||
//! Assignment operator
|
||||
XmpSidecar& operator=(const XmpSidecar& rhs);
|
||||
//@}
|
||||
private:
|
||||
//! @name NOT Implemented
|
||||
//@{
|
||||
//! Copy constructor
|
||||
XmpSidecar(const XmpSidecar& rhs);
|
||||
//! Assignment operator
|
||||
XmpSidecar& operator=(const XmpSidecar& rhs);
|
||||
//@}
|
||||
|
||||
Exiv2::Dictionary dates_;
|
||||
Exiv2::Dictionary dates_;
|
||||
|
||||
}; // class XmpSidecar
|
||||
}; // class XmpSidecar
|
||||
|
||||
// *****************************************************************************
|
||||
// template, inline and free functions
|
||||
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new XmpSidecar instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newXmpInstance(BasicIo::UniquePtr io, bool create);
|
||||
// These could be static private functions on Image subclasses but then
|
||||
// ImageFactory needs to be made a friend.
|
||||
/*!
|
||||
@brief Create a new XmpSidecar instance and return an auto-pointer to it.
|
||||
Caller owns the returned object and the auto-pointer ensures that
|
||||
it will be deleted.
|
||||
*/
|
||||
EXIV2API Image::UniquePtr newXmpInstance(BasicIo::UniquePtr io, bool create);
|
||||
|
||||
//! Check if the file iIo is an XMP sidecar file.
|
||||
EXIV2API bool isXmpType(BasicIo& iIo, bool advance);
|
||||
//! Check if the file iIo is an XMP sidecar file.
|
||||
EXIV2API bool isXmpType(BasicIo& iIo, bool advance);
|
||||
|
||||
} // namespace Exiv2
|
||||
} // namespace Exiv2
|
||||
|
||||
#endif // #ifndef XMPSIDECAR_HPP_
|
||||
#endif // #ifndef XMPSIDECAR_HPP_
|
||||
|
||||
Reference in New Issue
Block a user