6#include "exiv2lib_export.h"
111 static const char* typeName(
TypeId typeId);
113 static TypeId typeId(
const std::string& typeName);
115 static size_t typeSize(
TypeId typeId);
132 DataBuf(
const byte* pData,
size_t size);
142 void alloc(
size_t size);
146 void resize(
size_t size);
152 using iterator = std::vector<byte>::iterator;
153 using const_iterator = std::vector<byte>::const_iterator;
155 iterator begin() noexcept {
156 return pData_.begin();
158 [[nodiscard]] const_iterator cbegin() const noexcept {
159 return pData_.cbegin();
161 iterator end() noexcept {
164 [[nodiscard]] const_iterator cend() const noexcept {
168 [[nodiscard]]
size_t size()
const {
169 return pData_.size();
172 [[nodiscard]] uint8_t read_uint8(
size_t offset)
const;
173 void write_uint8(
size_t offset, uint8_t x);
175 [[nodiscard]] uint16_t read_uint16(
size_t offset, ByteOrder byteOrder)
const;
176 void write_uint16(
size_t offset, uint16_t x, ByteOrder byteOrder);
178 [[nodiscard]] uint32_t read_uint32(
size_t offset, ByteOrder byteOrder)
const;
179 void write_uint32(
size_t offset, uint32_t x, ByteOrder byteOrder);
181 [[nodiscard]] uint64_t read_uint64(
size_t offset, ByteOrder byteOrder)
const;
182 void write_uint64(
size_t offset, uint64_t x, ByteOrder byteOrder);
185 int cmpBytes(
size_t offset,
const void* buf,
size_t bufsize)
const;
188 [[nodiscard]]
byte* data(
size_t offset = 0);
191 [[nodiscard]]
const byte* c_data(
size_t offset = 0)
const;
194 [[nodiscard]]
const char* c_str(
size_t offset = 0)
const;
196 [[nodiscard]]
bool empty()
const {
197 return pData_.empty();
201 std::vector<byte> pData_;
217EXIV2API Slice<byte*>
makeSlice(DataBuf& buf,
size_t begin,
size_t end);
220EXIV2API Slice<const byte*>
makeSlice(
const DataBuf& buf,
size_t begin,
size_t end);
230 if (byteOrder == littleEndian) {
231 return static_cast<byte>(buf.
at(1)) << 8 |
static_cast<byte>(buf.
at(0));
233 return static_cast<byte>(buf.
at(0)) << 8 |
static_cast<byte>(buf.
at(1));
313EXIV2API
void hexdump(std::ostream& os,
const byte* buf,
size_t len,
size_t offset = 0);
320EXIV2API
bool isHex(
const std::string& str,
size_t size = 0,
const std::string& prefix =
"");
327EXIV2API
int exifTime(
const char* buf, tm* tm);
333EXIV2API
const char*
exvGettext(
const char* str);
347EXIV2API int64_t
parseInt64(
const std::string& s,
bool& ok);
361EXIV2API uint32_t
parseUint32(
const std::string& s,
bool& ok);
375EXIV2API
float parseFloat(
const std::string& s,
bool& ok);
448template <
typename T,
typename K,
int N>
449const T*
find(T (&src)[N],
const K& key) {
450 auto rc = std::find(src, src + N, key);
451 return rc == src + N ? nullptr : rc;
457 return std::to_string(arg);
462 std::ostringstream os;
467std::string toString(
const T& arg) {
484 std::istringstream is(s);
486 ok =
static_cast<bool>(is >> tmp);
488 is >> std::skipws >> rest;
Type information lookup functions. Implemented as a static class.
Definition types.hpp:108
Class CrwImage to access Canon CRW images. References: The Canon RAW (CRW) File Format by Phil Harv...
Definition asfvideo.hpp:15
std::pair< int32_t, int32_t > Rational
8 byte signed rational type.
Definition types.hpp:31
EXIV2API std::ostream & operator<<(std::ostream &os, const DataSet &dataSet)
Output operator for dataSet.
Definition datasets.cpp:590
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:308
EXIV2API size_t 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:342
const T * find(T(&src)[N], const K &key)
Find an element that matches key in the array src.
Definition types.hpp:449
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:296
EXIV2API float parseFloat(const std::string &s, bool &ok)
Return a float set to the value represented by s.
Definition types.cpp:564
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:475
EXIV2API size_t 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:422
EXIV2API Rational floatToRationalCast(float f)
Very simple conversion of a float to a Rational.
Definition types.cpp:607
EXIV2API size_t 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:410
EXIV2API void hexdump(std::ostream &os, const byte *buf, size_t len, size_t 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:454
EXIV2API const char * exvGettext(const char *str)
Translate a string using the gettext framework. This wrapper hides all the implementation details fro...
Definition types.cpp:504
EXIV2API int16_t getShort(const byte *buf, ByteOrder byteOrder)
Read a 2 byte signed short value from the data buffer.
Definition types.cpp:276
uint8_t byte
1 byte unsigned integer type.
Definition types.hpp:26
EXIV2API uint32_t getULong(const byte *buf, ByteOrder byteOrder)
Read a 4 byte unsigned long value from the data buffer.
Definition types.cpp:250
Slice< T > makeSlice(T &cont, size_t begin, size_t end)
Return a new slice with the given bounds.
Definition slice.hpp:533
std::pair< uint32_t, uint32_t > URational
8 byte unsigned rational type.
Definition types.hpp:29
TypeId
Exiv2 value type identifiers.
Definition types.hpp:70
@ unsignedShort
Exif SHORT type, 16-bit (2-byte) unsigned integer.
Definition types.hpp:73
@ date
IPTC date type.
Definition types.hpp:88
@ signedRational
Exif SRATIONAL type, two SLONGs: numerator and denominator of a fraction.
Definition types.hpp:80
@ tiffIfd8
TIFF IFD type, 64-bit (8-byte) unsigned integer.
Definition types.hpp:86
@ lastTypeId
Last type id.
Definition types.hpp:98
@ unsignedLongLong
Exif LONG LONG type, 64-bit (8-byte) unsigned integer.
Definition types.hpp:84
@ unsignedLong
Exif LONG type, 32-bit (4-byte) unsigned integer.
Definition types.hpp:74
@ signedShort
Exif SSHORT type, a 16-bit (2-byte) signed (twos-complement) integer.
Definition types.hpp:78
@ signedLongLong
Exif LONG LONG type, 64-bit (8-byte) signed integer.
Definition types.hpp:85
@ signedLong
Exif SLONG type, a 32-bit (4-byte) signed (twos-complement) integer.
Definition types.hpp:79
@ langAlt
XMP language alternative type.
Definition types.hpp:96
@ xmpAlt
XMP alternative type.
Definition types.hpp:93
@ unsignedByte
Exif BYTE type, 8-bit unsigned integer.
Definition types.hpp:71
@ signedByte
Exif SBYTE type, an 8-bit signed (twos-complement) integer.
Definition types.hpp:76
@ asciiString
Exif ASCII type, 8-bit byte.
Definition types.hpp:72
@ xmpText
XMP text type.
Definition types.hpp:92
@ time
IPTC time type.
Definition types.hpp:89
@ xmpSeq
XMP sequence type.
Definition types.hpp:95
@ comment
Exiv2 type for the Exif user comment.
Definition types.hpp:90
@ tiffDouble
TIFF DOUBLE type, double precision (8-byte) IEEE format.
Definition types.hpp:82
@ undefined
Exif UNDEFINED type, an 8-bit byte that may contain anything.
Definition types.hpp:77
@ xmpBag
XMP bag type.
Definition types.hpp:94
@ tiffFloat
TIFF FLOAT type, single precision (4-byte) IEEE format.
Definition types.hpp:81
@ unsignedRational
Exif RATIONAL type, two LONGs: numerator and denominator of a fraction.
Definition types.hpp:75
@ tiffIfd
TIFF IFD type, 32-bit (4-byte) unsigned integer.
Definition types.hpp:83
@ invalidTypeId
Invalid type id.
Definition types.hpp:97
@ directory
Exiv2 type for a CIFF directory.
Definition types.hpp:91
bool stringTo< bool >(const std::string &s, bool &ok)
Specialization of stringTo(const std::string& s, bool& ok) for bool.
Definition types.cpp:513
EXIV2API uint16_t getUShort(const byte *buf, ByteOrder byteOrder)
Read a 2 byte unsigned short value from the data buffer.
Definition types.cpp:246
EXIV2API size_t 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:372
EXIV2API int exifTime(const char *buf, 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:484
EXIV2API Rational parseRational(const std::string &s, bool &ok)
Return a Rational set to the value represented by s.
Definition types.cpp:586
EXIV2API uint32_t parseUint32(const std::string &s, bool &ok)
Return a uint32_t set to the value represented by s.
Definition types.cpp:556
EXIV2API size_t 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:378
ByteOrder
Type to express the byte order (little or big endian)
Definition types.hpp:34
T stringTo(const std::string &s, bool &ok)
Utility function to convert a string to a value of type T.
Definition types.hpp:483
EXIV2API uint64_t getULongLong(const byte *buf, ByteOrder byteOrder)
Read a 8 byte unsigned long value from the data buffer.
Definition types.cpp:257
EXIV2API size_t 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:389
WriteMethod
Type to indicate write method used by TIFF parsers.
Definition types.hpp:41
EXIV2API Rational getRational(const byte *buf, ByteOrder byteOrder)
Read an 8 byte signed rational value from the data buffer.
Definition types.cpp:290
EXIV2API size_t 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:404
EXIV2API size_t ull2Data(byte *buf, uint64_t l, ByteOrder byteOrder)
Convert an uint64_t to data, write the data to the buffer, return number of bytes written.
Definition types.cpp:357
MetadataId
An identifier for each type of metadata.
Definition types.hpp:47
EXIV2API int64_t parseInt64(const std::string &s, bool &ok)
Return a int64_t set to the value represented by s.
Definition types.cpp:530
EXIV2API std::istream & operator>>(std::istream &is, Rational &r)
Input operator for our fake rational.
Definition types.cpp:234
EXIV2API int32_t getLong(const byte *buf, ByteOrder byteOrder)
Read a 4 byte signed long value from the data buffer.
Definition types.cpp:283
std::string toStringHelper(const T &arg, std::true_type)
Utility function to convert the argument of any type to a string.
Definition types.hpp:456
std::vector< byte > Blob
Container for binary data.
Definition types.hpp:102
EXIV2API URational getURational(const byte *buf, ByteOrder byteOrder)
Read an 8 byte unsigned rational value from the data buffer.
Definition types.cpp:270
EXIV2API size_t 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:331
AccessMode
An identifier for each mode of metadata support.
Definition types.hpp:57
Utility class containing a character array. All it does is to take care of memory allocation and dele...
Definition types.hpp:124
DataBuf()=default
Default constructor.
value_type & at(size_t index)
Definition slice.hpp:174
Slice (= view) for STL containers.
Definition slice.hpp:421