types.hpp File Reference

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

#include "exv_conf.h"
#include "version.hpp"
#include <string>
#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

struct  Exiv2::TypeInfoTable
 Information pertaining to the defined types. More...
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. Todo: this should be some sort of smart pointer, essentially an std::auto_ptr for a character array. But it isn't... 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_COUNTOF(a)   (sizeof(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.

Enumerations

enum  ByteOrder { invalidByteOrder, littleEndian, bigEndian }
 Type to express the byte order (little or big endian).
enum  MetadataId { mdExif = 1, mdIptc = 2, mdComment = 4 }
 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 {
  invalidTypeId, unsignedByte, asciiString, unsignedShort,
  unsignedLong, unsignedRational, invalid6, undefined,
  signedShort, signedLong, signedRational, string,
  date, time, comment, directory,
  lastTypeId
}
 Type identifiers for IFD format types.
enum  IfdId {
  ifdIdNotSet, ifd0Id, exifIfdId, gpsIfdId,
  iopIfdId, ifd1Id, canonIfdId, canonCsIfdId,
  canonSiIfdId, canonCfIfdId, canonPiIfdId, canonPaIfdId,
  fujiIfdId, minoltaIfdId, minoltaCs5DIfdId, minoltaCs7DIfdId,
  minoltaCsOldIfdId, minoltaCsNewIfdId, nikon1IfdId, nikon2IfdId,
  nikon3IfdId, olympusIfdId, panasonicIfdId, sigmaIfdId,
  sonyIfdId, lastIfdId
}
 Type to specify the IFD to which a metadata belongs.
enum  DataLocId { invalidDataLocId, valueData, directoryData, lastDataLocId }
 Type to identify where the data is stored in a directory.

Functions

uint16_t getUShort (const byte *buf, ByteOrder byteOrder)
 Read a 2 byte unsigned short value from the data buffer.
uint32_t getULong (const byte *buf, ByteOrder byteOrder)
 Read a 4 byte unsigned long value from the data buffer.
URational getURational (const byte *buf, ByteOrder byteOrder)
 Read an 8 byte unsigned rational value from the data buffer.
int16_t getShort (const byte *buf, ByteOrder byteOrder)
 Read a 2 byte signed short value from the data buffer.
int32_t getLong (const byte *buf, ByteOrder byteOrder)
 Read a 4 byte signed long value from the data buffer.
Rational getRational (const byte *buf, ByteOrder byteOrder)
 Read an 8 byte signed rational value from the data buffer.
std::ostream & operator<< (std::ostream &os, const Rational &r)
 Output operator for our fake rational.
std::istream & operator>> (std::istream &is, Rational &r)
 Input operator for our fake rational.
std::ostream & operator<< (std::ostream &os, const URational &r)
 Output operator for our fake unsigned rational.
std::istream & operator>> (std::istream &is, URational &r)
 Input operator for our fake unsigned rational.
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.
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.
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.
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.
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.
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.
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 the buffer adjusted by offset.
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, false otherwise. If size is 0, any number of digits is allowed and all are checked.
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 format, returns 0 if successful, else 1.
const char * exvGettext (const char *str)
 Translate a string using the gettext framework. This wrapper hides all the implementation details from the interface.
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 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
1071
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

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...


Generated on Wed Jul 11 11:16:58 2007 for Exiv2 by  doxygen 1.3.9.1