Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Examples

Exiv2::IptcData Class Reference

A container for Iptc data. This is a top-level class of the Exiv2 library. More...

#include <iptc.hpp>

List of all members.

Public Types

typedef IptcMetadata::iterator iterator
 IptcMetadata iterator type.
typedef IptcMetadata::const_iterator const_iterator
 IptcMetadata const iterator type.

Public Member Functions

Manipulators
int read (const std::string &path)
 Read the Iptc data from file path.
int read (const byte *buf, long len)
 Read the Iptc data from a byte buffer. The format must follow the IPTC IIM4 standard.
int write (const std::string &path)
 Write the Iptc data to file path. If an Iptc data section already exists in the file, it is replaced. If there is no metadata to write, the Iptc data section is deleted from the file. Otherwise, an Iptc data section is created.
int writeIptcData (const std::string &path)
 Write the Iptc data to a binary file. By convention, the filename extension should be ".exv". This file format contains the Iptc data as it is found in a JPEG file. Exv files can be read with int read(const std::string& path) just like normal image files.
DataBuf copy ()
 Write the Iptc data to a data buffer and return the data buffer. Caller owns this buffer. The copied data follows the IPTC IIM4 standard.
Iptcdatumoperator[] (const std::string &key)
 Returns a reference to the Iptcdatum that is associated with a particular key. If IptcData does not already contain such an Iptcdatum, operator[] adds object Iptcdatum(key).
int add (const IptcKey &key, Value *value)
 Add an Iptcdatum from the supplied key and value pair. This method copies (clones) the value. A check for non-repeatable datasets is performed.
int add (const Iptcdatum &iptcdatum)
 Add a copy of the Iptcdatum to the Iptc metadata. A check for non-repeatable datasets is performed.
iterator erase (iterator pos)
 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.
void sortByKey ()
 Sort metadata by key.
void sortByTag ()
 Sort metadata by tag (aka dataset).
iterator begin ()
 Begin of the metadata.
iterator end ()
 End of the metadata.
iterator findKey (const IptcKey &key)
 Find a Iptcdatum with the given key, return an iterator to it. If multiple entries with the same key exist, it is undefined which of the matching metadata is found.
iterator findId (uint16_t dataset, uint16_t record=IptcDataSets::application2)
 Find a Iptcdatum with the given record and dataset it, return a const iterator to it. If multiple entries with the same Ids exists, it is undefined which of the matching metadata is found.
Accessors
int erase (const std::string &path) const
 Erase the Iptc data from file path.
const_iterator begin () const
 Begin of the metadata.
const_iterator end () const
 End of the metadata.
const_iterator findKey (const IptcKey &key) const
 Find an Iptcdatum with the given key, return a const iterator to it. If multiple metadata with the same key exist it is undefined which of the matching metadata is found.
const_iterator findId (uint16_t dataset, uint16_t record=IptcDataSets::application2) const
 Find a Iptcdatum with the given record and dataset number, return a const iterator to it. If multiple metadata with the same Ids exist it is undefined which of the matching metadata is found.
long count () const
 Get the number of metadata entries.
long size () const
 Return the exact size of all contained Iptc metadata.

Static Public Member Functions

static std::string strError (int rc, const std::string &path)
 Convert the return code from int read(const std::string& path), int read(const byte* buf, long len), int write(const std::string& path), int writeIptcData(const std::string& path), int erase(const std::string& path) const into an error message.


Detailed Description

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:

Examples:

iptceasy.cpp, and iptcprint.cpp.


Member Function Documentation

int Exiv2::IptcData::add const Iptcdatum iptcdatum  ) 
 

Add a copy of the Iptcdatum to the Iptc metadata. A check for non-repeatable datasets is performed.

Returns:
0 if successful;
6 if the dataset already exists and is not repeatable;

int Exiv2::IptcData::add const IptcKey key,
Value value
 

Add an Iptcdatum from the supplied key and value pair. This method copies (clones) the value. A check for non-repeatable datasets is performed.

Returns:
0 if successful;
6 if the dataset already exists and is not repeatable

DataBuf Exiv2::IptcData::copy  ) 
 

Write the Iptc data to a data buffer and return the data buffer. Caller owns this buffer. The copied data follows the IPTC IIM4 standard.

Returns:
Data buffer containing the Iptc data.

int Exiv2::IptcData::erase const std::string &  path  )  const
 

Erase the Iptc data from file path.

Parameters:
path Path to the file.
Returns:
0 if successful;
-2 if the file contains an unknown image type;
the return code of Image::writeMetadata() if the call to this function fails;

Iptcdatum & Exiv2::IptcData::operator[] const std::string &  key  ) 
 

Returns a reference to the Iptcdatum that is associated with a particular key. If IptcData does not already contain such an Iptcdatum, operator[] adds object Iptcdatum(key).

Note:
Since operator[] might insert a new element, it can't be a const member function.

int Exiv2::IptcData::read const byte buf,
long  len
 

Read the Iptc data from a byte buffer. The format must follow the IPTC IIM4 standard.

Parameters:
buf Pointer to the data buffer to read from
len Number of bytes in the data buffer
Returns:
0 if successful;
5 if Iptc data is invalid or corrupt;

int Exiv2::IptcData::read const std::string &  path  ) 
 

Read the Iptc data from file path.

Parameters:
path Path to the file
Returns:
0 if successful;
3 if the file contains no Iptc data;
the return code of Image::readMetadata() if the call to this function fails;
the return code of read(const char* buf, long len) if the call to this function fails;
Examples:
iptcprint.cpp.

std::string Exiv2::IptcData::strError int  rc,
const std::string &  path
[static]
 

Convert the return code from int read(const std::string& path), int read(const byte* buf, long len), int write(const std::string& path), int writeIptcData(const std::string& path), int erase(const std::string& path) const into an error message.

Todo: Implement global handling of error messages

Examples:
iptcprint.cpp.

int Exiv2::IptcData::write const std::string &  path  ) 
 

Write the Iptc data to file path. If an Iptc data section already exists in the file, it is replaced. If there is no metadata to write, the Iptc data section is deleted from the file. Otherwise, an Iptc data section is created.

Returns:
0 if successful;
-2 if the file contains an unknown image type;
the return code of Image::writeMetadata() if the call to this function fails;
Examples:
iptceasy.cpp.

int Exiv2::IptcData::writeIptcData const std::string &  path  ) 
 

Write the Iptc data to a binary file. By convention, the filename extension should be ".exv". This file format contains the Iptc data as it is found in a JPEG file. Exv files can be read with int read(const std::string& path) just like normal image files.

Returns:
0 if successful;
the return code of Image::writeMetadata() if the call to this function fails;


The documentation for this class was generated from the following files:
Generated on Sat Mar 5 19:54:24 2005 for Exiv2 by  doxygen 1.4.1