 |
Exiv2
|
23 #include "exiv2lib_export.h"
38 # if _MSC_VER >= _MSC_VER_2010
42 typedef unsigned __int8 uint8_t;
43 typedef unsigned __int16 uint16_t;
44 typedef unsigned __int32 uint32_t;
45 typedef unsigned __int64 uint64_t;
46 typedef __int8 int8_t;
47 typedef __int16 int16_t;
48 typedef __int32 int32_t;
49 typedef __int64 int64_t;
57 #ifdef EXV_UNICODE_PATH
58 # define EXV_WIDEN(t) L ## t
66 #define EXV_CALL_MEMBER_FN(object,ptrToMember) ((object).*(ptrToMember))
70 #define EXV_MIN(a,b) ((a) < (b) ? (a) : (b))
71 #define EXV_MAX(a,b) ((a) > (b) ? (a) : (b))
74 #if defined(__GNUC__) && (__GNUC__ >= 4) || defined(__clang__)
75 #define EXV_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))
76 #elif defined(_MSC_VER) && (_MSC_VER >= 1700)
77 #define EXV_WARN_UNUSED_RESULT _Check_return_
79 #define EXV_WARN_UNUSED_RESULT
102 enum ByteOrder { invalidByteOrder, littleEndian, bigEndian };
108 enum MetadataId { mdNone=0, mdExif=1, mdIptc=2, mdComment=4, mdXmp=8, mdIccProfile=16 };
111 enum AccessMode { amNone=0, amRead=1, amWrite=2, amReadWrite=3 };
151 typedef std::vector<byte>
Blob;
167 static const char* typeName(
TypeId typeId);
169 static TypeId typeId(
const std::string& typeName);
171 static long typeSize(
TypeId typeId);
184 std::pair<byte*, long>
p;
202 DataBuf(
const byte* pData,
long size);
226 void alloc(
long size);
232 EXV_WARN_UNUSED_RESULT std::pair<byte*, long> release();
240 void reset(std::pair<byte*, long> =std::make_pair((
byte*)(0),
long(0)));
285 template <
typename T>
288 if (byteOrder == littleEndian) {
289 return static_cast<byte>(buf.
at(1)) << 8 |
static_cast<byte>(buf.
at(0));
291 return static_cast<byte>(buf.
at(0)) << 8 |
static_cast<byte>(buf.
at(1));
367 EXIV2API
void hexdump(std::ostream& os,
const byte* buf,
long len,
long offset =0);
374 EXIV2API
bool isHex(
const std::string& str,
376 const std::string& prefix =
"");
383 EXIV2API
int exifTime(
const char* buf,
struct tm* tm);
389 EXIV2API
const char*
exvGettext(
const char* str);
391 #ifdef EXV_UNICODE_PATH
392 EXIV2API std::wstring s2ws(
const std::string& s);
395 EXIV2API std::string ws2s(
const std::wstring& s);
409 EXIV2API
long parseLong(
const std::string& s,
bool& ok);
423 EXIV2API
float parseFloat(
const std::string& s,
bool& ok);
496 template<
typename T,
typename K,
int N>
497 const T*
find(T (&src)[N],
const K& key)
499 const T* rc = std::find(src, src + N, key);
500 return rc == src + N ? 0 : rc;
504 template <
typename T,
int N> char (&
sizer(T (&)[N]))[N];
506 #define EXV_COUNTOF(a) (sizeof(Exiv2::sizer(a)))
512 std::ostringstream os;
531 std::istringstream is(s);
533 ok = (is >> tmp) ?
true :
false;
535 is >> std::skipws >> rest;
536 if (!rest.empty()) ok =
false;
558 template <
typename IntType>
559 IntType
gcd(IntType n, IntType m)
568 #pragma warning( disable : 4146 )
573 if (n == std::numeric_limits<IntType>::min()) {
574 n = std::numeric_limits<IntType>::max();
582 #pragma warning( default : 4146 )
600 #endif // #ifndef TYPES_HPP_
EXIV2API URational getURational(const byte *buf, ByteOrder byteOrder)
Read an 8 byte unsigned rational value from the data buffer.
Definition: types.cpp:306
void reset(std::pair< byte *, long >=std::make_pair((byte *)(0), long(0)))
Reset value.
Definition: types.cpp:182
Slice (= view) for STL containers.
Definition: slice.hpp:521
EXIV2API std::istream & operator>>(std::istream &is, Rational &r)
Input operator for our fake rational.
Definition: types.cpp:223
byte * pData_
Pointer to the buffer, 0 if none has been allocated.
Definition: types.hpp:258
@ tiffFloat
TIFF FLOAT type, single precision (4-byte) IEEE format.
Definition: types.hpp:130
EXIV2API Rational parseRational(const std::string &s, bool &ok)
Return a Rational set to the value represented by s.
Definition: types.cpp:671
EXIV2API long d2Data(byte *buf, double d, ByteOrder byteOrder)
Convert a double precision floating point (IEEE 754 binary64) double to data, write the data to the b...
Definition: types.cpp:478
Internal::enable_if< Internal::is_signed< T >::VALUE, T >::type abs(T num)
Calculates the absolute value of a number without producing negative values.
Definition: safe_op.hpp:320
Auxiliary type to enable copies and assignments, similar to std::auto_ptr_ref. See http://www....
Definition: types.hpp:180
EXIV2API long ur2Data(byte *buf, URational l, ByteOrder byteOrder)
Convert an unsigned rational to data, write the data to the buffer, return number of bytes written.
Definition: types.cpp:420
@ undefined
Exif UNDEFINED type, an 8-bit byte that may contain anything.
Definition: types.hpp:126
EXV_WARN_UNUSED_RESULT std::pair< byte *, long > release()
Release ownership of the buffer to the caller. Returns the buffer as a data pointer and size pair,...
Definition: types.cpp:167
@ signedLongLong
Exif LONG LONG type, 64-bit (8-byte) signed integer.
Definition: types.hpp:134
char(& sizer(T(&)[N]))[N]
Template used in the COUNTOF macro to determine the size of an array.
@ signedShort
Exif SSHORT type, a 16-bit (2-byte) signed (twos-complement) integer.
Definition: types.hpp:127
Slice< T > makeSlice(T &cont, size_t begin, size_t end)
Return a new slice with the given bounds.
Definition: slice.hpp:665
@ comment
Exiv2 type for the Exif user comment.
Definition: types.hpp:139
const EXIV2API char * exvGettext(const char *str)
Translate a string using the gettext framework. This wrapper hides all the implementation details fro...
Definition: types.cpp:571
@ asciiString
Exif ASCII type, 8-bit byte.
Definition: types.hpp:121
EXIV2API long r2Data(byte *buf, Rational l, ByteOrder byteOrder)
Convert a signed rational to data, write the data to the buffer, return number of bytes written.
Definition: types.cpp:457
EXIV2API float parseFloat(const std::string &s, bool &ok)
Return a float set to the value represented by s.
Definition: types.cpp:650
EXIV2API bool isHex(const std::string &str, size_t size=0, const std::string &prefix="")
Return true if str is a hex number starting with prefix followed by size hex digits,...
Definition: types.cpp:538
@ unsignedLong
Exif LONG type, 32-bit (4-byte) unsigned integer.
Definition: types.hpp:123
@ tiffIfd8
TIFF IFD type, 64-bit (8-byte) unsigned integer.
Definition: types.hpp:135
EXIV2API long f2Data(byte *buf, float f, ByteOrder byteOrder)
Convert a single precision floating point (IEEE 754 binary32) float to data, write the data to the bu...
Definition: types.cpp:464
T stringTo(const std::string &s, bool &ok)
Utility function to convert a string to a value of type T.
Definition: types.hpp:529
@ tiffDouble
TIFF DOUBLE type, double precision (8-byte) IEEE format.
Definition: types.hpp:131
DataBuf()
Default constructor.
Definition: types.cpp:133
Type information lookup functions. Implemented as a static class.
Definition: types.hpp:157
@ tiffIfd
TIFF IFD type, 32-bit (4-byte) unsigned integer.
Definition: types.hpp:132
MetadataId
An identifier for each type of metadata.
Definition: types.hpp:108
void free()
Free the internal buffer and reset the size to 0.
Definition: types.cpp:175
@ unsignedRational
Exif RATIONAL type, two LONGs: numerator and denumerator of a fraction.
Definition: types.hpp:124
static TypeId typeId(const std::string &typeName)
Return the type id for a type name.
Definition: types.cpp:109
EXIV2API void hexdump(std::ostream &os, const byte *buf, long len, long offset=0)
Print len bytes from buf in hex and ASCII format to the given stream, prefixed with the position in t...
Definition: types.cpp:513
EXIV2API int exifTime(const char *buf, struct tm *tm)
Converts a string in the form "%Y:%m:%d %H:%M:%S", e.g., "2007:05:24 12:31:55" to broken down time fo...
Definition: types.cpp:551
EXIV2API std::string getProcessPath()
Return the path of the current process.
Definition: futils.cpp:434
@ invalidTypeId
Invalid type id.
Definition: types.hpp:146
uint8_t byte
1 byte unsigned integer type.
Definition: types.hpp:94
EXIV2API long parseLong(const std::string &s, bool &ok)
Return a long set to the value represented by s.
Definition: types.cpp:626
DataBufRef(std::pair< byte *, long > rhs)
Constructor.
Definition: types.hpp:182
EXIV2API int16_t getShort(const byte *buf, ByteOrder byteOrder)
Read a 2 byte signed short value from the data buffer.
Definition: types.cpp:313
EXIV2API uint64_t getULongLong(const byte *buf, ByteOrder byteOrder)
Read a 8 byte unsigned long value from the data buffer.
Definition: types.cpp:290
@ xmpBag
XMP bag type.
Definition: types.hpp:143
Utility class containing a character array. All it does is to take care of memory allocation and dele...
Definition: types.hpp:193
EXIV2API long l2Data(byte *buf, int32_t l, ByteOrder byteOrder)
Convert a signed long to data, write the data to the buffer, return number of bytes written.
Definition: types.cpp:440
void alloc(long size)
Allocate a data buffer of at least the given size. Note that if the requested size is less than the c...
Definition: types.cpp:156
@ unsignedByte
Exif BYTE type, 8-bit unsigned integer.
Definition: types.hpp:120
EXIV2API long us2Data(byte *buf, uint16_t s, ByteOrder byteOrder)
Convert an unsigned short to data, write the data to the buffer, return number of bytes written.
Definition: types.cpp:390
@ signedByte
Exif SBYTE type, an 8-bit signed (twos-complement) integer.
Definition: types.hpp:125
value_type & at(size_t index)
Definition: slice.hpp:261
long size_
The current size of the buffer.
Definition: types.hpp:260
EXIV2API int32_t getLong(const byte *buf, ByteOrder byteOrder)
Read a 4 byte signed long value from the data buffer.
Definition: types.cpp:323
const T * find(T(&src)[N], const K &key)
Find an element that matches key in the array src.
Definition: types.hpp:497
@ langAlt
XMP language alternative type.
Definition: types.hpp:145
EXIV2API std::ostream & operator<<(std::ostream &os, const DataSet &dataSet)
Output operator for dataSet.
Definition: datasets.cpp:709
@ unsignedShort
Exif SHORT type, 16-bit (2-byte) unsigned integer.
Definition: types.hpp:122
Provides classes and functions to encode and decode Exif and Iptc data. The libexiv2 API consists of ...
Definition: asfvideo.hpp:36
EXIV2API float getFloat(const byte *buf, ByteOrder byteOrder)
Read a 4 byte single precision floating point value (IEEE 754 binary32) from the data buffer.
Definition: types.cpp:342
std::pair< int32_t, int32_t > Rational
8 byte signed rational type.
Definition: types.hpp:99
@ signedLong
Exif SLONG type, a 32-bit (4-byte) signed (twos-complement) integer.
Definition: types.hpp:128
TypeId
Exiv2 value type identifiers.
Definition: types.hpp:119
EXIV2API long ul2Data(byte *buf, uint32_t l, ByteOrder byteOrder)
Convert an unsigned long to data, write the data to the buffer, return number of bytes written.
Definition: types.cpp:403
~DataBuf()
Destructor, deletes the allocated buffer.
Definition: types.cpp:130
@ signedRational
Exif SRATIONAL type, two SLONGs: numerator and denumerator of a fraction.
Definition: types.hpp:129
static const char * typeName(TypeId typeId)
Return the name of the type, 0 if unknown.
Definition: types.cpp:102
bool operator==(const TagDetails &td, const LensTypeAndFocalLengthAndMaxAperture <fl)
Compare tag details with a lens entry.
Definition: canonmn_int.cpp:2820
EXIV2API uint16_t getUShort(const byte *buf, ByteOrder byteOrder)
Read a 2 byte unsigned short value from the data buffer.
Definition: types.cpp:273
ByteOrder
Type to express the byte order (little or big endian)
Definition: types.hpp:102
@ time
IPTC time type.
Definition: types.hpp:138
@ date
IPTC date type.
Definition: types.hpp:137
AccessMode
An identifier for each mode of metadata support.
Definition: types.hpp:111
Slice< container > makeSliceUntil(container &cont, size_t end)
Return a new slice spanning until end.
Definition: slice.hpp:702
IntType gcd(IntType n, IntType m)
Return the greatest common denominator of n and m. (Implementation from Boost rational....
Definition: types.hpp:559
std::pair< uint32_t, uint32_t > URational
8 byte unsigned rational type.
Definition: types.hpp:97
EXIV2API Rational getRational(const byte *buf, ByteOrder byteOrder)
Read an 8 byte signed rational value from the data buffer.
Definition: types.cpp:335
DataBuf & operator=(DataBuf &rhs)
Assignment operator. Transfers the buffer and releases the buffer at the original object similar to s...
Definition: types.cpp:149
@ xmpText
XMP text type.
Definition: types.hpp:141
@ unsignedLongLong
Exif LONG LONG type, 64-bit (8-byte) unsigned integer.
Definition: types.hpp:133
@ string
IPTC string type.
Definition: types.hpp:136
@ directory
Exiv2 type for a CIFF directory.
Definition: types.hpp:140
EXIV2API double getDouble(const byte *buf, ByteOrder byteOrder)
Read an 8 byte double precision floating point value (IEEE 754 binary64) from the data buffer.
Definition: types.cpp:356
bool stringTo< bool >(const std::string &s, bool &ok)
Specialization of stringTo(const std::string& s, bool& ok) for bool.
Definition: types.cpp:607
@ xmpSeq
XMP sequence type.
Definition: types.hpp:144
std::string toString(const T &arg)
Utility function to convert the argument of any type to a string.
Definition: types.hpp:510
@ lastTypeId
Last type id.
Definition: types.hpp:147
EXIV2API Rational floatToRationalCast(float f)
Very simple conversion of a float to a Rational.
Definition: types.cpp:689
@ xmpAlt
XMP alternative type.
Definition: types.hpp:142
WriteMethod
Type to indicate write method used by TIFF parsers.
Definition: types.hpp:105
std::pair< byte *, long > p
Pointer to a byte array and its size.
Definition: types.hpp:184
static long typeSize(TypeId typeId)
Return the size in bytes of one element of this type.
Definition: types.cpp:116
EXIV2API uint32_t getULong(const byte *buf, ByteOrder byteOrder)
Read a 4 byte unsigned long value from the data buffer.
Definition: types.cpp:278
EXIV2API long s2Data(byte *buf, int16_t s, ByteOrder byteOrder)
Convert a signed short to data, write the data to the buffer, return number of bytes written.
Definition: types.cpp:427
std::vector< byte > Blob
Container for binary data.
Definition: types.hpp:151