diff --git a/src/tiffparse.cpp b/src/tiffparse.cpp deleted file mode 100644 index e24f118c..00000000 --- a/src/tiffparse.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// ***************************************************************** -*- C++ -*- -// tiffparse.cpp, $Rev$ -// Print the structure of a TIFF file - -#include -#include -#include -#include -#include - -#include - -using namespace Exiv2; - -int main(int argc, char* const argv[]) -try { - if (argc != 2) { - std::cout << "Usage: " << argv[0] << " file\n"; - std::cout << "Print the structure of a TIFF file\n"; - return 1; - } - - FileIo io(argv[1]); - if(io.open() != 0) { - throw Error(9, io.path(), strError()); - } - IoCloser closer(io); - - // Ensure that this is the correct image type - if (!isTiffType(io, false)) { - if (io.error() || io.eof()) throw Error(14); - throw Error(3, "TIFF"); - } - - // Read the image into a memory buffer - long len = io.size(); - DataBuf buf(len); - io.read(buf.pData_, len); - if (io.error() || io.eof()) throw Error(14); - - TiffHeader tiffHeader; - if (!tiffHeader.read(buf.pData_, buf.size_)) throw Error(3, "TIFF"); - - TiffComponent::AutoPtr rootDir = TiffCreator::create(Tag::root, Group::none); - if (0 == rootDir.get()) { - throw Error(1, "No root element defined in TIFF structure"); - } - rootDir->setStart(buf.pData_ + tiffHeader.offset()); - - TiffRwState::AutoPtr state(new TiffRwState(tiffHeader.byteOrder(), 0)); - - TiffReader reader(buf.pData_, - buf.size_, - rootDir.get(), - state); - - rootDir->accept(reader); - - tiffHeader.print(std::cerr); - TiffPrinter tiffPrinter(std::cerr); - rootDir->accept(tiffPrinter); - - return 0; -} -catch (AnyError& e) { - std::cerr << e << "\n"; - return -1; -} diff --git a/src/tiffvisitor.cpp b/src/tiffvisitor.cpp index 7aadfbf6..92296c3b 100644 --- a/src/tiffvisitor.cpp +++ b/src/tiffvisitor.cpp @@ -912,126 +912,6 @@ namespace Exiv2 { } } // TiffEncoder::add - const std::string TiffPrinter::indent_(" "); - - void TiffPrinter::incIndent() - { - prefix_ += indent_; - } // TiffPrinter::incIndent - - void TiffPrinter::decIndent() - { - if (prefix_.length() >= indent_.length()) { - prefix_.erase(prefix_.length() - indent_.length(), indent_.length()); - } - } // TiffPrinter::decIndent - - void TiffPrinter::visitEntry(TiffEntry* object) - { - printTiffEntry(object, prefix()); - } // TiffPrinter::visitEntry - - void TiffPrinter::visitDataEntry(TiffDataEntry* object) - { - printTiffEntry(object, prefix()); - if (object->pValue()) { - os_ << prefix() << _("Data area") << " " - << object->pValue()->sizeDataArea() - << " " << _("bytes.\n"); - } - } // TiffPrinter::visitDataEntry - - void TiffPrinter::visitImageEntry(TiffImageEntry* object) - { - printTiffEntry(object, prefix()); - } // TiffPrinter::visitImageEntry - - void TiffPrinter::visitSizeEntry(TiffSizeEntry* object) - { - printTiffEntry(object, prefix()); - } - - void TiffPrinter::visitDirectory(TiffDirectory* object) - { - assert(object != 0); - os_ << prefix() << tiffGroupName(object->group()) - << " " << _("directory with") << " " - // cast to make MSVC happy - << std::dec << static_cast(object->components_.size()); - if (object->components_.size() == 1) os_ << " " << _("entry:\n"); - else os_ << " " << _("entries:\n"); - incIndent(); - - } // TiffPrinter::visitDirectory - - void TiffPrinter::visitDirectoryNext(TiffDirectory* object) - { - decIndent(); - if (object->hasNext()) { - if (object->pNext_) os_ << prefix() << _("Next directory:\n"); - else os_ << prefix() << _("No next directory\n"); - } - } // TiffPrinter::visitDirectoryNext - - void TiffPrinter::visitDirectoryEnd(TiffDirectory* /*object*/) - { - // Nothing to do - } // TiffPrinter::visitDirectoryEnd - - void TiffPrinter::visitSubIfd(TiffSubIfd* object) - { - os_ << prefix() << _("Sub-IFD") << " "; - printTiffEntry(object); - } // TiffPrinter::visitSubIfd - - void TiffPrinter::visitMnEntry(TiffMnEntry* object) - { - if (!object->mn_) printTiffEntry(object, prefix()); - else os_ << prefix() << _("Makernote") << " "; - } // TiffPrinter::visitMnEntry - - void TiffPrinter::visitIfdMakernote(TiffIfdMakernote* /*object*/) - { - // Nothing to do - } // TiffPrinter::visitIfdMakernote - - void TiffPrinter::printTiffEntry(TiffEntryBase* object, - const std::string& px) const - { - assert(object != 0); - - os_ << px << tiffGroupName(object->group()) - << " " << _("tag") << " 0x" << std::setw(4) << std::setfill('0') - << std::hex << std::right << object->tag() - << ", " << _("type") << " 0x" << std::hex << object->tiffType() - << ", " << std::dec << object->count() << " "<< _("component"); - if (object->count() > 1) os_ << "s"; - os_ << " in " << object->size() << " " << _("bytes"); - if (object->size() > 4) os_ << ", " << _("offset") << " " << object->offset(); - os_ << "\n"; - const Value* vp = object->pValue(); - if (vp && vp->count() < 100) os_ << prefix() << *vp; - else os_ << prefix() << "..."; - os_ << "\n"; - - } // TiffPrinter::printTiffEntry - - void TiffPrinter::visitArrayEntry(TiffArrayEntry* object) - { - os_ << prefix() << _("Array Entry") << " " << tiffGroupName(object->group()) - << " " << _("tag") << " 0x" << std::setw(4) << std::setfill('0') - << std::hex << std::right << object->tag() << " " << _("with") - << " " << std::dec << object->count() << " "; - if (object->count() > 1) os_ << _("elements"); - else os_ << _("element"); - os_ << "\n"; - } // TiffPrinter::visitArrayEntry - - void TiffPrinter::visitArrayElement(TiffArrayElement* object) - { - printTiffEntry(object, prefix()); - } // TiffPrinter::visitArrayElement - TiffReader::TiffReader(const byte* pData, uint32_t size, TiffComponent* pRoot, diff --git a/src/tiffvisitor_int.hpp b/src/tiffvisitor_int.hpp index 6a452b8c..e718d3f9 100644 --- a/src/tiffvisitor_int.hpp +++ b/src/tiffvisitor_int.hpp @@ -631,71 +631,6 @@ namespace Exiv2 { }; // class TiffReader - /*! - @brief TIFF composite visitor to print the TIFF structure to an output - stream. - */ - class TiffPrinter : public TiffVisitor { - public: - //! @name Creators - //@{ - //! Constructor, takes an output stream to write to. - TiffPrinter(std::ostream& os, const std::string& prefix ="") - : os_(os), prefix_(prefix) {} - //! Virtual destructor - virtual ~TiffPrinter() {} - //@} - - //! @name Manipulators - //@{ - //! Print a TIFF entry. - virtual void visitEntry(TiffEntry* object); - //! Print a TIFF data entry. - virtual void visitDataEntry(TiffDataEntry* object); - //! Print a TIFF image entry. - virtual void visitImageEntry(TiffImageEntry* object); - //! Print a TIFF size entry. - virtual void visitSizeEntry(TiffSizeEntry* object); - //! Print a TIFF directory - virtual void visitDirectory(TiffDirectory* object); - //! Print header before next directory - virtual void visitDirectoryNext(TiffDirectory* object); - //! Cleanup before leaving this directory - virtual void visitDirectoryEnd(TiffDirectory* object); - //! Print a TIFF sub-IFD - virtual void visitSubIfd(TiffSubIfd* object); - //! Print a TIFF makernote - virtual void visitMnEntry(TiffMnEntry* object); - //! Print an IFD makernote - virtual void visitIfdMakernote(TiffIfdMakernote* object); - //! Print an array entry component - virtual void visitArrayEntry(TiffArrayEntry* object); - //! Print an array element - virtual void visitArrayElement(TiffArrayElement* object); - - //! Increment the indent by one level - void incIndent(); - //! Decrement the indent by one level - void decIndent(); - //@} - - //! @name Accessors - //@{ - //! Print a standard TIFF entry. - void printTiffEntry(TiffEntryBase* object, - const std::string& prefix ="") const; - //! Return the current prefix - std::string prefix() const { return prefix_; } - //@} - - private: - // DATA - std::ostream& os_; //!< Output stream to write to - std::string prefix_; //!< Current prefix - - static const std::string indent_; //!< Indent for one level - }; // class TiffPrinter - }} // namespace Internal, Exiv2 #endif // #ifndef TIFFVISITOR_INT_HPP_