From b9f913d5af3acf45583c72c9361ff5afc66ba07a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20D=C3=ADaz=20M=C3=A1s?= Date: Fri, 14 Sep 2018 09:37:32 +0200 Subject: [PATCH] Move implementation to .cpp files. Fix more issues related to visibility settings --- include/exiv2/error.hpp | 23 ++++++++++------------- include/exiv2/types.hpp | 12 ++++++------ include/exiv2/value.hpp | 8 ++------ src/cr2header_int.hpp | 8 +------- src/crwimage_int.hpp | 2 -- src/error.cpp | 19 +++++++++++++++++++ src/http.cpp | 4 ---- src/types.cpp | 15 +++++++++++++++ unitTests/CMakeLists.txt | 6 ++++++ 9 files changed, 59 insertions(+), 38 deletions(-) diff --git a/include/exiv2/error.hpp b/include/exiv2/error.hpp index 9dd1faf3..a40a037a 100644 --- a/include/exiv2/error.hpp +++ b/include/exiv2/error.hpp @@ -94,15 +94,16 @@ namespace Exiv2 { //! @name Creators //@{ //! Constructor, takes the log message type as an argument - explicit LogMsg(Level msgType) : msgType_(msgType) {} + explicit LogMsg(Level msgType); + //! Destructor, passes the log message to the message handler depending on the log level - ~LogMsg() { if (msgType_ >= level_ && handler_) handler_(msgType_, os_.str().c_str()); } + ~LogMsg(); //@} //! @name Manipulators //@{ //! Return a reference to the ostringstream which holds the log message - std::ostringstream& os() { return os_; } + std::ostringstream& os(); //@} /*! @@ -111,17 +112,17 @@ namespace Exiv2 { log level is \c warn. To suppress all log messages, set the log level to \c mute (or set the log message handler to 0). */ - static void setLevel(Level level) { level_ = level; } + static void setLevel(Level level); /*! @brief Set the log message handler. The default handler writes log messages to standard error. To suppress all log messages, set the log message handler to 0 (or set the log level to \c mute). */ - static void setHandler(Handler handler) { handler_ = handler; } + static void setHandler(Handler handler); //! Return the current log level - static Level level() { return level_; } + static Level level(); //! Return the current log message handler - static Handler handler() { return handler_; } + static Handler handler(); //! The default log handler. Sends the log message to standard error. static void defaultHandler(int level, const char* s); @@ -170,7 +171,7 @@ namespace Exiv2 { easier for library users (they have the option of catching most things via std::exception). */ - class EXIV2API AnyError : public std::exception { + class AnyError : public std::exception { public: //! @name Creators //@{ @@ -334,10 +335,9 @@ namespace Exiv2 { // free functions, template and inline definitions //! Return the error message for the error with code \em code. - EXIV2API const char* errMsg(int code); + const char* errMsg(int code); template - //! BasicError constructor BasicError::BasicError(ErrorCode code) : code_(code), count_(0) { @@ -345,7 +345,6 @@ namespace Exiv2 { } template template - //! BasicError constructor BasicError::BasicError(ErrorCode code, const A& arg1) : code_(code), count_(1), arg1_(toBasicString(arg1)) { @@ -353,7 +352,6 @@ namespace Exiv2 { } template template - //! BasicError constructor BasicError::BasicError(ErrorCode code, const A& arg1, const B& arg2) : code_(code), count_(2), arg1_(toBasicString(arg1)), @@ -363,7 +361,6 @@ namespace Exiv2 { } template template - //! BasicError constructor BasicError::BasicError(ErrorCode code, const A& arg1, const B& arg2, const C& arg3) : code_(code), count_(3), arg1_(toBasicString(arg1)), diff --git a/include/exiv2/types.hpp b/include/exiv2/types.hpp index 640456e9..0a902f0f 100644 --- a/include/exiv2/types.hpp +++ b/include/exiv2/types.hpp @@ -209,9 +209,9 @@ namespace Exiv2 { //! @name Creators //@{ //! Default constructor - DataBuf() : pData_(0), size_(0) {} + DataBuf(); //! Constructor with an initial buffer size - explicit DataBuf(long size) : pData_(new byte[size]()), size_(size) {} + explicit DataBuf(long size); //! Constructor, copies an existing buffer DataBuf(const byte* pData, long size); /*! @@ -221,7 +221,7 @@ namespace Exiv2 { */ DataBuf(DataBuf& rhs); //! Destructor, deletes the allocated buffer - ~DataBuf() { delete[] pData_; } + ~DataBuf(); //@} //! @name Manipulators @@ -262,9 +262,9 @@ namespace Exiv2 { See http://www.josuttis.com/libbook/auto_ptr.html for a discussion. */ //@{ - DataBuf(DataBufRef rhs) : pData_(rhs.p.first), size_(rhs.p.second) {} - DataBuf& operator=(DataBufRef rhs) { reset(rhs.p); return *this; } - operator DataBufRef() { return DataBufRef(release()); } + DataBuf(DataBufRef rhs); + DataBuf& operator=(DataBufRef rhs); + operator DataBufRef(); //@} // DATA diff --git a/include/exiv2/value.hpp b/include/exiv2/value.hpp index 6451addc..ea61b1a6 100644 --- a/include/exiv2/value.hpp +++ b/include/exiv2/value.hpp @@ -266,17 +266,13 @@ namespace Exiv2 { //! Shortcut for a %DataValue auto pointer. typedef std::auto_ptr AutoPtr; - //! @name Creators - //@{ - //! Default constructor. explicit DataValue(TypeId typeId =undefined); - //! Constructor + DataValue(const byte* buf, long len, ByteOrder byteOrder =invalidByteOrder, TypeId typeId =undefined); - //! Virtual destructor. + virtual ~DataValue(); - //@} //! @name Manipulators //@{ diff --git a/src/cr2header_int.hpp b/src/cr2header_int.hpp index e945f9a7..dd6bd949 100644 --- a/src/cr2header_int.hpp +++ b/src/cr2header_int.hpp @@ -30,10 +30,6 @@ // ***************************************************************************** // included header files #include "tiffimage_int.hpp" -#include "types.hpp" - -// + standard includes -#include // ***************************************************************************** // namespace extensions @@ -43,9 +39,7 @@ namespace Exiv2 { // ***************************************************************************** // class definitions - /*! - @brief Canon CR2 header structure. - */ + /// @brief Canon CR2 header structure. class Cr2Header : public TiffHeaderBase { public: //! @name Creators diff --git a/src/crwimage_int.hpp b/src/crwimage_int.hpp index ed61742f..3e45bb73 100644 --- a/src/crwimage_int.hpp +++ b/src/crwimage_int.hpp @@ -29,10 +29,8 @@ // ***************************************************************************** // included header files -#include "types.hpp" #include "tags_int.hpp" #include "image.hpp" -#include "basicio.hpp" // + standard includes #include diff --git a/src/error.cpp b/src/error.cpp index 8a69cc9f..e160a3dc 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -179,6 +179,25 @@ namespace Exiv2 { LogMsg::Level LogMsg::level_ = LogMsg::warn; // Default output level LogMsg::Handler LogMsg::handler_ = LogMsg::defaultHandler; + LogMsg::LogMsg(LogMsg::Level msgType) : msgType_(msgType) + {} + + LogMsg::~LogMsg() + { + if (msgType_ >= level_ && handler_) + handler_(msgType_, os_.str().c_str()); + } + + std::ostringstream &LogMsg::os() { return os_; } + + void LogMsg::setLevel(LogMsg::Level level) { level_ = level; } + + void LogMsg::setHandler(LogMsg::Handler handler) { handler_ = handler; } + + LogMsg::Level LogMsg::level() { return level_; } + + LogMsg::Handler LogMsg::handler() { return handler_; } + void LogMsg::defaultHandler(int level, const char* s) { switch (static_cast(level)) { diff --git a/src/http.cpp b/src/http.cpp index 302f9907..e4db519a 100644 --- a/src/http.cpp +++ b/src/http.cpp @@ -41,10 +41,6 @@ #include #include -#ifdef _MSC_VER -#pragma message("Using exiv2 http support") -#endif - #define SLEEP 1000 #define SNOOZE 0 diff --git a/src/types.cpp b/src/types.cpp index 63d376c2..cb3df1f5 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -130,6 +130,15 @@ namespace Exiv2 { UNUSED(ret); } + DataBuf::~DataBuf() + { delete[] pData_; } + + DataBuf::DataBuf() : pData_(0), size_(0) + {} + + DataBuf::DataBuf(long size) : pData_(new byte[size]()), size_(size) + {} + DataBuf::DataBuf(const byte* pData, long size) : pData_(0), size_(0) { @@ -182,6 +191,12 @@ namespace Exiv2 { size_ = p.second; } + DataBuf::DataBuf(DataBufRef rhs) : pData_(rhs.p.first), size_(rhs.p.second) {} + + DataBuf &DataBuf::operator=(DataBufRef rhs) { reset(rhs.p); return *this; } + + Exiv2::DataBuf::operator DataBufRef() { return DataBufRef(release()); } + // ************************************************************************* // free functions diff --git a/unitTests/CMakeLists.txt b/unitTests/CMakeLists.txt index 28163fa7..2c9bc05c 100644 --- a/unitTests/CMakeLists.txt +++ b/unitTests/CMakeLists.txt @@ -10,6 +10,7 @@ add_executable(unit_tests mainTestRunner.cpp test_TimeValue.cpp test_cr2header_int.cpp test_helper_functions.cpp + $ ) #TODO Use GTest::GTest once we upgrade the minimum CMake version required @@ -19,6 +20,11 @@ target_link_libraries(unit_tests ${GTEST_BOTH_LIBRARIES} ) +# ZLIB is used in exiv2lib_int. +if( EXIV2_ENABLE_PNG ) + target_link_libraries(unit_tests PRIVATE ${ZLIB_LIBRARIES} ) +endif() + target_include_directories(unit_tests PRIVATE ${GTEST_INCLUDE_DIRS}