[SCM] exiv2 packaging branch, master, updated. debian/0.25-3.1-3734-gdcbc29a
Maximiliano Curia
maxy at moszumanska.debian.org
Thu Jul 13 17:37:28 UTC 2017
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/exiv2.git;a=commitdiff;h=bec3e47
The following commit has been merged in the master branch:
commit bec3e47dfe9a1afd5a41df1ee835a9505ada5778
Author: Andreas Huggel <ahuggel at gmx.net>
Date: Tue Apr 4 13:24:07 2006 +0000
Second snapshot, still very experimental
---
src/tiffimage.cpp | 3 +-
src/tiffparser.cpp | 201 +++++++++++++++++++++++++++--------------------
src/tiffparser.hpp | 224 +++++++++++++++++++++++++++++++++--------------------
3 files changed, 259 insertions(+), 169 deletions(-)
diff --git a/src/tiffimage.cpp b/src/tiffimage.cpp
index 5346441..ad7c35a 100644
--- a/src/tiffimage.cpp
+++ b/src/tiffimage.cpp
@@ -145,7 +145,8 @@ namespace Exiv2 {
io_->read(buf.pData_, len);
if (io_->error() || io_->eof()) throw Error(14);
- TiffParser::decode(this, tiffStructure_, buf.pData_, buf.size_);
+ TiffMetadataDecoder decoder(this);
+ TiffParser::decode(buf.pData_, buf.size_, tiffStructure_, decoder);
} // TiffImage::readMetadata
void TiffImage::writeMetadata()
diff --git a/src/tiffparser.cpp b/src/tiffparser.cpp
index 7768556..c6fee7a 100644
--- a/src/tiffparser.cpp
+++ b/src/tiffparser.cpp
@@ -58,6 +58,13 @@ EXIV2_RCSID("@(#) $Id$");
Todo:
+ + Add child mgmt stuff to TIFF composite: add, remove, find
+ + Better encapsulate TiffStructure
+ + Remove read methods from Composite and turn them into a visitor
+ + Remove TiffStructure from Composite
+
+ in crwimage.* :
+
+ Fix CiffHeader according to TiffHeade2
+ Combine Error(15) and Error(33), add format argument %1
+ Search crwimage for todos, fix writeMetadata comment
@@ -70,12 +77,11 @@ EXIV2_RCSID("@(#) $Id$");
// class member definitions
namespace Exiv2 {
- void TiffParser::decode(Image* pImage,
+ void TiffParser::decode(const byte* pData,
+ uint32_t size,
const TiffStructure* pTiffStructure,
- const byte* pData,
- uint32_t size)
+ TiffVisitor& decoder)
{
- assert(pImage != 0);
assert(pData != 0);
TiffHeade2 tiffHeader;
@@ -84,7 +90,7 @@ namespace Exiv2 {
}
TiffComponent::AutoPtr rootDir
- = create(Tag::root, Group::none, pTiffStructure);
+ = TiffParser::create(Tag::root, Group::none, pTiffStructure);
if (0 == rootDir.get()) return;
rootDir->read(pData, size, tiffHeader.offset(), tiffHeader.byteOrder());
@@ -93,27 +99,31 @@ namespace Exiv2 {
rootDir->print(std::cerr, tiffHeader.byteOrder());
#endif
- rootDir->decode(*pImage, tiffHeader.byteOrder());
+ rootDir->accept(decoder);
} // TiffParser::decode
- TiffComponent::AutoPtr TiffParser::create(int32_t tag,
+ TiffComponent::AutoPtr TiffParser::create(uint32_t extendedTag,
uint16_t group,
const TiffStructure* pTiffStructure)
{
const TiffStructure* ts = 0;
- for (int i = 0; pTiffStructure[i].tag_ != Tag::none; ++i) {
- if (tag == pTiffStructure[i].tag_ && group == pTiffStructure[i].group_) {
- ts = &pTiffStructure[i];
+ int idx = 0;
+ for (; pTiffStructure[idx].extendedTag_ != Tag::none; ++idx) {
+ if ( extendedTag == pTiffStructure[idx].extendedTag_
+ && group == pTiffStructure[idx].group_) {
+ ts = &pTiffStructure[idx];
break;
}
}
+
TiffComponent::AutoPtr tc(0);
if (ts && ts->newTiffCompFct_) {
- tc = ts->newTiffCompFct_(ts->newGroup_, pTiffStructure);
+ tc = ts->newTiffCompFct_(pTiffStructure, idx);
}
if (!ts) {
- tc = TiffComponent::AutoPtr(new TiffEntry);
+ uint16_t tag = static_cast<uint16_t>(extendedTag & 0xffff);
+ tc = TiffComponent::AutoPtr(new TiffEntry(tag, group));
}
return tc;
} // TiffParser::create
@@ -130,7 +140,10 @@ namespace Exiv2 {
TiffEntryBase::~TiffEntryBase()
{
- if (isAllocated_) delete[] pData_;
+ if (isAllocated_) {
+ delete[] pData_;
+ }
+ delete pValue_;
} // TiffEntryBase::~TiffEntryBase
const uint16_t TiffHeade2::tag_ = 42;
@@ -162,29 +175,21 @@ namespace Exiv2 {
doRead(pData, size, start, byteOrder);
} // TiffComponent::read
- void TiffEntryBase::doRead(const byte* pData,
- uint32_t size,
- uint32_t start,
- ByteOrder byteOrder)
+ void TiffEntryBase::readEntry(const byte* pData,
+ uint32_t size,
+ uint32_t start,
+ ByteOrder byteOrder)
{
if (size - start < 12) throw Error(3, "TIFF");
const byte* p = pData + start;
- tag_ = getUShort(p, byteOrder);
+ // Component already has tag
p += 2;
- type_ = getUShort(p, byteOrder);
+ type_ = getUShort(p, byteOrder);
// todo: check type
p += 2;
- count_ = getULong(p, byteOrder);
+ count_ = getULong(p, byteOrder);
p += 4;
offset_ = getULong(p, byteOrder);
-#ifdef DEBUG
- std::cout << "TiffEntryBase for "
- << "tag 0x" << std::hex << tag_
- << ", type " << std::dec << type_
- << ", count " << count_
- << ", offset 0x" << std::hex << offset_
- << std::dec"
";
-#endif
size_ = TypeInfo::typeSize(typeId()) * count();
if (size_ > 4) {
if (size < offset() + size_) {
@@ -209,15 +214,17 @@ namespace Exiv2 {
else {
pData_ = pData + start + 8;
}
+ pValue_ = Value::create(typeId()).release();
+ if (pValue_) pValue_->read(pData_, size_, byteOrder);
- } // TiffEntryBase::doRead
+ } // TiffEntryBase::readEntry
void TiffEntry::doRead(const byte* pData,
uint32_t size,
uint32_t start,
ByteOrder byteOrder)
{
- TiffEntryBase::doRead(pData, size, start, byteOrder);
+ TiffEntryBase::readEntry(pData, size, start, byteOrder);
} // TiffEntry::doRead
void TiffDirectory::doRead(const byte* pData,
@@ -275,7 +282,7 @@ namespace Exiv2 {
uint32_t start,
ByteOrder byteOrder)
{
- TiffEntryBase::doRead(pData, size, start, byteOrder);
+ TiffEntryBase::readEntry(pData, size, start, byteOrder);
if (typeId() == unsignedLong && count() >= 1) {
uint32_t offset = getULong(this->pData(), byteOrder);
ifd_.read(pData, size, offset, byteOrder);
@@ -291,40 +298,6 @@ namespace Exiv2 {
#endif
} // TiffSubIfd::read
- void TiffComponent::decode(Image& image, ByteOrder byteOrder) const
- {
- doDecode(image, byteOrder);
- } // TiffComponent::decode
-
- void TiffEntryBase::doDecode(Image& image, ByteOrder byteOrder) const
- {
- ExifKey k(tag(), "Image"); // todo needs ifdItem
- TypeId t = typeId();
- Value::AutoPtr v = Value::create(t);
- v->read(pData_, size_, byteOrder);
- image.exifData().add(k, v.get());
- } // TiffEntryBase::doDecode
-
- void TiffEntry::doDecode(Image& image, ByteOrder byteOrder) const
- {
- TiffEntryBase::doDecode(image, byteOrder);
- } // TiffEntry::doDecode
-
- void TiffDirectory::doDecode(Image& image, ByteOrder byteOrder) const
- {
- Components::const_iterator b = components_.begin();
- Components::const_iterator e = components_.end();
- for (Components::const_iterator i = b; i != e; ++i) {
- (*i)->decode(image, byteOrder);
- }
- if (pNext_) pNext_->decode(image, byteOrder);
- } // TiffDirectory::doDecode
-
- void TiffSubIfd::doDecode(Image& image, ByteOrder byteOrder) const
- {
- ifd_.decode(image, byteOrder);
- } // TiffSubIfd::doDecode
-
void TiffHeade2::print(std::ostream& os, const std::string& prefix) const
{
os << prefix
@@ -339,9 +312,9 @@ namespace Exiv2 {
doPrint(os, byteOrder, prefix);
} // TiffComponent::print
- void TiffEntryBase::doPrint(std::ostream& os,
- ByteOrder byteOrder,
- const std::string& prefix) const
+ void TiffEntryBase::printEntry(std::ostream& os,
+ ByteOrder byteOrder,
+ const std::string& prefix) const
{
os << prefix
<< "tag = 0x" << std::setw(4) << std::setfill('0')
@@ -350,19 +323,17 @@ namespace Exiv2 {
<< ", count = " << std::dec << count()
<< ", offset = " << offset() << "
";
- TypeId t = typeId();
- Value::AutoPtr v = Value::create(t);
- v->read(pData_, size_, byteOrder);
- if (v->size() < 100) {
- os << prefix << *v << "
";
+ if (pValue_ && pValue_->size() < 100) {
+ os << prefix << *pValue_ << "
";
}
- } // TiffEntryBase::doPrint
+
+ } // TiffEntryBase::printEntry
void TiffEntry::doPrint(std::ostream& os,
ByteOrder byteOrder,
const std::string& prefix) const
{
- TiffEntryBase::doPrint(os, byteOrder, prefix);
+ TiffEntryBase::printEntry(os, byteOrder, prefix);
} // TiffEntry::doPrint
void TiffDirectory::doPrint(std::ostream& os,
@@ -383,29 +354,95 @@ namespace Exiv2 {
else {
os << prefix << "No next directory.
";
}
+
} // TiffDirectory::doPrint
void TiffSubIfd::doPrint(std::ostream& os,
ByteOrder byteOrder,
const std::string& prefix) const
{
- TiffEntryBase::doPrint(os, byteOrder, prefix);
+ TiffEntryBase::printEntry(os, byteOrder, prefix);
ifd_.print(os, byteOrder, prefix);
} // TiffSubIfd::doPrint
+ void TiffComponent::accept(TiffVisitor& visitor) const
+ {
+ doAccept(visitor);
+ } // TiffComponent::accept
+
+ void TiffEntry::doAccept(TiffVisitor& visitor) const
+ {
+ visitor.visitEntry(this);
+ } // TiffEntry::doAccept
+
+ void TiffDirectory::doAccept(TiffVisitor& visitor) const
+ {
+ visitor.visitDirectory(this);
+
+ Components::const_iterator b = components_.begin();
+ Components::const_iterator e = components_.end();
+ for (Components::const_iterator i = b; i != e; ++i) {
+ (*i)->accept(visitor);
+ }
+ if (pNext_) {
+ pNext_->accept(visitor);
+ }
+
+ } // TiffDirectory::doAccept
+
+ void TiffSubIfd::doAccept(TiffVisitor& visitor) const
+ {
+ visitor.visitSubIfd(this);
+ ifd_.accept(visitor);
+ } // TiffSubIfd::doAccept
+
+ void TiffMetadataDecoder::visitEntry(const TiffEntry* object)
+ {
+ decodeTiffEntry(object);
+ }
+
+ void TiffMetadataDecoder::visitDirectory(const TiffDirectory* object)
+ {
+ // Nothing to do
+ }
+
+ void TiffMetadataDecoder::visitSubIfd(const TiffSubIfd* object)
+ {
+ decodeTiffEntry(object);
+ }
+
+ void TiffMetadataDecoder::decodeTiffEntry(const TiffEntryBase* object)
+ {
+ // Todo: ExifKey should have an appropriate c'tor, this mapping should
+ // be a table and it belongs somewhere else
+ std::string group;
+ switch (object->group()) {
+ case 1: group = "Image"; break;
+ case 2: group = "Thumbnail"; break;
+ case 3: group = "Photo"; break;
+ case 4: group = "GPSInfo"; break;
+ case 5: group = "Iop"; break;
+ }
+
+ ExifKey k(object->tag(), group);
+ assert(pImage_ != 0);
+ pImage_->exifData().add(k, object->pValue());
+ } // TiffEntryBase::decodeTiffEntry
+
// *************************************************************************
// free functions
- TiffComponent::AutoPtr newTiffDirectory(uint16_t group,
- const TiffStructure* pTiffStructure)
+ TiffComponent::AutoPtr newTiffDirectory(const TiffStructure* ts, int i)
{
- return TiffComponent::AutoPtr(new TiffDirectory(group, pTiffStructure));
+ return TiffComponent::AutoPtr(new TiffDirectory(ts[i].tag(), ts[i].newGroup_, ts));
}
- TiffComponent::AutoPtr newTiffSubIfd(uint16_t group,
- const TiffStructure* pTiffStructure)
+ TiffComponent::AutoPtr newTiffSubIfd(const TiffStructure* ts, int i)
{
- return TiffComponent::AutoPtr(new TiffSubIfd(group, pTiffStructure));
+ return TiffComponent::AutoPtr(new TiffSubIfd(ts[i].tag(),
+ ts[i].group_,
+ ts[i].newGroup_,
+ ts));
}
} // namespace Exiv2
diff --git a/src/tiffparser.hpp b/src/tiffparser.hpp
index 015fbca..6e08b64 100644
--- a/src/tiffparser.hpp
+++ b/src/tiffparser.hpp
@@ -50,6 +50,7 @@ namespace Exiv2 {
// class declarations
struct TiffStructure;
+ class TiffVisitor;
// *****************************************************************************
// type definitions
@@ -76,20 +77,23 @@ namespace Exiv2 {
}
/*!
- Known TIFF tags
+ Special TIFF tags for the use in TIFF structures only
Todo: Same Q as above...
*/
namespace Tag {
- const int32_t none = -1; //!< Dummy tag
- const int32_t root = -2; //!< Special tag: root IFD
- const int32_t next = -3; //!< Special tag: next IFD
+ const uint32_t none = 0x10000; //!< Dummy tag
+ const uint32_t root = 0x20000; //!< Special tag: root IFD
+ const uint32_t next = 0x30000; //!< Special tag: next IFD
}
/*!
- @brief Interface class for components of a TIFF directory hierarchy. Both
- TIFF directories as well as entries implement this interface. This
- class is implemented as NVI (non-virtual interface).
+ @brief Interface class for components of a TIFF directory hierarchy
+ (Composite pattern). Both TIFF directories as well as entries
+ implement this interface. A component can be un iquely identified
+ bya tag, group tupel. This class is implemented as a NVI
+ (Non-Virtual Interface). It has an interface for visitors (Visitor
+ pattern).
*/
class TiffComponent {
public:
@@ -101,8 +105,10 @@ namespace Exiv2 {
//! @name Creators
//@{
//! Constructor
- TiffComponent(uint16_t group, const TiffStructure* pTiffStructure)
- : group_(group), pTiffStructure_(pTiffStructure) {}
+ TiffComponent(uint16_t tag,
+ uint16_t group,
+ const TiffStructure* pTiffStructure)
+ : tag_(tag), group_(group), pTiffStructure_(pTiffStructure) {}
//! Virtual destructor.
virtual ~TiffComponent() {}
@@ -128,19 +134,13 @@ namespace Exiv2 {
//! @name Accessors
//@{
- //*! Return the group id of this component
+ //! Return the tag of this entry.
+ uint16_t tag() const { return tag_; }
+ //! Return the group id of this component
uint16_t group() const { return group_; }
- //*! Return the TIFF structure
+ //! Return the TIFF structure
const TiffStructure* pTiffStructure() const { return pTiffStructure_; }
/*!
- @brief Decode metadata from the component and add it to
- \em image.
-
- @param image Image to add the metadata to
- @param byteOrder Byte order
- */
- void decode(Image& image, ByteOrder byteOrder) const;
- /*!
@brief Print debug info about a component to \em os.
@param os Output stream to write to
@@ -150,6 +150,12 @@ namespace Exiv2 {
void print(std::ostream& os,
ByteOrder byteOrder,
const std::string& prefix ="") const;
+ /*!
+ @brief Interface to accept visitors (Visitor pattern).
+
+ @param visitor The visitor.
+ */
+ void accept(TiffVisitor& visitor) const;
//@}
protected:
@@ -164,45 +170,43 @@ namespace Exiv2 {
//! @name Accessors
//@{
- //! Implements decode()
- virtual void doDecode(Image& image,
- ByteOrder byteOrder) const =0;
//! Implements print()
virtual void doPrint(std::ostream& os,
ByteOrder byteOrder,
const std::string& prefix) const =0;
+
+ //! Implements accept()
+ virtual void doAccept(TiffVisitor& visitor) const =0;
//@}
private:
// DATA
- uint16_t group_; //!< Group id for this component
+ uint16_t tag_; //!< Tag that identifies the component
+ uint16_t group_; //!< Group id for this component
const TiffStructure* pTiffStructure_; //!< TIFF structure for this component
}; // class TiffComponent
/*!
- @brief This baseclass provides the common functionality of an IFD directory entry
- and defines the interface for derived concrete entries.
-
- todo: make sure this class is an ABC
+ @brief This baseclass provides the common functionality of an IFD
+ directory entry and defines the interface for derived concrete
+ entries.
*/
class TiffEntryBase : public TiffComponent {
public:
//! @name Creators
//@{
//! Default constructor
- TiffEntryBase()
- : TiffComponent(Group::none, 0),
- tag_(0), type_(0), count_(0), offset_(0),
- size_(0), pData_(0), isAllocated_(false) {}
+ TiffEntryBase(uint16_t tag, uint16_t group)
+ : TiffComponent(tag, group, 0),
+ type_(0), count_(0), offset_(0),
+ size_(0), pData_(0), isAllocated_(false), pValue_(0) {}
//! Virtual destructor.
virtual ~TiffEntryBase();
//@}
//! @name Accessors
//@{
- //! Return the tag of this entry.
- uint16_t tag() const { return tag_; }
//! Return the Exiv2 type which corresponds to the field type.
TypeId typeId() const { return TypeId(type_); }
//! Return the number of components in this entry.
@@ -213,34 +217,29 @@ namespace Exiv2 {
uint32_t size() const { return size_; }
//! Return a pointer to the data area of this component
const byte* pData() const { return pData_; }
- //@}
+ //! Return a pointer to the converted value of this component
+ const Value* pValue() const { return pValue_; }
- protected:
- //! @name Manipulators
- //@{
- //! Implements read().
- virtual void doRead(const byte* pData,
- uint32_t size,
- uint32_t start,
- ByteOrder byteOrder);
+ //! Print base entry
+ void printEntry(std::ostream& os,
+ ByteOrder byteOrder,
+ const std::string& prefix) const;
//@}
- //! @name Accessors
+ //! @name Manipulators
//@{
- //! Implements decode() for a TIFF IFD entry
- virtual void doDecode(Image& image, ByteOrder byteOrder) const;
- //! Implements print() for a TIFF IFD entry
- virtual void doPrint(std::ostream& os,
- ByteOrder byteOrder,
- const std::string& prefix) const;
+ //! Read base entry
+ void readEntry(const byte* pData,
+ uint32_t size,
+ uint32_t start,
+ ByteOrder byteOrder);
//@}
private:
// DATA
- uint16_t tag_; //!< Tag that identifies the field
- uint16_t type_; //!< Field Type
- uint32_t count_; //!< The number of values of the indicated Type
- uint32_t offset_; //!< Offset to the data area from start of the TIFF header
+ uint16_t type_; //!< Field Type
+ uint32_t count_; //!< The number of values of the indicated Type
+ uint32_t offset_; //!< Offset to data area from start of TIFF header
/*!
Size of the data buffer holding the value in bytes, there is no
minimum size.
@@ -248,6 +247,7 @@ namespace Exiv2 {
uint32_t size_;
const byte* pData_; //!< Pointer to the data area
bool isAllocated_; //!< True if this entry owns the value data
+ Value* pValue_; //!< Converted data value
}; // class TiffEntryBase
@@ -258,6 +258,8 @@ namespace Exiv2 {
public:
//! @name Creators
//@{
+ //! Constructor
+ TiffEntry(uint16_t tag, uint16_t group) : TiffEntryBase(tag, group) {}
//! Virtual destructor.
virtual ~TiffEntry() {}
//@}
@@ -274,11 +276,10 @@ namespace Exiv2 {
//! @name Accessors
//@{
- virtual void doDecode(Image& image, ByteOrder byteOrder) const;
- //! Implements print() for a TIFF IFD entry
virtual void doPrint(std::ostream& os,
ByteOrder byteOrder,
const std::string& prefix) const;
+ virtual void doAccept(TiffVisitor& visitor) const;
//@}
}; // class TiffEntry
@@ -289,8 +290,8 @@ namespace Exiv2 {
//! @name Creators
//@{
//! Default constructor
- TiffDirectory(uint16_t group, const TiffStructure* pTiffStructure)
- : TiffComponent(group, pTiffStructure), pNext_(0) {}
+ TiffDirectory(uint16_t tag, uint16_t group, const TiffStructure* pTiffStructure)
+ : TiffComponent(tag, group, pTiffStructure), pNext_(0) {}
//! Virtual destructor
virtual ~TiffDirectory();
//@}
@@ -306,12 +307,11 @@ namespace Exiv2 {
//! @name Accessors
//@{
- virtual void doDecode(Image& image,
- ByteOrder byteOrder) const;
-
virtual void doPrint(std::ostream& os,
ByteOrder byteOrder,
const std::string& prefix) const;
+
+ virtual void doAccept(TiffVisitor& visitor) const;
//@}
private:
@@ -327,8 +327,11 @@ namespace Exiv2 {
//! @name Creators
//@{
//! Default constructor
- TiffSubIfd(uint16_t group, const TiffStructure* pTiffStructure)
- : ifd_(group, pTiffStructure) {}
+ TiffSubIfd(uint16_t tag,
+ uint16_t group,
+ uint16_t newGroup,
+ const TiffStructure* pTiffStructure)
+ : TiffEntryBase(tag, group), ifd_(tag, newGroup, pTiffStructure) {}
//! Virtual destructor
virtual ~TiffSubIfd() {}
//@}
@@ -344,12 +347,11 @@ namespace Exiv2 {
//! @name Accessors
//@{
- virtual void doDecode(Image& image,
- ByteOrder byteOrder) const;
-
virtual void doPrint(std::ostream& os,
ByteOrder byteOrder,
const std::string& prefix) const;
+
+ virtual void doAccept(TiffVisitor& visitor) const;
//@}
private:
@@ -422,20 +424,72 @@ namespace Exiv2 {
Todo: This may eventually need to also have access to the image or parse tree
in order to make decisions based on the value of other tags.
*/
- typedef TiffComponent::AutoPtr (*NewTiffCompFct)(uint16_t group,
- const TiffStructure* tiffStructure);
+ typedef TiffComponent::AutoPtr (*NewTiffCompFct)(const TiffStructure* ts, int i);
- /*!
- Table describing the TIFF structure of an image format for reading and writing.
- Different tables can be used to support different TIFF based image formats.
+ /*!
+ This structure is meant to be used as an entry (row) of a table describing
+ the TIFF structure of an image format for reading and writing. Different
+ tables can be used to support different TIFF based image formats.
*/
struct TiffStructure {
- int32_t tag_; //!< Tag
+ //! Return the tag corresponding to the extended tag
+ uint16_t tag() const { return static_cast<uint16_t>(extendedTag_ & 0xffff); }
+
+ uint32_t extendedTag_; //!< Tag (32 bit so that it can contain special tags)
uint16_t group_; //!< Group that contains the tag
NewTiffCompFct newTiffCompFct_; //!< Function to create the correct TIFF component
uint16_t newGroup_; //!< Group of the newly created component
};
+ //! Abstract base class for TIFF composite vistors (Visitor pattern)
+ class TiffVisitor {
+ public:
+ //! @name Creators
+ //@{
+ virtual ~TiffVisitor() {}
+ //@}
+
+ //! @name Manipulators
+ //@{
+ //! Decode a TIFF entry
+ virtual void visitEntry(const TiffEntry* object) =0;
+ //! Decode a TIFF directory
+ virtual void visitDirectory(const TiffDirectory* object) =0;
+ //! Decode a TIFF sub-IFD
+ virtual void visitSubIfd(const TiffSubIfd* object) =0;
+ //@}
+
+ }; // class TiffVisitor
+
+ /*!
+ TIFF composite visitor to decode metadata from the composite and add it
+ to an Image, which is supplied in the constructor.
+ */
+ class TiffMetadataDecoder : public TiffVisitor {
+ public:
+ //! @name Creators
+ //@{
+ //! Constructor
+ TiffMetadataDecoder(Image* pImage) : pImage_(pImage) {}
+ //! Virtual destructor
+ virtual ~TiffMetadataDecoder() {}
+ //@}
+
+ //! @name Manipulators
+ //@{
+ virtual void visitEntry(const TiffEntry* object);
+ virtual void visitDirectory(const TiffDirectory* object);
+ virtual void visitSubIfd(const TiffSubIfd* object);
+ //! Decode a standard TIFF entry
+ void decodeTiffEntry(const TiffEntryBase* object);
+ //@}
+
+ private:
+ // DATA
+ Image* pImage_; //!< Pointer to the image to which the metadata is added
+
+ }; // class TiffMetadataDecoder
+
/*!
Stateless parser class for data in TIFF format.
*/
@@ -448,29 +502,29 @@ namespace Exiv2 {
This is the entry point to access image data in TIFF format. The
parser uses classes TiffHeade2, TiffEntry, TiffDirectory.
- @param pImage Pointer to the %Exiv2 TIFF image to hold the
- metadata read from the buffer.
- @param pTiffStructure Pointer to a table describing the TIFF structure
- used to decode the data.
@param pData Pointer to the data buffer. Must point to data
in TIFF format; no checks are performed.
@param size Length of the data buffer.
+ @param pTiffStructure Pointer to a table describing the TIFF structure
+ used to decode the data.
+ @param decoder Reference to a TIFF visitor to decode and extract
+ the metadata from the TIFF composite structure.
@throw Error If the data buffer cannot be parsed.
*/
- static void decode( Image* pImage,
+ static void decode(const byte* pData,
+ uint32_t size,
const TiffStructure* pTiffStructure,
- const byte* pData,
- uint32_t size);
+ TiffVisitor& decoder);
/*!
@brief Create the appropriate TiffComponent to handle the \em tag in
\em group.
Uses table \em pTiffStructure to derive the correct component. If a
tag, group tupel is not found in the table, a TiffEntry is created. If
- the pointer that is returned is 0, then the tag should be ignored.
+ the pointer that is returned is 0, then the TIFF entry should be ignored.
*/
- static TiffComponent::AutoPtr create( int32_t tag,
+ static TiffComponent::AutoPtr create( uint32_t extendedTag,
uint16_t group,
const TiffStructure* pTiffStructure);
}; // class TiffParser
@@ -478,13 +532,11 @@ namespace Exiv2 {
// *****************************************************************************
// template, inline and free functions
- //!< Function to create and initialize a new TIFF directory
- TiffComponent::AutoPtr newTiffDirectory(uint16_t group,
- const TiffStructure* pTiffStructure);
+ //! Function to create and initialize a new TIFF directory
+ TiffComponent::AutoPtr newTiffDirectory(const TiffStructure* ts, int i);
- //!< Function to create and initialize a new TIFF sub-directory
- TiffComponent::AutoPtr newTiffSubIfd(uint16_t group,
- const TiffStructure* pTiffStructure);
+ //! Function to create and initialize a new TIFF sub-directory
+ TiffComponent::AutoPtr newTiffSubIfd(const TiffStructure* ts, int i);
} // namespace Exiv2
--
exiv2 packaging
More information about the pkg-kde-commits
mailing list