libopenraw  0.3.7
Public Types | Public Member Functions | Protected Attributes | List of all members
OpenRaw::Internals::IfdDir Class Reference

An IFD directory. More...

#include <ifddir.hpp>

Inheritance diagram for OpenRaw::Internals::IfdDir:
OpenRaw::Internals::CIFF::CiffIfd OpenRaw::Internals::MakerNoteDir OpenRaw::Internals::CIFF::CiffExifIfd OpenRaw::Internals::CIFF::CiffMainIfd OpenRaw::Internals::NonMakerNoteDir OpenRaw::Internals::OlympusMNoteDir

Public Types

typedef std::weak_ptr< IfdDirWeakRef
 Weak ptr of an IfdDir.
 
typedef std::shared_ptr< IfdDirRef
 Shared ptr of an IfdDir.
 
typedef std::vector< RefRefVec
 Vector of shared ptr of IfdDir. More...
 
typedef std::map< uint16_t, IfdEntry::RefEntries
 Ifd Entries map type. More...
 

Public Member Functions

 IfdDir (off_t _offset, RawContainer &_container, IfdDirType _type, const TagTable &tag_table=exif_tag_names)
 Construct an IfdDir. More...
 
IfdDirType type () const
 Get the type of the IfdDir.
 
void setType (IfdDirType type_)
 Set the type of the IfdDir.
 
off_t baseOffset () const
 Get the base offset for the data. More...
 
void setBaseOffset (off_t base)
 Set the base offset.
 
bool isPrimary () const
 The IFD is a primary in the TIFF/EP sense. More...
 
bool isThumbnail () const
 The IFD is for a thumnail. More...
 
off_t offset () const
 Return the offset.
 
const RawContainercontainer () const
 The container for the IfdDir, const.
 
RawContainercontainer ()
 The container for the IfdDir.
 
virtual bool load ()
 Load the directory to memory. More...
 
int numTags ()
 Return the number of entries.
 
IfdEntry::Ref getEntry (uint16_t id) const
 Get the IfdEntry for the tag id. More...
 
const Entriesentries () const
 Direct access to the entries.
 
RawContainer::EndianType endian () const
 the Container endian More...
 
void setEndian (RawContainer::EndianType _endian)
 Set the endian for the IFD. More...
 
template<typename T >
Option< T > getValue (uint16_t id) const
 Get a T value from an entry. More...
 
Option< uint32_t > getIntegerValue (uint16_t id)
 Get an loosely typed integer value from an entry. More...
 
off_t nextIFD ()
 Get the offset of the next IFD in absolute.
 
Ref getSubIFD (uint32_t idx=0) const
 Get the SubIFD at index idx. More...
 
Option< std::vector< IfdDir::Ref > > getSubIFDs ()
 Get all SubIFDs. More...
 
Ref getExifIFD ()
 Get the Exif IFD. More...
 
Ref getMakerNoteIfd (or_rawfile_type file_type)
 Get the MakerNote IFD. More...
 
void setTagTable (const TagTable &tag_table)
 Set the tag table for tag to name correspondance. More...
 
const char * getTagName (uint32_t tag) const
 Return the tag name for tag. More...
 
template<typename T >
Option< std::vector< T > > getEntryArrayValue (IfdEntry &e) const
 Get the entry value as an array. More...
 
template<typename T >
getEntryValue (IfdEntry &e, uint32_t idx=0, bool ignore_type=false) const
 Get the typed entry value. More...
 
uint32_t getEntryIntegerArrayItemValue (IfdEntry &e, int idx) const
 Return the integer value at index. It will coerce the type. More...
 
MetaValuemakeMetaValue (IfdEntry &e) const
 Make a meta value out of the IFD entry. More...
 

Protected Attributes

Entries m_entries
 

Detailed Description

An IFD directory.

Definition at line 51 of file ifddir.hpp.

Member Typedef Documentation

◆ Entries

Ifd Entries map type.

The key is the tag id of the entry.

Definition at line 66 of file ifddir.hpp.

◆ RefVec

Vector of shared ptr of IfdDir.

Used for situations like with IfdFileContainer.

Definition at line 61 of file ifddir.hpp.

Constructor & Destructor Documentation

◆ IfdDir()

OpenRaw::Internals::IfdDir::IfdDir ( off_t  _offset,
RawContainer _container,
IfdDirType  _type,
const TagTable &  tag_table = exif_tag_names 
)

Construct an IfdDir.

Parameters
_offsetThe offset from the begining of the container (where it starts)
_containerThe container
_typeThe IFD type.
tag_tableThe tag to name table. By default it is the Exif tags.

Definition at line 52 of file ifddir.cpp.

Member Function Documentation

◆ baseOffset()

off_t OpenRaw::Internals::IfdDir::baseOffset ( ) const
inline

Get the base offset for the data.

Usually it is 0.

Definition at line 88 of file ifddir.hpp.

◆ endian()

RawContainer::EndianType OpenRaw::Internals::IfdDir::endian ( ) const
inline

the Container endian

Usually it is the same as the file, but MakerNote are weird and might have a different idea.

Definition at line 137 of file ifddir.hpp.

Referenced by OpenRaw::Internals::CIFF::CiffMainIfd::load().

◆ getEntry()

IfdEntry::Ref OpenRaw::Internals::IfdDir::getEntry ( uint16_t  id) const

Get the IfdEntry for the tag id.

Requires load() to have been called once.

Returns
an IfdEntry::Ref. NULL if not found.

Definition at line 96 of file ifddir.cpp.

References m_entries.

Referenced by OpenRaw::Internals::MakerNoteDir::getIfdInEntry(), getIntegerValue(), getMakerNoteIfd(), getSubIFD(), getSubIFDs(), and getValue().

◆ getEntryIntegerArrayItemValue()

uint32_t OpenRaw::Internals::IfdDir::getEntryIntegerArrayItemValue ( IfdEntry e,
int  idx 
) const

Return the integer value at index. It will coerce the type.

Parameters
ethe IFD entry
idxthe index
Returns
the integer value or 0.

Definition at line 227 of file ifddir.cpp.

References OpenRaw::Internals::IfdEntry::type().

Referenced by getIntegerValue().

◆ getExifIFD()

IfdDir::Ref OpenRaw::Internals::IfdDir::getExifIFD ( )

Get the Exif IFD.

Returns
Ref to the new IfdDir if found

The SubIFD is located at offset found in the field EXIF_TAG_SUB_IFDS

Definition at line 179 of file ifddir.cpp.

◆ getIntegerValue()

Option< uint32_t > OpenRaw::Internals::IfdDir::getIntegerValue ( uint16_t  id)

Get an loosely typed integer value from an entry.

This method is preferred over getLongValue() or getShortValue() unless you really want the strong typing that IFD structure provide.

Parameters
idthe IFD field id
Returns
an Option<uint32_t> containing the value or none.

Definition at line 107 of file ifddir.cpp.

References getEntry(), and getEntryIntegerArrayItemValue().

◆ getMakerNoteIfd()

IfdDir::Ref OpenRaw::Internals::IfdDir::getMakerNoteIfd ( or_rawfile_type  file_type)

Get the MakerNote IFD.

Parameters
file_typethe file type as a hint
Returns
Ref to the new MakerNoteDir if found

Definition at line 197 of file ifddir.cpp.

References getEntry().

◆ getSubIFD()

IfdDir::Ref OpenRaw::Internals::IfdDir::getSubIFD ( uint32_t  idx = 0) const

Get the SubIFD at index idx.

Returns
Ref to the new IfdDir if found

The SubIFD is locate at offset found in the field EXIF_TAG_SUB_IFDS

Definition at line 137 of file ifddir.cpp.

References getEntry().

◆ getSubIFDs()

Option< std::vector< IfdDir::Ref > > OpenRaw::Internals::IfdDir::getSubIFDs ( )

Get all SubIFDs.

Returns
an option of ifds the list of IFDs Ref

Definition at line 157 of file ifddir.cpp.

References getEntry().

◆ getTagName()

const char * OpenRaw::Internals::IfdDir::getTagName ( uint32_t  tag) const

Return the tag name for tag.

Returns
a static string or nullptr if not found.

Definition at line 218 of file ifddir.cpp.

◆ getValue()

template<typename T >
Option<T> OpenRaw::Internals::IfdDir::getValue ( uint16_t  id) const
inline

Get a T value from an entry.

Parameters
idthe IFD field id
Returns
an Option<T> containing the value or none.

Definition at line 156 of file ifddir.hpp.

References getEntry().

◆ isPrimary()

bool OpenRaw::Internals::IfdDir::isPrimary ( ) const

The IFD is a primary in the TIFF/EP sense.

Returns
true if EXIF_TAG_NEW_SUBFILE_TYPE is 0.

Definition at line 40 of file ifddir.cpp.

◆ isThumbnail()

bool OpenRaw::Internals::IfdDir::isThumbnail ( ) const

The IFD is for a thumnail.

Returns
true if EXIF_TAG_NEW_SUBFILE_TYPE is 1.

Definition at line 46 of file ifddir.cpp.

◆ load()

bool OpenRaw::Internals::IfdDir::load ( )
virtual

Load the directory to memory.

The only reason you'd want to override is to synthesize an IFD from non-IFD.

Returns
true on success.

Reimplemented in OpenRaw::Internals::NonMakerNoteDir, OpenRaw::Internals::CIFF::CiffExifIfd, and OpenRaw::Internals::CIFF::CiffMainIfd.

Definition at line 65 of file ifddir.cpp.

References m_entries, OpenRaw::Internals::RawContainer::readInt16(), OpenRaw::Internals::RawContainer::readInt32(), OpenRaw::Internals::RawContainer::readUInt16(), and type().

◆ makeMetaValue()

MetaValue * OpenRaw::Internals::IfdDir::makeMetaValue ( IfdEntry e) const

Make a meta value out of the IFD entry.

Returns
a MetaValue or nullptr. Must be freed.

Definition at line 290 of file ifddir.cpp.

References OpenRaw::Internals::IfdEntry::type().

◆ setEndian()

void OpenRaw::Internals::IfdDir::setEndian ( RawContainer::EndianType  _endian)
inline

Set the endian for the IFD.

By default it's the same as the container but you might want to set it if, for example, parsing a MakerNote.

Definition at line 146 of file ifddir.hpp.

◆ setTagTable()

void OpenRaw::Internals::IfdDir::setTagTable ( const TagTable &  tag_table)
inline

Set the tag table for tag to name correspondance.

This is used to override the tag name in IFD that use non standard tags, like MakerNote or Panasonic RW2.

Definition at line 211 of file ifddir.hpp.

Member Data Documentation

◆ m_entries

Entries OpenRaw::Internals::IfdDir::m_entries
protected

The IFD entries

Definition at line 240 of file ifddir.hpp.

Referenced by entries(), getEntry(), load(), OpenRaw::Internals::CIFF::CiffExifIfd::load(), nextIFD(), and numTags().


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