![]() |
Exiv2
|
TIFF composite visitor to encode metadata from an image to the TIFF tree. The metadata containers and root element of the tree are supplied in the constructor. Used by TiffParserWorker to encode the metadata into a TIFF composite. More...
#include <tiffvisitor_int.hpp>
Public Member Functions | |
Creators | |
TiffEncoder (ExifData &exifData, IptcData &iptcData, XmpData &xmpData, TiffComponent *pRoot, bool isNewImage, const PrimaryGroups *pPrimaryGroups, const TiffHeaderBase *pHeader, FindEncoderFct findEncoderFct) | |
Constructor, taking the root element of the composite to encode to, the image with the metadata to encode and a function to find special encoders. | |
TiffEncoder (const TiffEncoder &)=delete | |
TiffEncoder & | operator= (const TiffEncoder &)=delete |
~TiffEncoder () override=default | |
Virtual destructor. | |
![]() | |
virtual | ~TiffVisitor ()=default |
Virtual destructor. | |
void | setGo (GoEvent event, bool go) |
Set the stop/go flag: true for go, false for stop. | |
virtual void | visitDirectoryEnd (TiffDirectory *object) |
Operation to perform for a TIFF directory, at the end of the processing. | |
bool | go (GoEvent event) const |
Check if stop flag for event is clear, return true if it's clear. | |
Accessors | |
ByteOrder | byteOrder () const |
Return the applicable byte order. May be different for the Makernote and the rest of the TIFF entries. | |
bool | dirty () const |
True if any tag was deleted or allocated in the process of visiting a TIFF composite tree. | |
WriteMethod | writeMethod () const |
Return the write method used. | |
Manipulators | |
void | visitEntry (TiffEntry *object) override |
Encode a TIFF entry. | |
void | visitDataEntry (TiffDataEntry *object) override |
Encode a TIFF data entry. | |
void | visitImageEntry (TiffImageEntry *object) override |
Encode a TIFF image entry. | |
void | visitSizeEntry (TiffSizeEntry *object) override |
Encode a TIFF size entry. | |
void | visitDirectory (TiffDirectory *object) override |
Encode a TIFF directory. | |
void | visitDirectoryNext (TiffDirectory *object) override |
Update directory entries. | |
void | visitSubIfd (TiffSubIfd *object) override |
Encode a TIFF sub-IFD. | |
void | visitMnEntry (TiffMnEntry *object) override |
Encode a TIFF makernote. | |
void | visitIfdMakernote (TiffIfdMakernote *object) override |
Encode an IFD makernote. | |
void | visitIfdMakernoteEnd (TiffIfdMakernote *object) override |
Reset encoder to its original state, undo makernote specific settings. | |
void | visitBinaryArray (TiffBinaryArray *object) override |
Encode a binary array. | |
void | visitBinaryArrayEnd (TiffBinaryArray *object) override |
Re-encrypt binary array if necessary. | |
void | visitBinaryElement (TiffBinaryElement *object) override |
Encode an element of a binary array. | |
void | encodeTiffComponent (TiffEntryBase *object, const Exifdatum *datum=nullptr) |
Top level encoder function. Determines how to encode each TIFF component. This function is called by the visit methods of the encoder as well as the add() method. | |
void | encodeBinaryElement (TiffBinaryElement *object, const Exifdatum *datum) |
Callback encoder function for an element of a binary array. | |
void | encodeBinaryArray (TiffBinaryArray *object, const Exifdatum *datum) |
Callback encoder function for a binary array. | |
void | encodeDataEntry (TiffDataEntry *object, const Exifdatum *datum) |
Callback encoder function for a data entry. | |
void | encodeTiffEntry (TiffEntry *object, const Exifdatum *datum) |
Callback encoder function for a standard TIFF entry. | |
void | encodeImageEntry (TiffImageEntry *object, const Exifdatum *datum) |
Callback encoder function for an image entry. | |
void | encodeMnEntry (TiffMnEntry *object, const Exifdatum *datum) |
Callback encoder function for a Makernote entry. | |
void | encodeSizeEntry (TiffSizeEntry *object, const Exifdatum *datum) |
Callback encoder function for a size entry. | |
void | encodeSubIfd (TiffSubIfd *object, const Exifdatum *datum) |
Callback encoder function for a sub-IFD entry. | |
void | encodeTiffEntryBase (TiffEntryBase *object, const Exifdatum *datum) |
Special encoder function for the base part of a TIFF entry. | |
void | encodeOffsetEntry (TiffEntryBase *object, const Exifdatum *datum) |
Special encoder function for an offset entry. | |
void | encodeIptc (TiffEntryBase *object, const Exifdatum *datum) |
Special encoder function to encode SubIFD contents to Image group if it contains primary image data. | |
void | add (TiffComponent *pRootDir, TiffComponent *pSourceDir, uint32_t root) |
Add metadata from image to the TIFF composite. | |
void | setDirty (bool flag=true) |
Set the dirty flag and end of traversing signal. | |
Additional Inherited Members | |
![]() | |
enum | GoEvent { geTraverse = 0 , geKnownMakernote = 1 } |
Events for the stop/go flag. See setGo(). More... | |
TIFF composite visitor to encode metadata from an image to the TIFF tree. The metadata containers and root element of the tree are supplied in the constructor. Used by TiffParserWorker to encode the metadata into a TIFF composite.
For non-intrusive writing, the encoder is used as a visitor (by passing it to the accept() member of a TiffComponent). The composite tree is then traversed and metadata from the image is used to encode each existing component.
For intrusive writing, add() is called, which loops through the metadata and creates and populates corresponding TiffComponents as needed.
void Exiv2::Internal::TiffEncoder::add | ( | TiffComponent * | pRootDir, |
TiffComponent * | pSourceDir, | ||
uint32_t | root | ||
) |
Add metadata from image to the TIFF composite.
For each Exif metadatum, the corresponding TiffComponent is created if necessary and populated using encodeTiffComponent(). The add() function is used during intrusive writing, to create a new TIFF structure.
References Exiv2::Internal::TiffComponent::accept(), Exiv2::Internal::TiffComponent::addPath(), Exiv2::ExifData::begin(), encodeTiffComponent(), Exiv2::ExifData::end(), Exiv2::Internal::TiffCreator::getPath(), Exiv2::Internal::groupId(), Exiv2::Internal::TiffFinder::result(), and Exiv2::Internal::TiffComponent::tag().
Referenced by Exiv2::Internal::TiffParserWorker::encode().
void Exiv2::Internal::TiffEncoder::encodeIptc | ( | TiffEntryBase * | object, |
const Exifdatum * | datum | ||
) |
Special encoder function to encode SubIFD contents to Image group if it contains primary image data.
Special encoder function to encode IPTC data to an IPTCNAA or Photoshop ImageResources tag.
Referenced by TiffEncoder().
void Exiv2::Internal::TiffEncoder::encodeTiffComponent | ( | TiffEntryBase * | object, |
const Exifdatum * | datum = nullptr |
||
) |
Top level encoder function. Determines how to encode each TIFF component. This function is called by the visit methods of the encoder as well as the add() method.
If no datum is provided, search the metadata based on tag and group of the object. This is the case if the function is called from a visit method.
Then check if a special encoder function is registered for the tag, and if so use it to encode the object. Else use the callback encoder function at the object (which results in a double-dispatch to the appropriate encoding function of the encoder.
object | Object in the TIFF component tree to encode. |
datum | The corresponding metadatum with the updated value. |
References Exiv2::ExifData::begin(), Exiv2::ExifData::end(), Exiv2::ExifData::erase(), Exiv2::ExifData::findKey(), Exiv2::Internal::TiffComponent::group(), Exiv2::Internal::groupName(), Exiv2::Exifdatum::idx(), Exiv2::ExifKey::idx(), Exiv2::Internal::TiffEntryBase::idx(), Exiv2::ExifKey::key(), setDirty(), and Exiv2::Internal::TiffComponent::tag().
Referenced by add(), visitBinaryArray(), visitBinaryElement(), visitDataEntry(), visitEntry(), visitImageEntry(), visitMnEntry(), visitSizeEntry(), and visitSubIfd().
|
overridevirtual |
Encode a binary array.
Implements Exiv2::Internal::TiffVisitor.
References Exiv2::Internal::TiffBinaryArray::cfg(), Exiv2::Internal::TiffBinaryArray::decoded(), and encodeTiffComponent().
|
overridevirtual |
Re-encrypt binary array if necessary.
Reimplemented from Exiv2::Internal::TiffVisitor.
References Exiv2::DataBuf::c_data(), Exiv2::Internal::TiffBinaryArray::cfg(), Exiv2::Internal::TiffBinaryArray::decoded(), Exiv2::Internal::TiffBinaryArray::initialize(), setDirty(), Exiv2::Internal::TiffComponent::tag(), and Exiv2::Internal::TiffBinaryArray::updOrigDataBuf().
|
overridevirtual |
Encode an element of a binary array.
Implements Exiv2::Internal::TiffVisitor.
References Exiv2::Internal::TiffBinaryElement::elByteOrder(), and encodeTiffComponent().
|
overridevirtual |
Encode a TIFF data entry.
Implements Exiv2::Internal::TiffVisitor.
References encodeTiffComponent().
|
overridevirtual |
Encode a TIFF directory.
Implements Exiv2::Internal::TiffVisitor.
|
overridevirtual |
|
overridevirtual |
|
overridevirtual |
Encode an IFD makernote.
Implements Exiv2::Internal::TiffVisitor.
References Exiv2::Internal::TiffIfdMakernote::byteOrder(), Exiv2::ExifData::end(), Exiv2::ExifData::erase(), Exiv2::ExifData::findKey(), and setDirty().
|
overridevirtual |
Reset encoder to its original state, undo makernote specific settings.
Reimplemented from Exiv2::Internal::TiffVisitor.
|
overridevirtual |
Encode a TIFF image entry.
Implements Exiv2::Internal::TiffVisitor.
References encodeTiffComponent().
|
overridevirtual |
Encode a TIFF makernote.
Implements Exiv2::Internal::TiffVisitor.
References encodeTiffComponent(), Exiv2::ExifData::end(), Exiv2::ExifData::erase(), Exiv2::ExifData::findKey(), Exiv2::Internal::TiffComponent::group(), Exiv2::Internal::groupName(), and Exiv2::Internal::TiffComponent::tag().
|
overridevirtual |
Encode a TIFF size entry.
Implements Exiv2::Internal::TiffVisitor.
References encodeTiffComponent().
|
overridevirtual |