- Main Page
- Namespaces
- Classes
- Files
- Examples

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# Exiv2::JpegBase Class Reference

Abstract helper base class to access JPEG images. More...

`#include <jpgimage.hpp>`

Inheritance diagram for Exiv2::JpegBase:

[legend]
Collaboration diagram for Exiv2::JpegBase:

[legend]
List of all members.

## Public Member Functions
Creators
virtual | ~JpegBase ()
| Virtual destructor.
Manipulators
void | readMetadata ()
| Read all metadata supported by a specific image format from the image. Before this method is called, the various metadata types will be empty.
void | writeMetadata ()
| Write metadata back to the image.
void | setExifData (const ExifData &exifData)
| Assign new exif data. The new exif data is not written to the image until the writeMetadata() method is called.
void | clearExifData ()
| Erase any buffered Exif data. Exif data is not removed from the actual image until the writeMetadata() method is called.
void | setIptcData (const IptcData &iptcData)
| Assign new iptc data. The new iptc data is not written to the image until the writeMetadata() method is called.
void | clearIptcData ()
| Erase any buffered Iptc data. Iptc data is not removed from the actual image until the writeMetadata() method is called.
void | setComment (const std::string &comment)
| Set the image comment. The new comment is not written to the image until the writeMetadata() method is called.
void | clearComment ()
| Erase any buffered comment. Comment is not removed from the actual image until the writeMetadata() method is called.
void | setMetadata (const Image &image)
| Copy all existing metadata from source Image. The data is copied into internal buffers and is not written to the image until the writeMetadata() method is called.
void | clearMetadata ()
| Erase all buffered metadata. Metadata is not removed from the actual image until the writeMetadata() method is called.
Accessors
bool | good () const
| Check if the Image instance is valid. Use after object construction.
const ExifData & | exifData () const
| Returns an ExifData instance containing currently buffered Exif data.
ExifData & | exifData ()
| Returns an ExifData instance containing currently buffered Exif data.
const IptcData & | iptcData () const
| Returns an IptcData instance containing currently buffered Iptc data.
IptcData & | iptcData ()
| Returns an IptcData instance containing currently buffered Iptc data.
std::string | comment () const
| Return a copy of the image comment. May be an empty string.
BasicIo & | io () const
| Return a reference to the BasicIo instance being used for Io.
## Protected Member Functions
Creators
| JpegBase (BasicIo::AutoPtr io, bool create, const byte initData[], long dataSize)
| Constructor that can either open an existing image or create a new image from scratch. If a new image is to be created, any existing data is overwritten.
Manipulators
virtual int | writeHeader (BasicIo &oIo) const =0
| Writes the image header (aka signature) to the BasicIo instance.
Accessors
virtual bool | isThisType (BasicIo &iIo, bool advance) const =0
| Determine if the content of the BasicIo instance is of the type supported by this class.
## Static Protected Attributes
static const byte | sos_ = 0xda
| JPEG SOS marker.
static const byte | eoi_ = 0xd9
| JPEG EOI marker.
static const byte | app0_ = 0xe0
| JPEG APP0 marker.
static const byte | app1_ = 0xe1
| JPEG APP1 marker.
static const byte | app13_ = 0xed
| JPEG APP13 marker.
static const byte | com_ = 0xfe
| JPEG Comment marker.
static const char | exifId_ [] = "Exif\0\0"
| Exif identifier.
static const char | jfifId_ [] = "JFIF\0"
| JFIF identifier.

## Detailed Description

Abstract helper base class to access JPEG images.

## Constructor & Destructor Documentation

Exiv2::JpegBase::JpegBase | ( | BasicIo::AutoPtr | io,
|  | bool | create,
|  | const byte | initData[],
|  | long | dataSize
| ) | `[protected]`

  | Constructor that can either open an existing image or create a new image from scratch. If a new image is to be created, any existing data is overwritten. Parameters:
  | io | An auto-pointer that owns a BasicIo instance used for reading and writing image metadata. Important: The constructor takes ownership of the passed in BasicIo instance through the auto-pointer. Callers should not continue to use the BasicIo instance after it is passed to this method. Use the Image::io() method to get a temporary reference.
  | create | Specifies if an existing image should be read (false) or if a new image should be created (true).
  | initData | Data to initialize newly created images. Only used when create is true. Should contain data for the smallest valid image of the calling subclass.
  | dataSize | Size of initData in bytes.

## Member Function Documentation

ExifData& Exiv2::JpegBase::exifData | ( |  | ) | `[inline, virtual]`

| Returns an ExifData instance containing currently buffered Exif data. The contained Exif data may have been read from the image by a previous call to readMetadata() or added directly. The Exif data in the returned instance will be written to the image when writeMetadata() is called. Returns: modifiable ExifData instance containing Exif values Implements Exiv2::Image.

const ExifData& Exiv2::JpegBase::exifData | ( |  | ) | const`[inline, virtual]`

| Returns an ExifData instance containing currently buffered Exif data. The Exif data may have been read from the image by a previous call to readMetadata() or added directly. The Exif data in the returned instance will be written to the image when writeMetadata() is called. Returns: read only ExifData instance containing Exif values Implements Exiv2::Image.

bool Exiv2::JpegBase::good | ( |  | ) | const`[virtual]`

| Check if the Image instance is valid. Use after object construction. Returns: true if the Image is in a valid state. Implements Exiv2::Image.

BasicIo& Exiv2::JpegBase::io | ( |  | ) | const`[inline, virtual]`

| Return a reference to the BasicIo instance being used for Io. This refence is particularly useful to reading the results of operations on a MemIo instance. For example after metadata has been modified and the writeMetadata() method has been called, this method can be used to get access to the modified image. Returns: BasicIo instance that can be used to read or write image data directly. Note: If the returned BasicIo is used to write to the image, the Image class will not see those changes until the readMetadata() method is called. Implements Exiv2::Image.

IptcData& Exiv2::JpegBase::iptcData | ( |  | ) | `[inline, virtual]`

| Returns an IptcData instance containing currently buffered Iptc data. The contained Iptc data may have been read from the image by a previous call to readMetadata() or added directly. The Iptc data in the returned instance will be written to the image when writeMetadata() is called. Returns: modifiable IptcData instance containing Iptc values Implements Exiv2::Image.

const IptcData& Exiv2::JpegBase::iptcData | ( |  | ) | const`[inline, virtual]`

| Returns an IptcData instance containing currently buffered Iptc data. The contained Iptc data may have been read from the image by a previous call to readMetadata() or added directly. The Iptc data in the returned instance will be written to the image when writeMetadata() is called. Returns: modifiable IptcData instance containing Iptc values Implements Exiv2::Image.

virtual bool Exiv2::JpegBase::isThisType | ( | BasicIo & | iIo,
|  | bool | advance
| ) | const`[protected, pure virtual]`

  | Determine if the content of the BasicIo instance is of the type supported by this class. The advance flag determines if the read position in the stream is moved (see below). This applies only if the type matches and the function returns true. If the type does not match, the stream position is not changed. However, if reading from the stream fails, the stream position is undefined. Consult the stream state to obtain more information in this case. Parameters:
  | iIo | BasicIo instance to read from.
  | advance | Flag indicating whether the position of the io should be advanced by the number of characters read to analyse the data (true) or left at its original position (false). This applies only if the type matches.
Returns: true if the data matches the type of this class; false if the data does not match Implemented in Exiv2::JpegImage, and Exiv2::ExvImage.

void Exiv2::JpegBase::readMetadata | ( |  | ) | `[virtual]`

  | Read all metadata supported by a specific image format from the image. Before this method is called, the various metadata types will be empty. This method returns success even if no metadata is found in the image. Callers must therefore check the size of individual metadata types before accessing the data. Exceptions:
  | Error | if opening or reading of the file fails or the image data is not valid (does not look like data of the specific image type).
Implements Exiv2::Image.

void Exiv2::JpegBase::setComment | ( | const std::string & | comment | ) | `[virtual]`

  | Set the image comment. The new comment is not written to the image until the writeMetadata() method is called. Parameters:
  | comment | String containing comment.
Implements Exiv2::Image.

void Exiv2::JpegBase::setExifData | ( | const ExifData & | exifData | ) | `[virtual]`

  | Assign new exif data. The new exif data is not written to the image until the writeMetadata() method is called. Parameters:
  | exifData | An ExifData instance holding exif data to be copied
Implements Exiv2::Image.

void Exiv2::JpegBase::setIptcData | ( | const IptcData & | iptcData | ) | `[virtual]`

  | Assign new iptc data. The new iptc data is not written to the image until the writeMetadata() method is called. Parameters:
  | iptcData | An IptcData instance holding iptc data to be copied
Implements Exiv2::Image.

void Exiv2::JpegBase::setMetadata | ( | const Image & | image | ) | `[virtual]`

  | Copy all existing metadata from source Image. The data is copied into internal buffers and is not written to the image until the writeMetadata() method is called. Parameters:
  | image | Metadata source. All metadata types are copied.
Implements Exiv2::Image.

virtual int Exiv2::JpegBase::writeHeader | ( | BasicIo & | oIo | ) | const`[protected, pure virtual]`

  | Writes the image header (aka signature) to the BasicIo instance. Parameters:
  | oIo | BasicIo instance that the header is written to.
Returns: 0 if successful; 4 if the output file can not be written to Implemented in Exiv2::JpegImage, and Exiv2::ExvImage.

void Exiv2::JpegBase::writeMetadata | ( |  | ) | `[virtual]`

  | Write metadata back to the image. All existing metadata sections in the image are either created, replaced, or erased. If values for a given metadata type have been assigned, a section for that metadata type will either be created or replaced. If no values have been assigned to a given metadata type, any exists section for that metadata type will be removed from the image. Exceptions:
  | Error | if the operation fails
Implements Exiv2::Image.

The documentation for this class was generated from the following files:

- jpgimage.hpp
- jpgimage.cpp