types.hpp File Reference

Type definitions for Exiv2 and related functionality. More...

#include "exv_conf.h"
#include "version.hpp"
#include <string>
#include <vector>
#include <iosfwd>
#include <utility>
#include <algorithm>
#include <sstream>
#include <stdint.h>

Include dependency graph for types.hpp:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Namespaces

namespace  Exiv2

Classes

class  Exiv2::TypeInfo
 Type information lookup functions. Implemented as a static class. More...
struct  Exiv2::DataBufRef
 Auxiliary type to enable copies and assignments, similar to std::auto_ptr_ref. See http://www.josuttis.com/libbook/auto_ptr.html for a discussion. More...
class  Exiv2::DataBuf
 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. More...

Defines

#define EXV_CALL_MEMBER_FN(object, ptrToMember)   ((object).*(ptrToMember))
 Macro to make calls to member functions through a pointer more readable. See the C++ FAQ LITE, item [33.5] How can I avoid syntax errors when calling a member function using a pointer-to-member-function?.
#define EXV_MIN(a, b)   ((a) < (b) ? (a) : (b))
 Simple common min macro.
#define EXV_MAX(a, b)   ((a) > (b) ? (a) : (b))
 Simple common max macro.
#define EXV_COUNTOF(a)   (sizeof(Exiv2::sizer(a)))
 Macro to determine the size of an array.

Typedefs

typedef uint8_t byte
 1 byte unsigned integer type.
typedef std::pair< uint32_t,
uint32_t > 
URational
 8 byte unsigned rational type.
typedef std::pair< int32_t,
int32_t > 
Rational
 8 byte signed rational type.
typedef std::vector< byteBlob
 Container for binary data.

Enumerations

enum  ByteOrder { invalidByteOrder, littleEndian, bigEndian }
 Type to express the byte order (little or big endian).
enum  WriteMethod { wmIntrusive, wmNonIntrusive }
 Type to indicate write method used by TIFF parsers.
enum  MetadataId {
  mdNone = 0, mdExif = 1, mdIptc = 2, mdComment = 4,
  mdXmp = 8
}
 An identifier for each type of metadata.
enum  AccessMode { amNone = 0, amRead = 1, amWrite = 2, amReadWrite = 3 }
 An identifier for each mode of metadata support.
enum  TypeId {
  unsignedByte = 1, asciiString = 2, unsignedShort = 3, unsignedLong = 4,
  unsignedRational = 5, signedByte = 6, undefined = 7, signedShort = 8,
  signedLong = 9, signedRational = 10, tiffFloat = 11, tiffDouble = 12,
  tiffIfd = 13, string = 0x10000, date = 0x10001, time = 0x10002,
  comment = 0x10003, directory = 0x10004, xmpText = 0x10005, xmpAlt = 0x10006,
  xmpBag = 0x10007, xmpSeq = 0x10008, langAlt = 0x10009, invalidTypeId = 0x1fffe,
  lastTypeId = 0x1ffff
}
 Exiv2 value type identifiers. More...
enum  IfdId {
  ifdIdNotSet, ifd0Id, exifIfdId, gpsIfdId,
  iopIfdId, ifd1Id, ifd2Id, ifd3Id,
  subImage1Id, subImage2Id, subImage3Id, subImage4Id,
  mnIfdId, canonIfdId, canonCsIfdId, canonSiIfdId,
  canonCfIfdId, canonPiIfdId, canonPaIfdId, canonFiIfdId,
  fujiIfdId, minoltaIfdId, minoltaCs5DIfdId, minoltaCs7DIfdId,
  minoltaCsOldIfdId, minoltaCsNewIfdId, nikon1IfdId, nikon2IfdId,
  nikon3IfdId, nikonPvIfdId, nikonVrIfdId, nikonPcIfdId,
  nikonWtIfdId, nikonIiIfdId, nikonAfIfdId, nikonSi1IfdId,
  nikonSi2IfdId, nikonSi3IfdId, nikonSi4IfdId, nikonSi5IfdId,
  nikonSi6IfdId, nikonLd1IfdId, nikonLd2IfdId, nikonLd3IfdId,
  nikonCb1IfdId, nikonCb2IfdId, nikonCb2aIfdId, nikonCb2bIfdId,
  nikonCb3IfdId, nikonCb4IfdId, olympusIfdId, olympus2IfdId,
  olympusCsIfdId, olympusEqIfdId, olympusRdIfdId, olympusRd2IfdId,
  olympusIpIfdId, olympusFiIfdId, olympusFe1IfdId, olympusFe2IfdId,
  olympusFe3IfdId, olympusFe4IfdId, olympusFe5IfdId, olympusFe6IfdId,
  olympusFe7IfdId, olympusFe8IfdId, olympusFe9IfdId, olympusRiIfdId,
  panasonicIfdId, panaRawIfdId, pentaxIfdId, sigmaIfdId,
  sonyIfdId, lastIfdId
}
 Type to specify the IFD to which a metadata belongs.

Functions

template<typename T, typename K, int N>
const T * find (T(&src)[N], const K &key)
 Find an element that matches key in the array src.
template<typename T, int N>
 char (&sizer(T(&)[N]))[N]
 Template used in the COUNTOF macro to determine the size of an array.
template<typename T>
std::string toString (const T &arg)
 Utility function to convert the argument of any type to a string.
template<typename T>
stringTo (const std::string &s, bool &ok)
 Utility function to convert a string to a value of type T.
template<typename IntType>
IntType gcd (IntType n, IntType m)
 Return the greatest common denominator of n and m. (Implementation from Boost rational.hpp).

Detailed Description

Type definitions for Exiv2 and related functionality.

Version:
Rev
1983
Author:
Andreas Huggel (ahu) ahuggel@gmx.net
Date:
09-Jan-04, ahu: created
11-Feb-04, ahu: isolated as a component 31-Jul-04, brad: added Time, Data and String values

Enumeration Type Documentation

enum TypeId
 

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.

Enumeration values:
unsignedByte  Exif BYTE type, 8-bit unsigned integer.
asciiString  Exif ASCII type, 8-bit byte.
unsignedShort  Exif SHORT type, 16-bit (2-byte) unsigned integer.
unsignedLong  Exif LONG type, 32-bit (4-byte) unsigned integer.
unsignedRational  Exif RATIONAL type, two LONGs: numerator and denumerator of a fraction.
signedByte  Exif SBYTE type, an 8-bit signed (twos-complement) integer.
undefined  Exif UNDEFINED type, an 8-bit byte that may contain anything.
signedShort  Exif SSHORT type, a 16-bit (2-byte) signed (twos-complement) integer.
signedLong  Exif SLONG type, a 32-bit (4-byte) signed (twos-complement) integer.
signedRational  Exif SRATIONAL type, two SLONGs: numerator and denumerator of a fraction.
tiffFloat  TIFF FLOAT type, single precision (4-byte) IEEE format.
tiffDouble  TIFF DOUBLE type, double precision (8-byte) IEEE format.
tiffIfd  TIFF IFD type, 32-bit (4-byte) unsigned integer.
string  IPTC string type.
date  IPTC date type.
time  IPTC time type.
comment  Exiv2 type for the Exif user comment.
directory  Exiv2 type for a CIFF directory.
xmpText  XMP text type.
xmpAlt  XMP alternative type.
xmpBag  XMP bag type.
xmpSeq  XMP sequence type.
langAlt  XMP language alternative type.
invalidTypeId  Invalid type id.
lastTypeId  Last type id.


Function Documentation

template<typename T, typename K, int N>
const T* find T &  src[N],
const K &  key
 

Find an element that matches key in the array 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.

      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;
      }

template<typename IntType>
IntType gcd IntType  n,
IntType  m
 

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 T>
T stringTo const std::string &  s,
bool &  ok
 

Utility function to convert a string to a value of type T.

The string representation of the value must match that recognized by the input operator for T for this function to succeed.

Parameters:
s String to convert
ok Output variable indicating the success of the operation.
Returns:
Returns the converted value and sets ok to true if the conversion was successful or false if not.


Generated on Thu Dec 31 03:57:52 2009 for Exiv2 by  doxygen 1.3.9.1