Exiv2
Public Types | Static Public Member Functions | List of all members
Exiv2::Internal::CiffComponent Class Referenceabstract

Interface class for components of the CIFF directory hierarchy of a CRW (Canon Raw data) image. Both CIFF directories as well as entries implement this interface. This class is implemented as NVI (non-virtual interface). More...

#include <crwimage_int.hpp>

Inheritance diagram for Exiv2::Internal::CiffComponent:
Inheritance graph
[legend]

Public Types

typedef std::auto_ptr< CiffComponentAutoPtr
 CiffComponent auto_ptr type.
 
typedef std::vector< CiffComponent * > Components
 Container type to hold all metadata.
 

Public Member Functions

Creators
 CiffComponent ()
 Default constructor.
 
 CiffComponent (uint16_t tag, uint16_t dir)
 Constructor taking a tag and directory.
 
virtual ~CiffComponent ()
 Virtual destructor.
 

Static Public Member Functions

static TypeId typeId (uint16_t tag)
 Return the type id for a tag.
 
static DataLocId dataLocation (uint16_t tag)
 Return the data location id for a tag.
 

Manipulators

void add (AutoPtr component)
 Add a component to the composition.
 
CiffComponentadd (CrwDirs &crwDirs, uint16_t crwTagId)
 Add crwTagId to the parse tree, if it doesn't exist yet. crwDirs contains the path of subdirectories, starting with the root directory, leading to crwTagId. Directories that don't exist yet are added along the way. Returns a pointer to the newly added component. More...
 
void remove (CrwDirs &crwDirs, uint16_t crwTagId)
 Remove crwTagId from the parse tree, if it exists yet. crwDirs contains the path of subdirectories, starting with the root directory, leading to crwTagId. More...
 
void read (const byte *pData, uint32_t size, uint32_t start, ByteOrder byteOrder)
 Read a component from a data buffer. More...
 
uint32_t write (Blob &blob, ByteOrder byteOrder, uint32_t offset)
 Write the metadata from the raw metadata component to the binary image blob. This method may append to the blob. More...
 
uint32_t writeValueData (Blob &blob, uint32_t offset)
 Writes the entry's value if size is larger than eight bytes. If needed, the value is padded with one 0 byte to make the number of bytes written to the blob even. The offset of the component is set to the offset passed in. More...
 
void setDir (uint16_t dir)
 Set the directory tag for this component.
 
void setValue (DataBuf buf)
 Set the data value of the entry.
 
virtual void doAdd (AutoPtr component)=0
 Implements add()
 
virtual CiffComponentdoAdd (CrwDirs &crwDirs, uint16_t crwTagId)
 Implements add(). The default implementation does nothing.
 
virtual void doRemove (CrwDirs &crwDirs, uint16_t crwTagId)
 Implements remove(). The default implementation does nothing.
 
virtual void doRead (const byte *pData, uint32_t size, uint32_t start, ByteOrder byteOrder)
 Implements read(). The default implementation reads a directory entry.
 
virtual uint32_t doWrite (Blob &blob, ByteOrder byteOrder, uint32_t offset)=0
 Implements write()
 
void setSize (uint32_t size)
 Set the size of the data area.
 
void setOffset (uint32_t offset)
 Set the offset for this component.
 

Accessors

void decode (Image &image, ByteOrder byteOrder) const
 Decode metadata from the component and add it to image. More...
 
void print (std::ostream &os, ByteOrder byteOrder, const std::string &prefix="") const
 Print debug info about a component to os. More...
 
void writeDirEntry (Blob &blob, ByteOrder byteOrder) const
 Write a directory entry for the component to the blob. If the size of the data is not larger than 8 bytes, the data is written to the directory entry.
 
uint16_t dir () const
 Return the tag of the directory containing this component.
 
uint16_t tag () const
 Return the tag of this component.
 
bool empty () const
 Return true if the component is empty, else false.
 
uint32_t size () const
 Return the data size of this component. More...
 
uint32_t offset () const
 Return the offset to the data from the start of the directory.
 
const bytepData () const
 Return a pointer to the data area of this component.
 
uint16_t tagId () const
 Return the tag id of this component.
 
TypeId typeId () const
 Return the type id of thi component.
 
DataLocId dataLocation () const
 Return the data location for this component.
 
CiffComponentfindComponent (uint16_t crwTagId, uint16_t crwDir) const
 Finds crwTagId in directory crwDir, returning a pointer to the component or 0 if not found.
 
virtual void doDecode (Image &image, ByteOrder byteOrder) const =0
 Implements decode()
 
virtual void doPrint (std::ostream &os, ByteOrder byteOrder, const std::string &prefix) const
 Implements print(). The default implementation prints the entry.
 
virtual bool doEmpty () const
 Implements empty(). Default implementation returns true if size is 0.
 
virtual CiffComponentdoFindComponent (uint16_t crwTagId, uint16_t crwDir) const
 Implements findComponent(). The default implementation checks the entry.
 

Detailed Description

Interface class for components of the CIFF directory hierarchy of a CRW (Canon Raw data) image. Both CIFF directories as well as entries implement this interface. This class is implemented as NVI (non-virtual interface).

Member Function Documentation

◆ add()

CiffComponent * Exiv2::Internal::CiffComponent::add ( CrwDirs crwDirs,
uint16_t  crwTagId 
)

Add crwTagId to the parse tree, if it doesn't exist yet. crwDirs contains the path of subdirectories, starting with the root directory, leading to crwTagId. Directories that don't exist yet are added along the way. Returns a pointer to the newly added component.

Parameters
crwDirsSubdirectory path from root to the subdirectory containing the tag to be added.
crwTagIdTag to be added.
Returns
A pointer to the newly added component.

References doAdd().

◆ decode()

void Exiv2::Internal::CiffComponent::decode ( Image image,
ByteOrder  byteOrder 
) const

Decode metadata from the component and add it to image.

Parameters
imageImage to add metadata to
byteOrderByte order

References doDecode().

Referenced by Exiv2::Internal::CiffHeader::decode().

◆ print()

void Exiv2::Internal::CiffComponent::print ( std::ostream &  os,
ByteOrder  byteOrder,
const std::string &  prefix = "" 
) const

Print debug info about a component to os.

Parameters
osOutput stream to write to
byteOrderByte order
prefixPrefix to be written before each line of output

References doPrint().

Referenced by Exiv2::Internal::CiffHeader::print().

◆ read()

void Exiv2::Internal::CiffComponent::read ( const byte pData,
uint32_t  size,
uint32_t  start,
ByteOrder  byteOrder 
)

Read a component from a data buffer.

Parameters
pDataPointer to the data buffer.
sizeNumber of bytes in the data buffer.
startComponent starts at pData + start.
byteOrderApplicable byte order (little or big endian).
Exceptions
ErrorIf the component cannot be parsed.

References doRead(), pData(), and size().

◆ remove()

void Exiv2::Internal::CiffComponent::remove ( CrwDirs crwDirs,
uint16_t  crwTagId 
)

Remove crwTagId from the parse tree, if it exists yet. crwDirs contains the path of subdirectories, starting with the root directory, leading to crwTagId.

Parameters
crwDirsSubdirectory path from root to the subdirectory containing the tag to be removed.
crwTagIdTag to be removed.

References doRemove().

Referenced by Exiv2::Internal::CiffHeader::remove().

◆ size()

uint32_t Exiv2::Internal::CiffComponent::size ( ) const
inline

Return the data size of this component.

Note
If the data is contained in the directory entry itself, this method returns 8, which is the maximum number of data bytes this component can have. The actual size, i.e., used data bytes, may be less than 8.

Referenced by Exiv2::CrwParser::decode(), doRead(), read(), Exiv2::Internal::CiffDirectory::readDirectory(), and setSize().

◆ write()

uint32_t Exiv2::Internal::CiffComponent::write ( Blob blob,
ByteOrder  byteOrder,
uint32_t  offset 
)

Write the metadata from the raw metadata component to the binary image blob. This method may append to the blob.

Parameters
blobBinary image to add metadata to
byteOrderByte order
offsetCurrent offset
Returns
New offset

References doWrite(), and offset().

Referenced by Exiv2::Internal::CiffHeader::write().

◆ writeValueData()

uint32_t Exiv2::Internal::CiffComponent::writeValueData ( Blob blob,
uint32_t  offset 
)

Writes the entry's value if size is larger than eight bytes. If needed, the value is padded with one 0 byte to make the number of bytes written to the blob even. The offset of the component is set to the offset passed in.

Parameters
blobThe binary image to write to.
offsetOffset from the start of the directory for this entry.
Returns
New offset.

References Exiv2::append(), dataLocation(), offset(), and tagId().


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