diff --git a/config/aclocal.m4 b/config/aclocal.m4 index 640dd390..4637eb66 100644 --- a/config/aclocal.m4 +++ b/config/aclocal.m4 @@ -8078,3 +8078,92 @@ else fi AC_SUBST($1)dnl ]) + +# =========================================================================== +# http://autoconf-archive.cryp.to/ax_cxx_check_flag.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CXX_CHECK_FLAG(FLAG-TO-CHECK,[PROLOGUE],[BODY],[ACTION-IF-SUCCESS],[ACTION-IF-FAILURE]) +# +# DESCRIPTION +# +# This macro tests if the C++ compiler supports the flag FLAG-TO-CHECK. If +# successfull execute ACTION-IF-SUCCESS otherwise ACTION-IF-FAILURE. +# PROLOGUE and BODY are optional and should be used as in AC_LANG_PROGRAM +# macro. +# +# This code is inspired from KDE_CHECK_COMPILER_FLAG macro. Thanks to +# Bogdan Drozdowski for testing and bug fixes. +# +# LAST MODIFICATION +# +# 2008-04-12 +# +# COPYLEFT +# +# Copyright (c) 2008 Francesco Salvestrini +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Macro Archive. When you make and +# distribute a modified version of the Autoconf Macro, you may extend this +# special exception to the GPL to apply to your modified version as well. + +AC_DEFUN([AX_CXX_CHECK_FLAG],[ + AC_PREREQ([2.61]) + AC_REQUIRE([AC_PROG_CXX]) + AC_REQUIRE([AC_PROG_SED]) + + flag=`echo "$1" | $SED 'y% .=/+-(){}<>:*,%_______________%'` + + AC_CACHE_CHECK([whether the C++ compiler accepts the $1 flag], + [ax_cv_cxx_check_flag_$flag],[ + + AC_LANG_PUSH([C++]) + + save_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS $1" + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([$2],[$3]) + ],[ + eval "ax_cv_cxx_check_flag_$flag=yes" + ],[ + eval "ax_cv_cxx_check_flag_$flag=no" + ]) + + CXXFLAGS="$save_CXXFLAGS" + + AC_LANG_POP + + ]) + + AS_IF([eval "test \"`echo '$ax_cv_cxx_check_flag_'$flag`\" = yes"],[ + : + $4 + ],[ + : + $5 + ]) +]) diff --git a/config/config.h.in b/config/config.h.in index 688ae84a..733f833f 100644 --- a/config/config.h.in +++ b/config/config.h.in @@ -126,6 +126,12 @@ slash. */ #undef LSTAT_FOLLOWS_SLASHED_SYMLINK +/* Define if g++ supports C++ visibility features */ +#undef HAVE_GXXCLASSVISIBILITY + +/* Define if we have / are building a shared library (DLL) */ +#undef HAVE_DLL + /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT @@ -192,3 +198,34 @@ #define SEPERATOR_STR "/" #define SEPERATOR_CHR '/' #endif + +/* Shared library support, see http://gcc.gnu.org/wiki/Visibility */ +#ifdef WIN32 +# define EXV_IMPORT __declspec(dllimport) +# define EXV_EXPORT __declspec(dllexport) +# define EXV_DLLLOCAL +# define EXV_DLLPUBLIC +#else +# ifdef EXV_HAVE_GXXCLASSVISIBILITY +# define EXV_IMPORT __attribute__ ((visibility("default"))) +# define EXV_EXPORT __attribute__ ((visibility("default"))) +# define EXV_DLLLOCAL __attribute__ ((visibility("hidden"))) +# define EXV_DLLPUBLIC __attribute__ ((visibility("default"))) +# else +# define EXV_IMPORT +# define EXV_EXPORT +# define EXV_DLLLOCAL +# define EXV_DLLPUBLIC +# endif /* ! EXV_HAVE_GXXCLASSVISIBILITY */ +#endif /* ! WIN32 */ + +/* Define EXIV2API for DLL builds */ +#ifdef EXV_HAVE_DLL +# ifdef EXV_BUILDING_LIB +# define EXIV2API EXV_EXPORT +# else +# define EXIV2API EXV_IMPORT +# endif /* ! EXV_BUILDING_LIB */ +#else +# define EXIV2API +#endif /* ! EXV_HAVE_DLL */ diff --git a/config/configure.ac b/config/configure.ac index f85125ee..7fb171ee 100644 --- a/config/configure.ac +++ b/config/configure.ac @@ -1,7 +1,7 @@ # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. -AC_PREREQ(2.59) +AC_PREREQ(2.61) AC_INIT(exiv2, 0.17.91, ahuggel@gmx.net) # See http://www.gnu.org/software/libtool/manual.html#Updating-version-info EXIV2_LTVERSION=4:1:0 @@ -189,6 +189,16 @@ else fi AC_SUBST(EXV_LIB_STATIC) +# g++ visibility support +AX_CXX_CHECK_FLAG(-fvisibility-inlines-hidden,[],[],[GXX_VISIBILITY=yes],[GXX_VISIBILITY=no]) +if test "$GXX_VISIBILITY" = "yes"; then + CXXFLAGS="${CXXFLAGS} -fvisibility=hidden -fvisibility-inlines-hidden" + AC_DEFINE(HAVE_GXXCLASSVISIBILITY,1) +fi +if test "$enable_shared" = "yes"; then + AC_DEFINE(HAVE_DLL) +fi + # --------------------------------------------------------------------------- # Create output files. # --------------------------------------------------------------------------- diff --git a/src/Makefile b/src/Makefile index a6913d4d..51cd380a 100644 --- a/src/Makefile +++ b/src/Makefile @@ -117,9 +117,8 @@ CSRC = localtime.c endif # Add source files of simple applications to this list -BINSRC = crwedit.cpp \ - crwparse.cpp \ - taglist.cpp +# Todo: How can we still support crwedit.cpp, crwparse.cpp +BINSRC = taglist.cpp # Source files for the Exiv2 application EXIV2MAIN = exiv2.cpp @@ -189,12 +188,12 @@ endif # ****************************************************************************** # Rules $(CCOBJ): %.o: %.cpp - @$(LIBTOOL) --mode=compile $(COMPILE.cc) -o $@ $< + @$(LIBTOOL) --mode=compile $(COMPILE.cc) -DEXV_BUILDING_LIB=1 -o $@ $< @$(MAKEDEPEND) @$(POSTDEPEND) $(COBJ): %.o: %.c - @$(LIBTOOL) --mode=compile $(COMPILE.c) -o $@ $< + @$(LIBTOOL) --mode=compile $(COMPILE.c) -DEXV_BUILDING_LIB=1 -o $@ $< @$(MAKEDEPEND) @$(POSTDEPEND) @@ -210,7 +209,7 @@ $(sort $(BINOBJ) $(EXIV2OBJ) $(MCOBJ) path-test.o): %.o: %.cpp %.ii: %.cpp set -e; \ - $(CXXCPP) $(CPPFLAGS) $< | sed '/^[ ]*$$/d' > $@ + $(CXXCPP) $(CPPFLAGS) -DEXV_BUILDING_LIB=1 $< | sed '/^[ ]*$$/d' > $@ # ****************************************************************************** # Targets diff --git a/src/basicio.hpp b/src/basicio.hpp index 350dfb52..9285edc8 100644 --- a/src/basicio.hpp +++ b/src/basicio.hpp @@ -52,8 +52,7 @@ namespace Exiv2 { operations. Subclasses should all behave the same so that they can be interchanged. */ - class BasicIo - { + class EXIV2API BasicIo { public: //! BasicIo auto_ptr type typedef std::auto_ptr AutoPtr; @@ -243,7 +242,7 @@ namespace Exiv2 { ensure BasicIo instances get closed. Useful when functions return errors from many locations. */ - class IoCloser { + class EXIV2API IoCloser { public: //! @name Creators //@{ @@ -261,7 +260,8 @@ namespace Exiv2 { // DATA //! The BasicIo reference - BasicIo &bio_; + BasicIo& bio_; + private: // Not implemented //! Copy constructor @@ -275,8 +275,7 @@ namespace Exiv2 { @brief Provides binary file IO by implementing the BasicIo interface. */ - class FileIo : public BasicIo - { + class EXIV2API FileIo : public BasicIo { public: //! @name Creators //@{ @@ -481,7 +480,7 @@ namespace Exiv2 { @param opMode The mode to switch to. @return 0 if successful */ - int switchMode(OpMode opMode); + EXV_DLLLOCAL int switchMode(OpMode opMode); }; // class FileIo @@ -497,8 +496,7 @@ namespace Exiv2 { creating a specialized readonly class or changing this one to have a readonly mode. */ - class MemIo : public BasicIo - { + class EXIV2API MemIo : public BasicIo { public: //! @name Creators //@{ @@ -658,6 +656,7 @@ namespace Exiv2 { */ virtual BasicIo::AutoPtr temporary() const; //@} + private: // NOT IMPLEMENTED //! Copy constructor @@ -674,17 +673,17 @@ namespace Exiv2 { bool eof_; // METHODS - void reserve(long wcount); + EXV_DLLLOCAL void reserve(long wcount); }; // class MemIo // ***************************************************************************** // template, inline and free functions //! Read file \em path into a DataBuf, which is returned. - DataBuf readFile(const std::string& path); + EXIV2API DataBuf readFile(const std::string& path); //! Write DataBuf \em buf to file \em path. Return the number of bytes written. - long writeFile(const DataBuf& buf, const std::string& path); + EXIV2API long writeFile(const DataBuf& buf, const std::string& path); } // namespace Exiv2 diff --git a/src/bmpimage.hpp b/src/bmpimage.hpp index 17e1f625..874d38e8 100644 --- a/src/bmpimage.hpp +++ b/src/bmpimage.hpp @@ -34,6 +34,7 @@ #include "exif.hpp" #include "iptc.hpp" #include "image.hpp" +#include "types.hpp" // + standard includes #include @@ -54,7 +55,7 @@ namespace Exiv2 { @brief Class to access Windows bitmaps. This is just a stub - we only read width and height. */ - class BmpImage : public Image { + class EXIV2API BmpImage : public Image { //! @name NOT Implemented //@{ //! Copy constructor @@ -123,10 +124,10 @@ namespace Exiv2 { Caller owns the returned object and the auto-pointer ensures that it will be deleted. */ - Image::AutoPtr newBmpInstance(BasicIo::AutoPtr io, bool create); + EXIV2API Image::AutoPtr newBmpInstance(BasicIo::AutoPtr io, bool create); //! Check if the file iIo is a Windows Bitmap image. - bool isBmpType(BasicIo& iIo, bool advance); + EXIV2API bool isBmpType(BasicIo& iIo, bool advance); } // namespace Exiv2 diff --git a/src/canonmn.hpp b/src/canonmn.hpp index 0a01aa78..314a2884 100644 --- a/src/canonmn.hpp +++ b/src/canonmn.hpp @@ -35,8 +35,8 @@ // ***************************************************************************** // included header files -#include "types.hpp" #include "tags.hpp" +#include "types.hpp" // + standard includes #include @@ -55,7 +55,7 @@ namespace Exiv2 { // class definitions //! MakerNote for Canon cameras - class CanonMakerNote { + class EXIV2API CanonMakerNote { public: //! Return read-only list of built-in Canon tags static const TagInfo* tagList(); @@ -125,7 +125,7 @@ namespace Exiv2 { 128 -> 4 143 -> 4.46875 */ - float canonEv(long val); + EXIV2API float canonEv(long val); } // namespace Exiv2 diff --git a/src/convert.hpp b/src/convert.hpp index 067b4f2c..c049021f 100644 --- a/src/convert.hpp +++ b/src/convert.hpp @@ -34,6 +34,11 @@ // ***************************************************************************** // included header files +#ifdef _MSC_VER +# include "exv_msvc.h" +#else +# include "exv_conf.h" +#endif // + standard includes @@ -51,27 +56,27 @@ namespace Exiv2 { // free functions, template and inline definitions //! Convert (copy) Exif tags to XMP properties. - void copyExifToXmp(const ExifData& exifData, XmpData& xmpData); + EXIV2API void copyExifToXmp(const ExifData& exifData, XmpData& xmpData); //! Convert (move) Exif tags to XMP properties, remove converted Exif tags. - void moveExifToXmp(ExifData& exifData, XmpData& xmpData); + EXIV2API void moveExifToXmp(ExifData& exifData, XmpData& xmpData); //! Convert (copy) XMP properties to Exif tags. - void copyXmpToExif(const XmpData& xmpData, ExifData& exifData); + EXIV2API void copyXmpToExif(const XmpData& xmpData, ExifData& exifData); //! Convert (move) XMP properties to Exif tags, remove converted XMP properties. - void moveXmpToExif(XmpData& xmpData, ExifData& exifData); + EXIV2API void moveXmpToExif(XmpData& xmpData, ExifData& exifData); //! Detect which metadata are newer and perform a copy in appropriate direction. - void syncExifWithXmp(ExifData& exifData, XmpData& xmpData); + EXIV2API void syncExifWithXmp(ExifData& exifData, XmpData& xmpData); //! Convert (copy) IPTC datasets to XMP properties. - void copyIptcToXmp(const IptcData& iptcData, XmpData& xmpData); + EXIV2API void copyIptcToXmp(const IptcData& iptcData, XmpData& xmpData); //! Convert (move) IPTC datasets to XMP properties, remove converted IPTC datasets. - void moveIptcToXmp(IptcData& iptcData, XmpData& xmpData); + EXIV2API void moveIptcToXmp(IptcData& iptcData, XmpData& xmpData); //! Convert (copy) XMP properties to IPTC datasets. - void copyXmpToIptc(const XmpData& xmpData, IptcData& iptcData); + EXIV2API void copyXmpToIptc(const XmpData& xmpData, IptcData& iptcData); //! Convert (move) XMP properties to IPTC tags, remove converted XMP properties. - void moveXmpToIptc(XmpData& xmpData, IptcData& iptcData); + EXIV2API void moveXmpToIptc(XmpData& xmpData, IptcData& iptcData); } // namespace Exiv2 diff --git a/src/cr2image.hpp b/src/cr2image.hpp index 276b2f61..be47c921 100644 --- a/src/cr2image.hpp +++ b/src/cr2image.hpp @@ -54,7 +54,7 @@ namespace Exiv2 { @brief Class to access raw Canon CR2 images. Exif metadata is supported directly, IPTC is read from the Exif data, if present. */ - class Cr2Image : public Image { + class EXIV2API Cr2Image : public Image { public: //! @name Creators //@{ @@ -124,7 +124,7 @@ namespace Exiv2 { class to decode and encode CR2 data. See class TiffParser for details. */ - class Cr2Parser { + class EXIV2API Cr2Parser { public: /*! @brief Decode metadata from a buffer \em pData of length \em size @@ -163,10 +163,10 @@ namespace Exiv2 { Caller owns the returned object and the auto-pointer ensures that it will be deleted. */ - Image::AutoPtr newCr2Instance(BasicIo::AutoPtr io, bool create); + EXIV2API Image::AutoPtr newCr2Instance(BasicIo::AutoPtr io, bool create); //! Check if the file iIo is a CR2 image. - bool isCr2Type(BasicIo& iIo, bool advance); + EXIV2API bool isCr2Type(BasicIo& iIo, bool advance); } // namespace Exiv2 diff --git a/src/crwimage.hpp b/src/crwimage.hpp index 94ebf2c6..e4359a70 100644 --- a/src/crwimage.hpp +++ b/src/crwimage.hpp @@ -62,7 +62,7 @@ namespace Exiv2 { @brief Class to access raw Canon CRW images. Only Exif metadata and a comment are supported. CRW format does not contain IPTC metadata. */ - class CrwImage : public Image { + class EXIV2API CrwImage : public Image { public: //! @name Creators //@{ @@ -116,7 +116,7 @@ namespace Exiv2 { /*! Stateless parser class for Canon CRW images (Ciff format). */ - class CrwParser { + class EXIV2API CrwParser { public: /*! @brief Decode metadata from a Canon CRW image in data buffer \em pData @@ -167,10 +167,10 @@ namespace Exiv2 { Caller owns the returned object and the auto-pointer ensures that it will be deleted. */ - Image::AutoPtr newCrwInstance(BasicIo::AutoPtr io, bool create); + EXIV2API Image::AutoPtr newCrwInstance(BasicIo::AutoPtr io, bool create); //! Check if the file iIo is a CRW image. - bool isCrwType(BasicIo& iIo, bool advance); + EXIV2API bool isCrwType(BasicIo& iIo, bool advance); } // namespace Exiv2 diff --git a/src/datasets.hpp b/src/datasets.hpp index 59f0c1dc..0730a1cb 100644 --- a/src/datasets.hpp +++ b/src/datasets.hpp @@ -47,7 +47,7 @@ namespace Exiv2 { // class definitions //! Details of an IPTC record. - struct RecordInfo { + struct EXIV2API RecordInfo { //! Constructor RecordInfo(uint16_t recordId, const char* name, const char* desc); uint16_t recordId_; //!< Record id @@ -56,7 +56,7 @@ namespace Exiv2 { }; //! Details of an IPTC dataset. - struct DataSet { + struct EXIV2API DataSet { //! Constructor DataSet( uint16_t number, @@ -85,7 +85,7 @@ namespace Exiv2 { }; // struct DataSet //! IPTC dataset reference, implemented as a static class. - class IptcDataSets { + class EXIV2API IptcDataSets { public: /*! @name Record identifiers @@ -274,7 +274,7 @@ namespace Exiv2 { /*! @brief Concrete keys for IPTC metadata. */ - class IptcKey : public Key { + class EXIV2API IptcKey : public Key { public: //! Shortcut for an %IptcKey auto pointer. typedef std::auto_ptr AutoPtr; @@ -351,7 +351,7 @@ namespace Exiv2 { private: //! Internal virtual copy constructor. - virtual IptcKey* clone_() const; + EXV_DLLLOCAL virtual IptcKey* clone_() const; // DATA static const char* familyName_; @@ -366,7 +366,7 @@ namespace Exiv2 { // free functions //! Output operator for dataSet - std::ostream& operator<<(std::ostream& os, const DataSet& dataSet); + EXIV2API std::ostream& operator<<(std::ostream& os, const DataSet& dataSet); } // namespace Exiv2 diff --git a/src/error.hpp b/src/error.hpp index caed2875..0fe981fd 100644 --- a/src/error.hpp +++ b/src/error.hpp @@ -53,7 +53,7 @@ namespace Exiv2 { easier for library users (they have the option of catching most things via std::exception). */ - class AnyError : public std::exception { + class EXIV2API AnyError : public std::exception { public: //! @name Creators //@{ @@ -79,7 +79,7 @@ namespace Exiv2 { @brief Simple error class used for exceptions. An output operator is provided to print errors to a stream. */ - class Error : public AnyError { + class EXIV2API Error : public AnyError { public: //! @name Creators //@{ diff --git a/src/exif.hpp b/src/exif.hpp index d0c62529..0ed1c1d3 100644 --- a/src/exif.hpp +++ b/src/exif.hpp @@ -60,7 +60,7 @@ namespace Exiv2 { @brief An Exif metadatum, consisting of an ExifKey and a Value and methods to manipulate these. */ - class Exifdatum : public Metadatum { + class EXIV2API Exifdatum : public Metadatum { template friend Exifdatum& setValue(Exifdatum&, const T&); public: //! @name Creators @@ -257,7 +257,7 @@ namespace Exiv2 { class only provides access to the Exif thumbnail as specified in the Exif standard. */ - class ExifThumbC { + class EXIV2API ExifThumbC { public: //! @name Creators //@{ @@ -296,6 +296,7 @@ namespace Exiv2 { //@} private: + // DATA const ExifData& exifData_; //!< Const reference to the Exif metadata. }; // class ExifThumb @@ -311,7 +312,7 @@ namespace Exiv2 { class only provides access to the Exif thumbnail as specified in the Exif standard. */ - class ExifThumb : public ExifThumbC { + class EXIV2API ExifThumb : public ExifThumbC { public: //! @name Creators //@{ @@ -403,6 +404,7 @@ namespace Exiv2 { //@} private: + // DATA ExifData& exifData_; //!< Reference to the related Exif metadata. }; // class ExifThumb @@ -422,7 +424,7 @@ namespace Exiv2 { - extract Exif metadata to files, insert from these files - extract and delete Exif thumbnail (JPEG and TIFF thumbnails) */ - class ExifData { + class EXIV2API ExifData { public: //! ExifMetadata iterator type typedef ExifMetadata::iterator iterator; @@ -509,7 +511,7 @@ namespace Exiv2 { @brief Stateless parser class for Exif data. Images use this class to decode and encode binary Exif data. See class TiffParser for details. */ - class ExifParser { + class EXIV2API ExifParser { public: /*! @brief Decode metadata from a buffer \em pData of length \em size diff --git a/src/fujimn.hpp b/src/fujimn.hpp index 1823e6d7..abf3dd32 100644 --- a/src/fujimn.hpp +++ b/src/fujimn.hpp @@ -38,6 +38,7 @@ // ***************************************************************************** // included header files #include "tags.hpp" +#include "types.hpp" // ***************************************************************************** // namespace extensions @@ -47,7 +48,7 @@ namespace Exiv2 { // class definitions //! MakerNote for Fujifilm cameras - class FujiMakerNote { + class EXIV2API FujiMakerNote { public: //! Return read-only list of built-in Fujifilm tags static const TagInfo* tagList(); diff --git a/src/futils.hpp b/src/futils.hpp index f1019cc0..2ebce542 100644 --- a/src/futils.hpp +++ b/src/futils.hpp @@ -32,6 +32,12 @@ // ********************************************************************* // included header files +#ifdef _MSC_VER +# include "exv_msvc.h" +#else +# include "exv_conf.h" +#endif + // + standard includes #include @@ -54,12 +60,12 @@ namespace Exiv2 { and its type, see stat(2). errno is left unchanged in case of an error. */ - bool fileExists(const std::string& path, bool ct =false); + EXIV2API bool fileExists(const std::string& path, bool ct =false); /*! @brief Return a system error message and the error code (errno). See %strerror(3). */ - std::string strError(); + EXIV2API std::string strError(); } // namespace Exiv2 diff --git a/src/gifimage.hpp b/src/gifimage.hpp index a7b5b00d..558e0fe1 100644 --- a/src/gifimage.hpp +++ b/src/gifimage.hpp @@ -35,6 +35,7 @@ #include "exif.hpp" #include "iptc.hpp" #include "image.hpp" +#include "types.hpp" // + standard includes #include @@ -55,7 +56,7 @@ namespace Exiv2 { @brief Class to access raw GIF images. Exif/IPTC metadata are supported directly. */ - class GifImage : public Image { + class EXIV2API GifImage : public Image { //! @name NOT Implemented //@{ //! Copy constructor @@ -124,10 +125,10 @@ namespace Exiv2 { Caller owns the returned object and the auto-pointer ensures that it will be deleted. */ - Image::AutoPtr newGifInstance(BasicIo::AutoPtr io, bool create); + EXIV2API Image::AutoPtr newGifInstance(BasicIo::AutoPtr io, bool create); //! Check if the file iIo is a GIF image. - bool isGifType(BasicIo& iIo, bool advance); + EXIV2API bool isGifType(BasicIo& iIo, bool advance); } // namespace Exiv2 diff --git a/src/i18n.h b/src/i18n.h index 7eccd335..bca198f8 100644 --- a/src/i18n.h +++ b/src/i18n.h @@ -39,7 +39,7 @@ # include // Definition is in types.cpp -const char* _exvGettext(const char* str); +EXIV2API const char* _exvGettext(const char* str); # define _(String) _exvGettext(String) # define N_(String) String diff --git a/src/image.cpp b/src/image.cpp index bb610464..67b52f17 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -76,10 +76,26 @@ EXIV2_RCSID("@(#) $Id$") #endif // ***************************************************************************** -// class member definitions -namespace Exiv2 { +namespace { - const ImageFactory::Registry ImageFactory::registry_[] = { + using namespace Exiv2; + + //! Struct for storing image types and function pointers. + struct Registry { + //! Comparison operator to compare a Registry structure with an image type + bool operator==(const int& imageType) const { return imageType == imageType_; } + + // DATA + int imageType_; + NewInstanceFct newInstance_; + IsThisTypeFct isThisType_; + AccessMode exifSupport_; + AccessMode iptcSupport_; + AccessMode xmpSupport_; + AccessMode commentSupport_; + }; + + const Registry registry[] = { //image type creation fct type check Exif mode IPTC mode XMP mode Comment mode //--------------- --------------- ---------- ----------- ----------- ----------- ------------ { ImageType::jpeg, newJpegInstance, isJpegType, amReadWrite, amReadWrite, amReadWrite, amReadWrite }, @@ -103,10 +119,11 @@ namespace Exiv2 { { ImageType::none, 0, 0, amNone, amNone, amNone, amNone } }; - bool ImageFactory::Registry::operator==(const int& imageType) const - { - return imageType == imageType_; - } +} + +// ***************************************************************************** +// class member definitions +namespace Exiv2 { Image::Image(int imageType, uint16_t supportedMetadata, @@ -228,7 +245,7 @@ namespace Exiv2 { AccessMode ImageFactory::checkMode(int type, MetadataId metadataId) { - const Registry* r = find(registry_, type); + const Registry* r = find(registry, type); if (!r) throw Error(13, type); AccessMode am = amNone; switch (metadataId) { @@ -253,7 +270,7 @@ namespace Exiv2 { bool ImageFactory::checkType(int type, BasicIo& io, bool advance) { - const Registry* r = find(registry_, type); + const Registry* r = find(registry, type); if (0 != r) { return r->isThisType_(io, advance); } @@ -276,9 +293,9 @@ namespace Exiv2 { { if (io.open() != 0) return ImageType::none; IoCloser closer(io); - for (unsigned int i = 0; registry_[i].imageType_ != ImageType::none; ++i) { - if (registry_[i].isThisType_(io, false)) { - return registry_[i].imageType_; + for (unsigned int i = 0; registry[i].imageType_ != ImageType::none; ++i) { + if (registry[i].isThisType_(io, false)) { + return registry[i].imageType_; } } return ImageType::none; @@ -305,9 +322,9 @@ namespace Exiv2 { if (io->open() != 0) { throw Error(9, io->path(), strError()); } - for (unsigned int i = 0; registry_[i].imageType_ != ImageType::none; ++i) { - if (registry_[i].isThisType_(*io, false)) { - return registry_[i].newInstance_(io, false); + for (unsigned int i = 0; registry[i].imageType_ != ImageType::none; ++i) { + if (registry[i].isThisType_(*io, false)) { + return registry[i].newInstance_(io, false); } } return Image::AutoPtr(); @@ -340,7 +357,7 @@ namespace Exiv2 { BasicIo::AutoPtr io) { // BasicIo instance does not need to be open - const Registry* r = find(registry_, type); + const Registry* r = find(registry, type); if (0 != r) { return r->newInstance_(io, true); } diff --git a/src/image.hpp b/src/image.hpp index 490106a2..82440bec 100644 --- a/src/image.hpp +++ b/src/image.hpp @@ -20,7 +20,7 @@ */ /*! @file image.hpp - @brief Class JpegImage to access JPEG images + @brief Class Image, defining the interface for all Image subclasses. @version $Rev$ @author Andreas Huggel (ahu) ahuggel@gmx.net @@ -68,7 +68,7 @@ namespace Exiv2 { ImageFactory method. The Image class can then be used to to read, write, and save metadata. */ - class Image { + class EXIV2API Image { public: //! Image auto_ptr type typedef std::auto_ptr AutoPtr; @@ -425,7 +425,7 @@ namespace Exiv2 { The factory is implemented as a static class. */ - class ImageFactory { + class EXIV2API ImageFactory { friend bool Image::good() const; public: /*! @@ -559,21 +559,6 @@ namespace Exiv2 { static bool checkType(int type, BasicIo& io, bool advance); private: - //! Struct for storing image types and function pointers. - struct Registry { - //! Comparison operator to compare a Registry structure with an image type - bool operator==(const int& imageType) const; - - // DATA - int imageType_; - NewInstanceFct newInstance_; - IsThisTypeFct isThisType_; - AccessMode exifSupport_; - AccessMode iptcSupport_; - AccessMode xmpSupport_; - AccessMode commentSupport_; - }; - //! @name Creators //@{ //! Prevent construction: not implemented. @@ -582,9 +567,6 @@ namespace Exiv2 { ImageFactory(const ImageFactory& rhs); //@} - // DATA - //! List of image types, creation functions and access modes - static const Registry registry_[]; }; // class ImageFactory // ***************************************************************************** diff --git a/src/iptc.hpp b/src/iptc.hpp index 1d454337..380445e4 100644 --- a/src/iptc.hpp +++ b/src/iptc.hpp @@ -52,7 +52,7 @@ namespace Exiv2 { @brief An IPTC metadatum ("dataset"), consisting of an IptcKey and a Value and methods to manipulate these. */ - class Iptcdatum : public Metadatum { + class EXIV2API Iptcdatum : public Metadatum { public: //! @name Creators //@{ @@ -174,7 +174,7 @@ namespace Exiv2 { typedef std::vector IptcMetadata; //! Unary predicate that matches an Iptcdatum with given record and dataset - class FindMetadatumById { + class EXIV2API FindMetadatumById { public: //! Constructor, initializes the object with the record and dataset id FindMetadatumById(uint16_t dataset, uint16_t record) @@ -187,6 +187,7 @@ namespace Exiv2 { { return dataset_ == iptcdatum.tag() && record_ == iptcdatum.record(); } private: + // DATA uint16_t dataset_; uint16_t record_; @@ -203,7 +204,7 @@ namespace Exiv2 { - write IPTC data to JPEG files - extract IPTC metadata to files, insert from these files */ - class IptcData { + class EXIV2API IptcData { public: //! IptcMetadata iterator type typedef IptcMetadata::iterator iterator; @@ -306,7 +307,7 @@ namespace Exiv2 { @brief Stateless parser class for IPTC data. Images use this class to decode and encode binary IPTC data. */ - class IptcParser { + class EXIV2API IptcParser { public: /*! @brief Decode binary IPTC data in IPTC IIM4 format from a buffer \em pData diff --git a/src/jp2image.hpp b/src/jp2image.hpp index 2de69799..537a9b52 100644 --- a/src/jp2image.hpp +++ b/src/jp2image.hpp @@ -37,6 +37,7 @@ #include "exif.hpp" #include "iptc.hpp" #include "image.hpp" +#include "types.hpp" // + standard includes #include @@ -58,9 +59,7 @@ namespace Exiv2 /*! @brief Class to access JPEG-2000 images. */ - class Jp2Image : public Image - { - + class EXIV2API Jp2Image : public Image { public: //! @name Creators //@{ @@ -112,7 +111,7 @@ namespace Exiv2 @return 4 if opening or writing to the associated BasicIo fails */ - void doWriteMetadata(BasicIo& oIo); + EXV_DLLLOCAL void doWriteMetadata(BasicIo& oIo); //@} }; // class Jp2Image @@ -127,10 +126,10 @@ namespace Exiv2 Caller owns the returned object and the auto-pointer ensures that it will be deleted. */ - Image::AutoPtr newJp2Instance(BasicIo::AutoPtr io, bool create); + EXIV2API Image::AutoPtr newJp2Instance(BasicIo::AutoPtr io, bool create); //! Check if the file iIo is a JPEG-2000 image. - bool isJp2Type(BasicIo& iIo, bool advance); + EXIV2API bool isJp2Type(BasicIo& iIo, bool advance); } // namespace Exiv2 diff --git a/src/jpgimage.hpp b/src/jpgimage.hpp index 9576ba50..aa84dcd3 100644 --- a/src/jpgimage.hpp +++ b/src/jpgimage.hpp @@ -35,6 +35,7 @@ // included header files #include "image.hpp" #include "basicio.hpp" +#include "types.hpp" // + standard includes #include @@ -56,7 +57,7 @@ namespace Exiv2 { @brief Helper class, has methods to deal with %Photoshop "Information Resource Blocks" (IRBs). */ - struct Photoshop { + struct EXIV2API Photoshop { // Todo: Public for now static const char ps3Id_[]; //!< %Photoshop marker static const char bimId_[]; //!< %Photoshop marker @@ -111,7 +112,7 @@ namespace Exiv2 { /*! @brief Abstract helper base class to access JPEG images. */ - class JpegBase : public Image { + class EXIV2API JpegBase : public Image { public: //! @name Manipulators //@{ @@ -226,7 +227,7 @@ namespace Exiv2 { @return 0 if successful;
4 if the image can not be written to. */ - int initImage(const byte initData[], long dataSize); + EXV_DLLLOCAL int initImage(const byte initData[], long dataSize); /*! @brief Provides the main implementation of writeMetadata() by writing all buffered metadata to the provided BasicIo. @@ -234,7 +235,7 @@ namespace Exiv2 { @return 4 if opening or writing to the associated BasicIo fails */ - void doWriteMetadata(BasicIo& oIo); + EXV_DLLLOCAL void doWriteMetadata(BasicIo& oIo); //@} //! @name Accessors @@ -247,7 +248,7 @@ namespace Exiv2 { @return the next Jpeg segment marker if successful;
-1 if a maker was not found before EOF */ - int advanceToMarker() const; + EXV_DLLLOCAL int advanceToMarker() const; //@} }; // class JpegBase @@ -255,7 +256,7 @@ namespace Exiv2 { /*! @brief Class to access JPEG images */ - class JpegImage : public JpegBase { + class EXIV2API JpegImage : public JpegBase { friend bool isJpegType(BasicIo& iIo, bool advance); public: //! @name Creators @@ -299,6 +300,7 @@ namespace Exiv2 { */ int writeHeader(BasicIo& oIo) const; //@} + private: // Constant data static const byte soi_; // SOI marker @@ -311,10 +313,11 @@ namespace Exiv2 { JpegImage(const JpegImage& rhs); //! Assignment operator JpegImage& operator=(const JpegImage& rhs); + }; // class JpegImage //! Helper class to access %Exiv2 files - class ExvImage : public JpegBase { + class EXIV2API ExvImage : public JpegBase { friend bool isExvType(BasicIo& iIo, bool advance); public: //! @name Creators @@ -350,6 +353,7 @@ namespace Exiv2 { //@{ int writeHeader(BasicIo& oIo) const; //@} + private: // Constant data static const char exiv2Id_[]; // EXV identifier @@ -362,6 +366,7 @@ namespace Exiv2 { ExvImage(const ExvImage& rhs); //! Assignment operator ExvImage& operator=(const ExvImage& rhs); + }; // class ExvImage // ***************************************************************************** @@ -374,17 +379,17 @@ namespace Exiv2 { Caller owns the returned object and the auto-pointer ensures that it will be deleted. */ - Image::AutoPtr newJpegInstance(BasicIo::AutoPtr io, bool create); + EXIV2API Image::AutoPtr newJpegInstance(BasicIo::AutoPtr io, bool create); //! Check if the file iIo is a JPEG image. - bool isJpegType(BasicIo& iIo, bool advance); + EXIV2API bool isJpegType(BasicIo& iIo, bool advance); /*! @brief Create a new ExvImage instance and return an auto-pointer to it. Caller owns the returned object and the auto-pointer ensures that it will be deleted. */ - Image::AutoPtr newExvInstance(BasicIo::AutoPtr io, bool create); + EXIV2API Image::AutoPtr newExvInstance(BasicIo::AutoPtr io, bool create); //! Check if the file iIo is an EXV file - bool isExvType(BasicIo& iIo, bool advance); + EXIV2API bool isExvType(BasicIo& iIo, bool advance); } // namespace Exiv2 diff --git a/src/metadatum.hpp b/src/metadatum.hpp index b20cf068..c55b4a58 100644 --- a/src/metadatum.hpp +++ b/src/metadatum.hpp @@ -53,7 +53,7 @@ namespace Exiv2 { @brief Abstract base class defining the %Key of a metadatum. Keys are used to identify and group metadata. */ - class Key { + class EXIV2API Key { public: //! Shortcut for a %Key auto pointer. typedef std::auto_ptr AutoPtr; @@ -110,7 +110,7 @@ namespace Exiv2 { private: //! Internal virtual copy constructor. - virtual Key* clone_() const =0; + EXV_DLLLOCAL virtual Key* clone_() const =0; }; // class Key @@ -124,7 +124,7 @@ namespace Exiv2 { @brief Abstract base class defining the interface to access information related to one metadata tag. */ - class Metadatum { + class EXIV2API Metadatum { public: //! @name Creators //@{ @@ -281,7 +281,7 @@ namespace Exiv2 { }; // class Metadatum //! Unary predicate that matches a Exifdatum with a given key - class FindMetadatumByKey { + class EXIV2API FindMetadatumByKey { public: //! Constructor, initializes the object with the tag to look for FindMetadatumByKey(const std::string& key) : key_(key) {} @@ -310,12 +310,12 @@ namespace Exiv2 { @brief Compare two metadata by tag. Return true if the tag of metadatum lhs is less than that of rhs. */ - bool cmpMetadataByTag(const Metadatum& lhs, const Metadatum& rhs); + EXIV2API bool cmpMetadataByTag(const Metadatum& lhs, const Metadatum& rhs); /*! @brief Compare two metadata by key. Return true if the key of metadatum lhs is less than that of rhs. */ - bool cmpMetadataByKey(const Metadatum& lhs, const Metadatum& rhs); + EXIV2API bool cmpMetadataByKey(const Metadatum& lhs, const Metadatum& rhs); } // namespace Exiv2 diff --git a/src/minoltamn.hpp b/src/minoltamn.hpp index d53bf2ca..acf84997 100644 --- a/src/minoltamn.hpp +++ b/src/minoltamn.hpp @@ -39,6 +39,7 @@ // ***************************************************************************** // included header files #include "tags.hpp" +#include "types.hpp" // + standard includes #include @@ -51,7 +52,7 @@ namespace Exiv2 { // class definitions //! MakerNote for Minolta cameras - class MinoltaMakerNote { + class EXIV2API MinoltaMakerNote { public: //! Return read-only list of built-in Minolta tags static const TagInfo* tagList(); diff --git a/src/mrwimage.hpp b/src/mrwimage.hpp index 786f93e7..e8de3c3f 100644 --- a/src/mrwimage.hpp +++ b/src/mrwimage.hpp @@ -34,6 +34,7 @@ // included header files #include "image.hpp" #include "basicio.hpp" +#include "types.hpp" // + standard includes #include @@ -54,7 +55,7 @@ namespace Exiv2 { @brief Class to access raw Minolta MRW images. Exif metadata is supported directly, IPTC is read from the Exif data, if present. */ - class MrwImage : public Image { + class EXIV2API MrwImage : public Image { public: //! @name Creators //@{ @@ -129,10 +130,10 @@ namespace Exiv2 { Caller owns the returned object and the auto-pointer ensures that it will be deleted. */ - Image::AutoPtr newMrwInstance(BasicIo::AutoPtr io, bool create); + EXIV2API Image::AutoPtr newMrwInstance(BasicIo::AutoPtr io, bool create); //! Check if the file iIo is a MRW image. - bool isMrwType(BasicIo& iIo, bool advance); + EXIV2API bool isMrwType(BasicIo& iIo, bool advance); } // namespace Exiv2 diff --git a/src/nikonmn.hpp b/src/nikonmn.hpp index 918d7991..e13c9203 100644 --- a/src/nikonmn.hpp +++ b/src/nikonmn.hpp @@ -43,6 +43,7 @@ // ***************************************************************************** // included header files #include "tags.hpp" +#include "types.hpp" // + standard includes #include @@ -57,7 +58,7 @@ namespace Exiv2 { // class definitions //! A MakerNote format used by Nikon cameras, such as the E990 and D1. - class Nikon1MakerNote { + class EXIV2API Nikon1MakerNote { public: //! Return read-only list of built-in Nikon1 tags static const TagInfo* tagList(); @@ -86,7 +87,7 @@ namespace Exiv2 { @brief A second MakerNote format used by Nikon cameras, including the E700, E800, E900, E900S, E910, E950 */ - class Nikon2MakerNote { + class EXIV2API Nikon2MakerNote { public: //! Return read-only list of built-in Nikon2 tags static const TagInfo* tagList(); @@ -104,7 +105,7 @@ namespace Exiv2 { }; // class Nikon2MakerNote //! A third MakerNote format used by Nikon cameras, e.g., E5400, SQ, D2H, D70 - class Nikon3MakerNote { + class EXIV2API Nikon3MakerNote { public: //! Return read-only list of built-in Nikon3 tags static const TagInfo* tagList(); diff --git a/src/olympusmn.hpp b/src/olympusmn.hpp index 0abf074c..e7966af3 100644 --- a/src/olympusmn.hpp +++ b/src/olympusmn.hpp @@ -39,8 +39,8 @@ // ***************************************************************************** // included header files -#include "types.hpp" #include "tags.hpp" +#include "types.hpp" // + standard includes #include @@ -55,7 +55,7 @@ namespace Exiv2 { // class definitions //! MakerNote for Olympus cameras - class OlympusMakerNote { + class EXIV2API OlympusMakerNote { public: //! Return read-only list of built-in Olympus tags static const TagInfo* tagList(); diff --git a/src/orfimage.hpp b/src/orfimage.hpp index fbb79c3f..ec5625dc 100644 --- a/src/orfimage.hpp +++ b/src/orfimage.hpp @@ -54,7 +54,7 @@ namespace Exiv2 { @brief Class to access raw Olympus ORF images. Exif metadata is supported directly, IPTC is read from the Exif data, if present. */ - class OrfImage : public Image { + class EXIV2API OrfImage : public Image { public: //! @name Creators //@{ @@ -124,7 +124,7 @@ namespace Exiv2 { class to decode and encode ORF data. See class TiffParser for details. */ - class OrfParser { + class EXIV2API OrfParser { public: /*! @brief Decode metadata from a buffer \em pData of length \em size @@ -163,10 +163,10 @@ namespace Exiv2 { Caller owns the returned object and the auto-pointer ensures that it will be deleted. */ - Image::AutoPtr newOrfInstance(BasicIo::AutoPtr io, bool create); + EXIV2API Image::AutoPtr newOrfInstance(BasicIo::AutoPtr io, bool create); //! Check if the file iIo is an ORF image. - bool isOrfType(BasicIo& iIo, bool advance); + EXIV2API bool isOrfType(BasicIo& iIo, bool advance); } // namespace Exiv2 diff --git a/src/panasonicmn.hpp b/src/panasonicmn.hpp index 465b3262..be3a1534 100644 --- a/src/panasonicmn.hpp +++ b/src/panasonicmn.hpp @@ -36,8 +36,8 @@ // ***************************************************************************** // included header files -#include "types.hpp" #include "tags.hpp" +#include "types.hpp" // + standard includes #include @@ -51,7 +51,7 @@ namespace Exiv2 { // class definitions //! MakerNote for Panasonic cameras - class PanasonicMakerNote { + class EXIV2API PanasonicMakerNote { public: //! Return read-only list of built-in Panasonic tags static const TagInfo* tagList(); diff --git a/src/pentaxmn.hpp b/src/pentaxmn.hpp index 8602ef09..5c1b4880 100644 --- a/src/pentaxmn.hpp +++ b/src/pentaxmn.hpp @@ -34,8 +34,8 @@ // ***************************************************************************** // included header files -#include "types.hpp" #include "tags.hpp" +#include "types.hpp" // + standard includes #include @@ -51,7 +51,7 @@ namespace Exiv2 { // class definitions //! MakerNote for Pentaxfilm cameras - class PentaxMakerNote { + class EXIV2API PentaxMakerNote { public: //! Return read-only list of built-in Pentaxfilm tags static const TagInfo* tagList(); diff --git a/src/pngchunk.cpp b/src/pngchunk.cpp index 638e457e..9b875ee2 100644 --- a/src/pngchunk.cpp +++ b/src/pngchunk.cpp @@ -39,13 +39,11 @@ EXIV2_RCSID("@(#) $Id: pngchunk.cpp 823 2006-06-23 07:35:00Z cgilles $") //#define DEBUG 1 -extern "C" -{ -// To uncompress or compress text chunk -#include +extern "C" { +#include // To uncompress or compress text chunk } -#include "pngchunk.hpp" +#include "pngchunk_int.hpp" #include "tiffimage.hpp" #include "exif.hpp" #include "iptc.hpp" @@ -71,8 +69,9 @@ PNG tags : http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/PNG // ***************************************************************************** // class member definitions -namespace Exiv2 -{ +namespace Exiv2 { + namespace Internal { + void PngChunk::decodeIHDRChunk(const DataBuf& data, int* outWidth, int* outHeight) @@ -816,4 +815,4 @@ namespace Exiv2 } // PngChunk::formatStringList -} // namespace Exiv2 +}} // namespace Internal, Exiv2 diff --git a/src/pngchunk.hpp b/src/pngchunk_int.hpp similarity index 92% rename from src/pngchunk.hpp rename to src/pngchunk_int.hpp index 67db00f5..c1f54d85 100644 --- a/src/pngchunk.hpp +++ b/src/pngchunk_int.hpp @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA. */ /*! - @file pngchunk.hpp + @file pngchunk_int.hpp @brief Class PngChunk to parse PNG chunk data implemented using the following references:
PNG iTXt chunk structure from PNG definitive guide,
PNG tTXt and zTXt chunks structures from PNG definitive guide,
@@ -32,8 +32,8 @@ caulier dot gilles at gmail dot com @date 12-Jun-06, gc: submitted */ -#ifndef PNGCHUNK_HPP_ -#define PNGCHUNK_HPP_ +#ifndef PNGCHUNK_INT_HPP_ +#define PNGCHUNK_INT_HPP_ // ***************************************************************************** // included header files @@ -45,14 +45,14 @@ // ***************************************************************************** // namespace extensions -namespace Exiv2 -{ +namespace Exiv2 { // ***************************************************************************** // class declarations - class Image; + namespace Internal { + // ***************************************************************************** // class definitions @@ -60,33 +60,27 @@ namespace Exiv2 @brief Stateless parser class for data in PNG chunk format. Images use this class to decode and encode PNG-based data. */ - class PngChunk - { + class PngChunk { public: - - /*! - @brief Text Chunk types. - */ - enum TxtChunkType - { - tEXt_Chunk = 0, - zTXt_Chunk = 1, - iTXt_Chunk = 2 - }; - - /*! - @brief Metadata Chunk types. - */ - enum MetadataType - { - exif_Data = 0, - iptc_Data = 1, - xmp_Data = 2, - comment_Data = 3 - }; + /*! + @brief Text Chunk types. + */ + enum TxtChunkType { + tEXt_Chunk = 0, + zTXt_Chunk = 1, + iTXt_Chunk = 2 + }; + /*! + @brief Metadata Chunk types. + */ + enum MetadataType { + exif_Data = 0, + iptc_Data = 1, + xmp_Data = 2, + comment_Data = 3 + }; public: - /*! @brief Decode PNG IHDR chunk data from a data buffer \em data and return image size to \em outWidth and \em outHeight. @@ -130,10 +124,6 @@ namespace Exiv2 static DataBuf makeMetadataChunk(const DataBuf& metadata, MetadataType type, bool compress); private: - - //! @name Accessors - //@{ - /*! @brief Parse PNG Text chunk to determine type and extract content. Supported Chunk types are tTXt, zTXt, and iTXt. @@ -212,10 +202,9 @@ namespace Exiv2 const size_t length, const char *format, va_list operands); - //@} }; // class PngChunk -} // namespace Exiv2 +}} // namespace Internal, Exiv2 -#endif // #ifndef PNGCHUNK_HPP_ +#endif // #ifndef PNGCHUNK_INT_HPP_ diff --git a/src/pngimage.cpp b/src/pngimage.cpp index 40149abd..353f11d0 100644 --- a/src/pngimage.cpp +++ b/src/pngimage.cpp @@ -41,7 +41,7 @@ EXIV2_RCSID("@(#) $Id: pngimage.cpp 823 2006-06-12 07:35:00Z cgilles $") # include "exv_conf.h" #endif -#include "pngchunk.hpp" +#include "pngchunk_int.hpp" #include "pngimage.hpp" #include "image.hpp" #include "basicio.hpp" @@ -59,8 +59,10 @@ const unsigned char pngSignature[8] = { 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A // ***************************************************************************** // class member definitions -namespace Exiv2 -{ +namespace Exiv2 { + + using namespace Internal; + PngImage::PngImage(BasicIo::AutoPtr io, bool /*create*/) : Image(ImageType::png, mdExif | mdIptc | mdComment, io) { diff --git a/src/pngimage.hpp b/src/pngimage.hpp index fbb9384a..9b34a237 100644 --- a/src/pngimage.hpp +++ b/src/pngimage.hpp @@ -37,6 +37,7 @@ // included header files #include "image.hpp" #include "basicio.hpp" +#include "types.hpp" // + standard includes #include @@ -59,9 +60,7 @@ namespace Exiv2 @brief Class to access PNG images. Exif and IPTC metadata are supported directly. */ - class PngImage : public Image - { - + class EXIV2API PngImage : public Image { public: //! @name Creators //@{ @@ -109,8 +108,9 @@ namespace Exiv2 @return 4 if opening or writing to the associated BasicIo fails */ - void doWriteMetadata(BasicIo& oIo); + EXV_DLLLOCAL void doWriteMetadata(BasicIo& oIo); //@} + }; // class PngImage // ***************************************************************************** @@ -123,10 +123,10 @@ namespace Exiv2 Caller owns the returned object and the auto-pointer ensures that it will be deleted. */ - Image::AutoPtr newPngInstance(BasicIo::AutoPtr io, bool create); + EXIV2API Image::AutoPtr newPngInstance(BasicIo::AutoPtr io, bool create); //! Check if the file iIo is a PNG image. - bool isPngType(BasicIo& iIo, bool advance); + EXIV2API bool isPngType(BasicIo& iIo, bool advance); } // namespace Exiv2 diff --git a/src/properties.hpp b/src/properties.hpp index 350d033f..1b7fbc70 100644 --- a/src/properties.hpp +++ b/src/properties.hpp @@ -59,7 +59,7 @@ namespace Exiv2 { enum XmpCategory { xmpInternal, xmpExternal }; //! Information about one XMP property. - struct XmpPropertyInfo { + struct EXIV2API XmpPropertyInfo { //! Comparison operator for name bool operator==(const std::string& name) const; @@ -72,7 +72,7 @@ namespace Exiv2 { }; //! Structure mapping XMP namespaces and (preferred) prefixes. - struct XmpNsInfo { + struct EXIV2API XmpNsInfo { //! For comparison with prefix struct Prefix { //! Constructor. @@ -99,7 +99,7 @@ namespace Exiv2 { }; //! XMP property reference, implemented as a static class. - class XmpProperties { + class EXIV2API XmpProperties { //! Prevent construction: not implemented. XmpProperties(); //! Prevent copy-construction: not implemented. @@ -182,7 +182,6 @@ namespace Exiv2 { static std::ostream& printProperty(std::ostream& os, const std::string& key, const Value& value); - /*! @brief Register namespace \em ns with preferred prefix \em prefix. @@ -221,7 +220,7 @@ namespace Exiv2 { /*! @brief Concrete keys for XMP metadata. */ - class XmpKey : public Key { + class EXIV2API XmpKey : public Key { public: //! Shortcut for an %XmpKey auto pointer. typedef std::auto_ptr AutoPtr; @@ -282,7 +281,7 @@ namespace Exiv2 { private: //! Internal virtual copy constructor. - virtual XmpKey* clone_() const; + EXV_DLLLOCAL virtual XmpKey* clone_() const; private: // Pimpl idiom @@ -295,7 +294,7 @@ namespace Exiv2 { // free functions //! Output operator for property info - std::ostream& operator<<(std::ostream& os, const XmpPropertyInfo& propertyInfo); + EXIV2API std::ostream& operator<<(std::ostream& os, const XmpPropertyInfo& propertyInfo); } // namespace Exiv2 diff --git a/src/psdimage.hpp b/src/psdimage.hpp index 2df318cc..bb8cb2ef 100644 --- a/src/psdimage.hpp +++ b/src/psdimage.hpp @@ -35,6 +35,7 @@ #include "exif.hpp" #include "iptc.hpp" #include "image.hpp" +#include "types.hpp" // + standard includes #include @@ -54,7 +55,7 @@ namespace Exiv2 { /*! @brief Class to access raw Photoshop images. */ - class PsdImage : public Image { + class EXIV2API PsdImage : public Image { //! @name NOT Implemented //@{ //! Copy constructor @@ -125,7 +126,7 @@ namespace Exiv2 { private: //! @name Manipulators //@{ - void processResourceBlock(uint16_t resourceId, uint32_t resourceSize); + EXV_DLLLOCAL void processResourceBlock(uint16_t resourceId, uint32_t resourceSize); //@} }; // class PsdImage @@ -140,10 +141,10 @@ namespace Exiv2 { Caller owns the returned object and the auto-pointer ensures that it will be deleted. */ - Image::AutoPtr newPsdInstance(BasicIo::AutoPtr io, bool create); + EXIV2API Image::AutoPtr newPsdInstance(BasicIo::AutoPtr io, bool create); //! Check if the file iIo is a Photoshop image. - bool isPsdType(BasicIo& iIo, bool advance); + EXIV2API bool isPsdType(BasicIo& iIo, bool advance); } // namespace Exiv2 diff --git a/src/rafimage.hpp b/src/rafimage.hpp index e8ff1bc1..885a21c9 100644 --- a/src/rafimage.hpp +++ b/src/rafimage.hpp @@ -33,6 +33,7 @@ // included header files #include "image.hpp" #include "basicio.hpp" +#include "types.hpp" // + standard includes #include @@ -53,7 +54,7 @@ namespace Exiv2 { @brief Class to access raw Fujifilm RAF images. Exif metadata is supported directly, IPTC is read from the Exif data, if present. */ - class RafImage : public Image { + class EXIV2API RafImage : public Image { public: //! @name Creators //@{ @@ -128,10 +129,10 @@ namespace Exiv2 { Caller owns the returned object and the auto-pointer ensures that it will be deleted. */ - Image::AutoPtr newRafInstance(BasicIo::AutoPtr io, bool create); + EXIV2API Image::AutoPtr newRafInstance(BasicIo::AutoPtr io, bool create); //! Check if the file iIo is a RAF image. - bool isRafType(BasicIo& iIo, bool advance); + EXIV2API bool isRafType(BasicIo& iIo, bool advance); } // namespace Exiv2 diff --git a/src/sigmamn.hpp b/src/sigmamn.hpp index bc0eadeb..9a7448d4 100644 --- a/src/sigmamn.hpp +++ b/src/sigmamn.hpp @@ -33,8 +33,8 @@ // ***************************************************************************** // included header files -#include "types.hpp" #include "tags.hpp" +#include "types.hpp" // + standard includes #include @@ -49,7 +49,7 @@ namespace Exiv2 { // class definitions //! MakerNote for Sigma (Foveon) cameras - class SigmaMakerNote { + class EXIV2API SigmaMakerNote { public: //! Return read-only list of built-in Sigma tags static const TagInfo* tagList(); diff --git a/src/sonymn.hpp b/src/sonymn.hpp index 413ec3e4..6351877a 100644 --- a/src/sonymn.hpp +++ b/src/sonymn.hpp @@ -31,8 +31,8 @@ // ***************************************************************************** // included header files -#include "types.hpp" #include "tags.hpp" +#include "types.hpp" // + standard includes #include @@ -46,7 +46,7 @@ namespace Exiv2 { // class definitions //! MakerNote for Sony cameras - class SonyMakerNote { + class EXIV2API SonyMakerNote { public: //! Return read-only list of built-in Sony tags static const TagInfo* tagList(); diff --git a/src/tags.hpp b/src/tags.hpp index fefd5b42..0f3fba29 100644 --- a/src/tags.hpp +++ b/src/tags.hpp @@ -73,7 +73,7 @@ namespace Exiv2 { // class definitions //! The details of an IFD. - struct IfdInfo { + struct EXIV2API IfdInfo { struct Item; bool operator==(IfdId ifdId) const; //!< Comparison operator for IFD id bool operator==(Item item) const; //!< Comparison operator for IFD item @@ -85,20 +85,20 @@ namespace Exiv2 { }; //! Search key to find an IfdInfo by its IFD item. - struct IfdInfo::Item { + struct EXIV2API IfdInfo::Item { Item(const std::string& item); //!< Constructor std::string i_; //!< IFD item }; //! The details of a section. - struct SectionInfo { + struct EXIV2API SectionInfo { SectionId sectionId_; //!< Section id const char* name_; //!< Section name (one word) const char* desc_; //!< Section description }; //! Tag information - struct TagInfo { + struct EXIV2API TagInfo { //! Constructor TagInfo( uint16_t tag, @@ -124,7 +124,7 @@ namespace Exiv2 { @brief Helper structure for lookup tables for translations of numeric tag values to human readable labels. */ - struct TagDetails { + struct EXIV2API TagDetails { long val_; //!< Tag value const char* label_; //!< Translation of the tag value @@ -136,7 +136,7 @@ namespace Exiv2 { @brief Helper structure for lookup tables for translations of bitmask values to human readable labels. */ - struct TagDetailsBitmask { + struct EXIV2API TagDetailsBitmask { uint32_t mask_; //!< Bitmask value const char* label_; //!< Description of the tag value }; // struct TagDetailsBitmask @@ -191,7 +191,7 @@ namespace Exiv2 { #define EXV_PRINT_TAG_BITMASK(array) printTagBitmask //! Exif tag reference, implemented as a static class. - class ExifTags { + class EXIV2API ExifTags { //! Prevent construction: not implemented. ExifTags(); //! Prevent copy-construction: not implemented. @@ -320,7 +320,7 @@ namespace Exiv2 { /*! @brief Concrete keys for Exif metadata. */ - class ExifKey : public Key { + class EXIV2API ExifKey : public Key { public: //! Shortcut for an %ExifKey auto pointer. typedef std::auto_ptr AutoPtr; @@ -405,7 +405,7 @@ namespace Exiv2 { private: //! Internal virtual copy constructor. - virtual ExifKey* clone_() const; + EXV_DLLLOCAL virtual ExifKey* clone_() const; // DATA static const char* familyName_; @@ -421,115 +421,115 @@ namespace Exiv2 { // free functions //! Output operator for TagInfo - std::ostream& operator<<(std::ostream& os, const TagInfo& ti); + EXIV2API std::ostream& operator<<(std::ostream& os, const TagInfo& ti); //! @name Functions printing interpreted tag values //@{ //! Default print function, using the Value output operator - std::ostream& printValue(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& printValue(std::ostream& os, const Value& value, const ExifData*); //! Print the value converted to a long - std::ostream& printLong(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& printLong(std::ostream& os, const Value& value, const ExifData*); //! Print a Rational or URational value in floating point format - std::ostream& printFloat(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& printFloat(std::ostream& os, const Value& value, const ExifData*); //! Print a longitude or latitude value - std::ostream& printDegrees(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& printDegrees(std::ostream& os, const Value& value, const ExifData*); //! Print function converting from UCS-2LE to UTF-8 - std::ostream& printUcs2(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& printUcs2(std::ostream& os, const Value& value, const ExifData*); //! Print function for Exif units - std::ostream& printExifUnit(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& printExifUnit(std::ostream& os, const Value& value, const ExifData*); //! Print GPS version - std::ostream& print0x0000(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0x0000(std::ostream& os, const Value& value, const ExifData*); //! Print GPS altitude ref - std::ostream& print0x0005(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0x0005(std::ostream& os, const Value& value, const ExifData*); //! Print GPS altitude - std::ostream& print0x0006(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0x0006(std::ostream& os, const Value& value, const ExifData*); //! Print GPS timestamp - std::ostream& print0x0007(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0x0007(std::ostream& os, const Value& value, const ExifData*); //! Print GPS status - std::ostream& print0x0009(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0x0009(std::ostream& os, const Value& value, const ExifData*); //! Print GPS measurement mode - std::ostream& print0x000a(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0x000a(std::ostream& os, const Value& value, const ExifData*); //! Print GPS speed ref - std::ostream& print0x000c(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0x000c(std::ostream& os, const Value& value, const ExifData*); //! Print GPS destination distance ref - std::ostream& print0x0019(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0x0019(std::ostream& os, const Value& value, const ExifData*); //! Print GPS differential correction - std::ostream& print0x001e(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0x001e(std::ostream& os, const Value& value, const ExifData*); //! Print orientation - std::ostream& print0x0112(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0x0112(std::ostream& os, const Value& value, const ExifData*); //! Print YCbCrPositioning - std::ostream& print0x0213(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0x0213(std::ostream& os, const Value& value, const ExifData*); //! Print the copyright - std::ostream& print0x8298(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0x8298(std::ostream& os, const Value& value, const ExifData*); //! Print the exposure time - std::ostream& print0x829a(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0x829a(std::ostream& os, const Value& value, const ExifData*); //! Print the f-number - std::ostream& print0x829d(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0x829d(std::ostream& os, const Value& value, const ExifData*); //! Print exposure program - std::ostream& print0x8822(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0x8822(std::ostream& os, const Value& value, const ExifData*); //! Print ISO speed ratings - std::ostream& print0x8827(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0x8827(std::ostream& os, const Value& value, const ExifData*); //! Print components configuration specific to compressed data - std::ostream& print0x9101(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0x9101(std::ostream& os, const Value& value, const ExifData*); //! Print exposure time converted from APEX shutter speed value - std::ostream& print0x9201(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0x9201(std::ostream& os, const Value& value, const ExifData*); //! Print f-number converted from APEX aperture value - std::ostream& print0x9202(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0x9202(std::ostream& os, const Value& value, const ExifData*); //! Print the exposure bias value - std::ostream& print0x9204(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0x9204(std::ostream& os, const Value& value, const ExifData*); //! Print the subject distance - std::ostream& print0x9206(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0x9206(std::ostream& os, const Value& value, const ExifData*); //! Print metering mode - std::ostream& print0x9207(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0x9207(std::ostream& os, const Value& value, const ExifData*); //! Print light source - std::ostream& print0x9208(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0x9208(std::ostream& os, const Value& value, const ExifData*); //! Print the actual focal length of the lens - std::ostream& print0x920a(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0x920a(std::ostream& os, const Value& value, const ExifData*); //! Print the user comment - std::ostream& print0x9286(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0x9286(std::ostream& os, const Value& value, const ExifData*); //! Print color space - std::ostream& print0xa001(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0xa001(std::ostream& os, const Value& value, const ExifData*); //! Print sensing method - std::ostream& print0xa217(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0xa217(std::ostream& os, const Value& value, const ExifData*); //! Print file source - std::ostream& print0xa300(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0xa300(std::ostream& os, const Value& value, const ExifData*); //! Print scene type - std::ostream& print0xa301(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0xa301(std::ostream& os, const Value& value, const ExifData*); //! Print custom rendered - std::ostream& print0xa401(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0xa401(std::ostream& os, const Value& value, const ExifData*); //! Print exposure mode - std::ostream& print0xa402(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0xa402(std::ostream& os, const Value& value, const ExifData*); //! Print white balance - std::ostream& print0xa403(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0xa403(std::ostream& os, const Value& value, const ExifData*); //! Print digital zoom ratio - std::ostream& print0xa404(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0xa404(std::ostream& os, const Value& value, const ExifData*); //! Print 35mm equivalent focal length - std::ostream& print0xa405(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0xa405(std::ostream& os, const Value& value, const ExifData*); //! Print scene capture type - std::ostream& print0xa406(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0xa406(std::ostream& os, const Value& value, const ExifData*); //! Print gain control - std::ostream& print0xa407(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0xa407(std::ostream& os, const Value& value, const ExifData*); //! Print saturation - std::ostream& print0xa409(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0xa409(std::ostream& os, const Value& value, const ExifData*); //! Print subject distance range - std::ostream& print0xa40c(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& print0xa40c(std::ostream& os, const Value& value, const ExifData*); //! Print GPS direction ref - std::ostream& printGPSDirRef(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& printGPSDirRef(std::ostream& os, const Value& value, const ExifData*); //! Print contrast, sharpness (normal, soft, hard) - std::ostream& printNormalSoftHard(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& printNormalSoftHard(std::ostream& os, const Value& value, const ExifData*); //! Print any version packed in 4 Bytes format : major major minor minor - std::ostream& printExifVersion(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& printExifVersion(std::ostream& os, const Value& value, const ExifData*); //! Print any version encoded in the ASCII string majormajorminorminor - std::ostream& printXmpVersion(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& printXmpVersion(std::ostream& os, const Value& value, const ExifData*); //! Print a date following the format YYYY-MM-DDTHH:MM:SSZ - std::ostream& printXmpDate(std::ostream& os, const Value& value, const ExifData*); + EXIV2API std::ostream& printXmpDate(std::ostream& os, const Value& value, const ExifData*); //@} //! Calculate F number from an APEX aperture value - float fnumber(float apertureValue); + EXIV2API float fnumber(float apertureValue); //! Calculate the exposure time from an APEX shutter speed value - URational exposureTime(float shutterSpeedValue); + EXIV2API URational exposureTime(float shutterSpeedValue); } // namespace Exiv2 diff --git a/src/tgaimage.hpp b/src/tgaimage.hpp index d6291389..5ee20cad 100644 --- a/src/tgaimage.hpp +++ b/src/tgaimage.hpp @@ -36,6 +36,7 @@ #include "exif.hpp" #include "iptc.hpp" #include "image.hpp" +#include "types.hpp" // + standard includes #include @@ -56,7 +57,7 @@ namespace Exiv2 { @brief Class to access raw TARGA images. This is just a stub - we only read width and height. */ - class TgaImage : public Image { + class EXIV2API TgaImage : public Image { //! @name NOT Implemented //@{ //! Copy constructor @@ -125,10 +126,10 @@ namespace Exiv2 { Caller owns the returned object and the auto-pointer ensures that it will be deleted. */ - Image::AutoPtr newTgaInstance(BasicIo::AutoPtr io, bool create); + EXIV2API Image::AutoPtr newTgaInstance(BasicIo::AutoPtr io, bool create); //! Check if the file iIo is a Targa v2 image. - bool isTgaType(BasicIo& iIo, bool advance); + EXIV2API bool isTgaType(BasicIo& iIo, bool advance); } // namespace Exiv2 diff --git a/src/tiffimage.hpp b/src/tiffimage.hpp index 1438b4de..73faa573 100644 --- a/src/tiffimage.hpp +++ b/src/tiffimage.hpp @@ -33,6 +33,7 @@ // included header files #include "image.hpp" #include "basicio.hpp" +#include "types.hpp" // + standard includes #include @@ -53,7 +54,7 @@ namespace Exiv2 { @brief Class to access TIFF images. Exif metadata is supported directly, IPTC is read from the Exif data, if present. */ - class TiffImage : public Image { + class EXIV2API TiffImage : public Image { public: //! @name Creators //@{ @@ -109,7 +110,7 @@ namespace Exiv2 { class to decode and encode TIFF data. It is a wrapper of the internal class Internal::TiffParserWorker. */ - class TiffParser { + class EXIV2API TiffParser { public: /*! @brief Decode metadata from a buffer \em pData of length \em size @@ -185,10 +186,10 @@ namespace Exiv2 { Caller owns the returned object and the auto-pointer ensures that it will be deleted. */ - Image::AutoPtr newTiffInstance(BasicIo::AutoPtr io, bool create); + EXIV2API Image::AutoPtr newTiffInstance(BasicIo::AutoPtr io, bool create); //! Check if the file iIo is a TIFF image. - bool isTiffType(BasicIo& iIo, bool advance); + EXIV2API bool isTiffType(BasicIo& iIo, bool advance); } // namespace Exiv2 diff --git a/src/types.cpp b/src/types.cpp index 8d9c90e2..fb624cb7 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -48,37 +48,47 @@ EXIV2_RCSID("@(#) $Id$") #include // ***************************************************************************** -// class member definitions -namespace Exiv2 { +namespace { + + //! Information pertaining to the defined %Exiv2 value type identifiers. + struct TypeInfoTable { + Exiv2::TypeId typeId_; //!< Type id + const char* name_; //!< Name of the type + long size_; //!< Bytes per data entry + //! Comparison operator for \em typeId + bool operator==(Exiv2::TypeId typeId) const; + //! Comparison operator for \em name + bool operator==(const std::string& name) const; + }; // struct TypeInfoTable //! Lookup list with information of Exiv2 types - const TypeInfoTable TypeInfo::typeInfoTable_[] = { - { invalidTypeId, "Invalid", 0 }, - { unsignedByte, "Byte", 1 }, - { asciiString, "Ascii", 1 }, - { unsignedShort, "Short", 2 }, - { unsignedLong, "Long", 4 }, - { unsignedRational, "Rational", 8 }, - { signedByte, "SByte", 1 }, - { undefined, "Undefined", 1 }, - { signedShort, "SShort", 2 }, - { signedLong, "SLong", 4 }, - { signedRational, "SRational", 8 }, - { tiffFloat, "Float", 4 }, - { tiffDouble, "Double", 8 }, - { string, "String", 1 }, - { date, "Date", 8 }, - { time, "Time", 11 }, - { comment, "Comment", 1 }, - { directory, "Directory", 1 }, - { xmpText, "XmpText", 1 }, - { xmpAlt, "XmpAlt", 1 }, - { xmpBag, "XmpBag", 1 }, - { xmpSeq, "XmpSeq", 1 }, - { langAlt, "LangAlt", 1 } + const TypeInfoTable typeInfoTable[] = { + { Exiv2::invalidTypeId, "Invalid", 0 }, + { Exiv2::unsignedByte, "Byte", 1 }, + { Exiv2::asciiString, "Ascii", 1 }, + { Exiv2::unsignedShort, "Short", 2 }, + { Exiv2::unsignedLong, "Long", 4 }, + { Exiv2::unsignedRational, "Rational", 8 }, + { Exiv2::signedByte, "SByte", 1 }, + { Exiv2::undefined, "Undefined", 1 }, + { Exiv2::signedShort, "SShort", 2 }, + { Exiv2::signedLong, "SLong", 4 }, + { Exiv2::signedRational, "SRational", 8 }, + { Exiv2::tiffFloat, "Float", 4 }, + { Exiv2::tiffDouble, "Double", 8 }, + { Exiv2::string, "String", 1 }, + { Exiv2::date, "Date", 8 }, + { Exiv2::time, "Time", 11 }, + { Exiv2::comment, "Comment", 1 }, + { Exiv2::directory, "Directory", 1 }, + { Exiv2::xmpText, "XmpText", 1 }, + { Exiv2::xmpAlt, "XmpAlt", 1 }, + { Exiv2::xmpBag, "XmpBag", 1 }, + { Exiv2::xmpSeq, "XmpSeq", 1 }, + { Exiv2::langAlt, "LangAlt", 1 } }; - bool TypeInfoTable::operator==(TypeId typeId) const + bool TypeInfoTable::operator==(Exiv2::TypeId typeId) const { return typeId_ == typeId; } @@ -88,23 +98,29 @@ namespace Exiv2 { return std::string(name_) == name; } +} + +// ***************************************************************************** +// class member definitions +namespace Exiv2 { + const char* TypeInfo::typeName(TypeId typeId) { - const TypeInfoTable* tit = find(typeInfoTable_, typeId); + const TypeInfoTable* tit = find(typeInfoTable, typeId); if (!tit) return 0; return tit->name_; } TypeId TypeInfo::typeId(const std::string& typeName) { - const TypeInfoTable* tit = find(typeInfoTable_, typeName); + const TypeInfoTable* tit = find(typeInfoTable, typeName); if (!tit) return invalidTypeId; return tit->typeId_; } long TypeInfo::typeSize(TypeId typeId) { - const TypeInfoTable* tit = find(typeInfoTable_, typeId); + const TypeInfoTable* tit = find(typeInfoTable, typeId); if (!tit) return 0; return tit->size_; } diff --git a/src/types.hpp b/src/types.hpp index 676eb3d2..89698d14 100644 --- a/src/types.hpp +++ b/src/types.hpp @@ -151,21 +151,10 @@ namespace Exiv2 { // ***************************************************************************** // class definitions - //! Information pertaining to the defined %Exiv2 value type identifiers. - struct TypeInfoTable { - TypeId typeId_; //!< Type id - const char* name_; //!< Name of the type - long size_; //!< Bytes per data entry - //! Comparison operator for \em typeId - bool operator==(TypeId typeId) const; - //! Comparison operator for \em name - bool operator==(const std::string& name) const; - }; // struct TypeInfoTable - //! Type information lookup functions. Implemented as a static class. - class TypeInfo { + class EXIV2API TypeInfo { //! Prevent construction: not implemented. - TypeInfo() {} + TypeInfo(); //! Prevent copy-construction: not implemented. TypeInfo(const TypeInfo& rhs); //! Prevent assignment: not implemented. @@ -179,8 +168,6 @@ namespace Exiv2 { //! Return the size in bytes of one element of this type static long typeSize(TypeId typeId); - private: - static const TypeInfoTable typeInfoTable_[]; }; /*! @@ -188,7 +175,7 @@ namespace Exiv2 { std::auto_ptr_ref. See http://www.josuttis.com/libbook/auto_ptr.html for a discussion. */ - struct DataBufRef { + struct EXIV2API DataBufRef { //! Constructor DataBufRef(std::pair rhs) : p(rhs) {} //! Pointer to a byte array and its size @@ -201,7 +188,7 @@ namespace Exiv2 { be as a stack variable in functions that need a temporary data buffer. */ - class DataBuf { + class EXIV2API DataBuf { public: //! @name Creators //@{ @@ -270,71 +257,71 @@ namespace Exiv2 { // free functions //! Read a 2 byte unsigned short value from the data buffer - uint16_t getUShort(const byte* buf, ByteOrder byteOrder); + EXIV2API uint16_t getUShort(const byte* buf, ByteOrder byteOrder); //! Read a 4 byte unsigned long value from the data buffer - uint32_t getULong(const byte* buf, ByteOrder byteOrder); + EXIV2API uint32_t getULong(const byte* buf, ByteOrder byteOrder); //! Read an 8 byte unsigned rational value from the data buffer - URational getURational(const byte* buf, ByteOrder byteOrder); + EXIV2API URational getURational(const byte* buf, ByteOrder byteOrder); //! Read a 2 byte signed short value from the data buffer - int16_t getShort(const byte* buf, ByteOrder byteOrder); + EXIV2API int16_t getShort(const byte* buf, ByteOrder byteOrder); //! Read a 4 byte signed long value from the data buffer - int32_t getLong(const byte* buf, ByteOrder byteOrder); + EXIV2API int32_t getLong(const byte* buf, ByteOrder byteOrder); //! Read an 8 byte signed rational value from the data buffer - Rational getRational(const byte* buf, ByteOrder byteOrder); + EXIV2API Rational getRational(const byte* buf, ByteOrder byteOrder); //! Output operator for our fake rational - std::ostream& operator<<(std::ostream& os, const Rational& r); + EXIV2API std::ostream& operator<<(std::ostream& os, const Rational& r); //! Input operator for our fake rational - std::istream& operator>>(std::istream& is, Rational& r); + EXIV2API std::istream& operator>>(std::istream& is, Rational& r); //! Output operator for our fake unsigned rational - std::ostream& operator<<(std::ostream& os, const URational& r); + EXIV2API std::ostream& operator<<(std::ostream& os, const URational& r); //! Input operator for our fake unsigned rational - std::istream& operator>>(std::istream& is, URational& r); + EXIV2API std::istream& operator>>(std::istream& is, URational& r); /*! @brief Convert an unsigned short to data, write the data to the buffer, return number of bytes written. */ - long us2Data(byte* buf, uint16_t s, ByteOrder byteOrder); + EXIV2API long us2Data(byte* buf, uint16_t s, ByteOrder byteOrder); /*! @brief Convert an unsigned long to data, write the data to the buffer, return number of bytes written. */ - long ul2Data(byte* buf, uint32_t l, ByteOrder byteOrder); + EXIV2API long ul2Data(byte* buf, uint32_t l, ByteOrder byteOrder); /*! @brief Convert an unsigned rational to data, write the data to the buffer, return number of bytes written. */ - long ur2Data(byte* buf, URational l, ByteOrder byteOrder); + EXIV2API long ur2Data(byte* buf, URational l, ByteOrder byteOrder); /*! @brief Convert a signed short to data, write the data to the buffer, return number of bytes written. */ - long s2Data(byte* buf, int16_t s, ByteOrder byteOrder); + EXIV2API long s2Data(byte* buf, int16_t s, ByteOrder byteOrder); /*! @brief Convert a signed long to data, write the data to the buffer, return number of bytes written. */ - long l2Data(byte* buf, int32_t l, ByteOrder byteOrder); + EXIV2API long l2Data(byte* buf, int32_t l, ByteOrder byteOrder); /*! @brief Convert a signed rational to data, write the data to the buffer, return number of bytes written. */ - long r2Data(byte* buf, Rational l, ByteOrder byteOrder); + EXIV2API long r2Data(byte* buf, Rational l, ByteOrder byteOrder); /*! @brief Print len bytes from buf in hex and ASCII format to the given stream, prefixed with the position in the buffer adjusted by offset. */ - void hexdump(std::ostream& os, const byte* buf, long len, long offset =0); + EXIV2API void hexdump(std::ostream& os, const byte* buf, long len, long offset =0); /*! @brief Return true if str is a hex number starting with prefix followed by size hex digits, false otherwise. If size is 0, any number of digits is allowed and all are checked. */ - bool isHex(const std::string& str, + EXIV2API bool isHex(const std::string& str, size_t size =0, const std::string& prefix =""); @@ -343,13 +330,13 @@ namespace Exiv2 { "2007:05:24 12:31:55" to broken down time format, returns 0 if successful, else 1. */ - int exifTime(const char* buf, struct tm* tm); + EXIV2API int exifTime(const char* buf, struct tm* tm); /*! @brief Translate a string using the gettext framework. This wrapper hides all the implementation details from the interface. */ - const char* exvGettext(const char* str); + EXIV2API const char* exvGettext(const char* str); /*! @brief Return a \em long set to the value represented by \em s. @@ -363,7 +350,7 @@ namespace Exiv2 { @return Returns the \em long value represented by \em s and sets \em ok to \c true if the conversion was successful or \c false if not. */ - long parseLong(const std::string& s, bool& ok); + EXIV2API long parseLong(const std::string& s, bool& ok); /*! @brief Return a \em float set to the value represented by \em s. @@ -377,7 +364,7 @@ namespace Exiv2 { @return Returns the \em float value represented by \em s and sets \em ok to \c true if the conversion was successful or \c false if not. */ - float parseFloat(const std::string& s, bool& ok); + EXIV2API float parseFloat(const std::string& s, bool& ok); /*! @brief Return a \em Rational set to the value represented by \em s. @@ -393,7 +380,7 @@ namespace Exiv2 { @return Returns the \em Rational value represented by \em s and sets \em ok to \c true if the conversion was successful or \c false if not. */ - Rational parseRational(const std::string& s, bool& ok); + EXIV2API Rational parseRational(const std::string& s, bool& ok); /*! @brief Very simple conversion of a \em float to a \em Rational. @@ -401,7 +388,7 @@ namespace Exiv2 { Test it with the values that you expect and check the implementation to see if this is really what you want! */ - Rational floatToRationalCast(float f); + EXIV2API Rational floatToRationalCast(float f); // ***************************************************************************** // template and inline definitions diff --git a/src/value.hpp b/src/value.hpp index bfde77b5..8c762273 100644 --- a/src/value.hpp +++ b/src/value.hpp @@ -59,7 +59,7 @@ namespace Exiv2 { string or data buffer. For other tasks, like modifying values you may need to downcast it to a specific subclass to access its interface. */ - class Value { + class EXIV2API Value { public: //! Shortcut for a %Value auto pointer. typedef std::auto_ptr AutoPtr; @@ -260,7 +260,7 @@ namespace Exiv2 { } //! %Value for an undefined data type. - class DataValue : public Value { + class EXIV2API DataValue : public Value { public: //! Shortcut for a %DataValue auto pointer. typedef std::auto_ptr AutoPtr; @@ -332,7 +332,7 @@ namespace Exiv2 { private: //! Internal virtual copy constructor. - virtual DataValue* clone_() const; + EXV_DLLLOCAL virtual DataValue* clone_() const; public: //! Type used to store the data. @@ -348,7 +348,7 @@ namespace Exiv2 { Uses a std::string to store the value and implements defaults for most operations. */ - class StringValueBase : public Value { + class EXIV2API StringValueBase : public Value { public: //! Shortcut for a %StringValueBase auto pointer. typedef std::auto_ptr AutoPtr; @@ -434,7 +434,7 @@ namespace Exiv2 { left to caller to decode and encode the string to and from readable text if that is required. */ - class StringValue : public StringValueBase { + class EXIV2API StringValue : public StringValueBase { public: //! Shortcut for a %StringValue auto pointer. typedef std::auto_ptr AutoPtr; @@ -458,7 +458,7 @@ namespace Exiv2 { private: //! Internal virtual copy constructor. - virtual StringValue* clone_() const; + EXV_DLLLOCAL virtual StringValue* clone_() const; }; // class StringValue @@ -468,7 +468,7 @@ namespace Exiv2 { This class is for null terminated single byte Ascii strings. This class also ensures that the string is null terminated. */ - class AsciiValue : public StringValueBase { + class EXIV2API AsciiValue : public StringValueBase { public: //! Shortcut for a %AsciiValue auto pointer. typedef std::auto_ptr AutoPtr; @@ -509,7 +509,7 @@ namespace Exiv2 { private: //! Internal virtual copy constructor. - virtual AsciiValue* clone_() const; + EXV_DLLLOCAL virtual AsciiValue* clone_() const; }; // class AsciiValue @@ -521,7 +521,7 @@ namespace Exiv2 { undefined), but this is not checked. It is left to caller to decode and encode the string to and from readable text if that is required. */ - class CommentValue : public StringValueBase { + class EXIV2API CommentValue : public StringValueBase { public: //! Character set identifiers for the character sets defined by %Exif enum CharsetId { ascii, jis, unicode, undefined, @@ -607,14 +607,14 @@ namespace Exiv2 { private: //! Internal virtual copy constructor. - virtual CommentValue* clone_() const; + EXV_DLLLOCAL virtual CommentValue* clone_() const; }; // class CommentValue /*! @brief Base class for all Exiv2 values used to store XMP property values. */ - class XmpValue : public Value { + class EXIV2API XmpValue : public Value { public: //! Shortcut for a %XmpValue auto pointer. typedef std::auto_ptr AutoPtr; @@ -705,7 +705,7 @@ namespace Exiv2 { Uses a std::string to store the value. */ - class XmpTextValue : public XmpValue { + class EXIV2API XmpTextValue : public XmpValue { public: //! Shortcut for a %XmpTextValue auto pointer. typedef std::auto_ptr AutoPtr; @@ -770,7 +770,7 @@ namespace Exiv2 { private: //! Internal virtual copy constructor. - virtual XmpTextValue* clone_() const; + EXV_DLLLOCAL virtual XmpTextValue* clone_() const; public: // DATA @@ -787,7 +787,7 @@ namespace Exiv2 { Uses a vector of std::string to store the value(s). */ - class XmpArrayValue : public XmpValue { + class EXIV2API XmpArrayValue : public XmpValue { public: //! Shortcut for a %XmpArrayValue auto pointer. typedef std::auto_ptr AutoPtr; @@ -838,7 +838,7 @@ namespace Exiv2 { private: //! Internal virtual copy constructor. - virtual XmpArrayValue* clone_() const; + EXV_DLLLOCAL virtual XmpArrayValue* clone_() const; public: //! Type used to store XMP array elements. @@ -854,7 +854,7 @@ namespace Exiv2 { A language alternative is an array consisting of simple text values, each of which has a language qualifier. */ - class LangAltValue : public XmpValue { + class EXIV2API LangAltValue : public XmpValue { public: //! Shortcut for a %LangAltValue auto pointer. typedef std::auto_ptr AutoPtr; @@ -922,7 +922,7 @@ namespace Exiv2 { private: //! Internal virtual copy constructor. - virtual LangAltValue* clone_() const; + EXV_DLLLOCAL virtual LangAltValue* clone_() const; public: //! Type used to store language alternative arrays. @@ -942,7 +942,7 @@ namespace Exiv2 { This class is limited to parsing simple date strings in the ISO 8601 format CCYYMMDD (century, year, month, day). */ - class DateValue : public Value { + class EXIV2API DateValue : public Value { public: //! Shortcut for a %DateValue auto pointer. typedef std::auto_ptr AutoPtr; @@ -1031,7 +1031,7 @@ namespace Exiv2 { private: //! Internal virtual copy constructor. - virtual DateValue* clone_() const; + EXV_DLLLOCAL virtual DateValue* clone_() const; // DATA Date date_; @@ -1046,7 +1046,7 @@ namespace Exiv2 { seconds and ±HHMM refers to hours and minutes ahead or behind Universal Coordinated Time. */ - class TimeValue : public Value { + class EXIV2API TimeValue : public Value { public: //! Shortcut for a %TimeValue auto pointer. typedef std::auto_ptr AutoPtr; @@ -1151,7 +1151,7 @@ namespace Exiv2 { @param format Format string for sscanf(). @return 0 if successful, else 1. */ - int scanTime3(const char* buf, const char* format); + EXV_DLLLOCAL int scanTime3(const char* buf, const char* format); /*! @brief Set time from \em buf if it conforms to \em format (6 input items). @@ -1162,13 +1162,13 @@ namespace Exiv2 { @param format Format string for sscanf(). @return 0 if successful, else 1. */ - int scanTime6(const char* buf, const char* format); + EXV_DLLLOCAL int scanTime6(const char* buf, const char* format); //@} //! @name Accessors //@{ //! Internal virtual copy constructor. - virtual TimeValue* clone_() const; + EXV_DLLLOCAL virtual TimeValue* clone_() const; //@} // DATA diff --git a/src/version.hpp b/src/version.hpp index 2584a5c8..5c05ed82 100644 --- a/src/version.hpp +++ b/src/version.hpp @@ -115,11 +115,11 @@ namespace Exiv2 { /*! @brief Return the version of %Exiv2 available at runtime as an integer. */ - int versionNumber(); + EXIV2API int versionNumber(); /*! @brief Return the version of %Exiv2 available at runtime as a string. */ - const char* version(); + EXIV2API const char* version(); /*! @brief Test the version of the available %Exiv2 library at runtime. Return true if it is the same as or newer than the passed-in version. @@ -162,6 +162,6 @@ namespace Exiv2 { #endif @endcode */ - bool testVersion(int major, int minor, int patch); + EXIV2API bool testVersion(int major, int minor, int patch); } // namespace Exiv2 #endif // VERSION_HPP_ diff --git a/src/xmp.hpp b/src/xmp.hpp index 4656dc17..7d04abba 100644 --- a/src/xmp.hpp +++ b/src/xmp.hpp @@ -51,7 +51,7 @@ namespace Exiv2 { @brief Information related to an XMP property. An XMP metadatum consists of an XmpKey and a Value and provides methods to manipulate these. */ - class Xmpdatum : public Metadatum { + class EXIV2API Xmpdatum : public Metadatum { public: //! @name Creators //@{ @@ -171,7 +171,7 @@ namespace Exiv2 { - add, modify and delete metadata - serialize XMP data to an XML block */ - class XmpData { + class EXIV2API XmpData { public: //! XmpMetadata iterator type typedef XmpMetadata::iterator iterator; @@ -250,7 +250,7 @@ namespace Exiv2 { class to parse and serialize XMP packets. The parser uses the XMP toolkit to do the job. */ - class XmpParser { + class EXIV2API XmpParser { friend void XmpProperties::registerNs(const std::string&, const std::string&); friend void XmpProperties::unregisterNs(const std::string&); public: diff --git a/src/xmpsidecar.hpp b/src/xmpsidecar.hpp index 3352594f..599cb24f 100644 --- a/src/xmpsidecar.hpp +++ b/src/xmpsidecar.hpp @@ -33,6 +33,7 @@ // included header files #include "image.hpp" #include "basicio.hpp" +#include "types.hpp" // + standard includes #include @@ -52,7 +53,7 @@ namespace Exiv2 { /*! @brief Class to access XMP sidecar files. They contain only XMP metadata. */ - class XmpSidecar : public Image { + class EXIV2API XmpSidecar : public Image { public: //! @name Creators //@{ @@ -113,10 +114,10 @@ namespace Exiv2 { Caller owns the returned object and the auto-pointer ensures that it will be deleted. */ - Image::AutoPtr newXmpInstance(BasicIo::AutoPtr io, bool create); + EXIV2API Image::AutoPtr newXmpInstance(BasicIo::AutoPtr io, bool create); //! Check if the file iIo is an XMP sidecar file. - bool isXmpType(BasicIo& iIo, bool advance); + EXIV2API bool isXmpType(BasicIo& iIo, bool advance); } // namespace Exiv2 diff --git a/test/Makefile b/test/Makefile index 47e5746b..4a385d49 100644 --- a/test/Makefile +++ b/test/Makefile @@ -59,7 +59,6 @@ SHELL = /bin/sh # Add test drivers to this list TESTS = addmoddel.sh \ bugfixes-test.sh \ - crw-test.sh \ exifdata-test.sh \ exiv2-test.sh \ imagetest.sh \