Move implementation to .cpp files. Fix more issues related to visibility settings

v0.27.3
Luis Díaz Más 7 years ago
parent e3f975137c
commit b9f913d5af

@ -94,15 +94,16 @@ namespace Exiv2 {
//! @name Creators //! @name Creators
//@{ //@{
//! Constructor, takes the log message type as an argument //! 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 //! 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 //! @name Manipulators
//@{ //@{
//! Return a reference to the ostringstream which holds the log message //! 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 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). 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 @brief Set the log message handler. The default handler writes log
messages to standard error. To suppress all log messages, set messages to standard error. To suppress all log messages, set
the log message handler to 0 (or set the log level to \c mute). 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 //! Return the current log level
static Level level() { return level_; } static Level level();
//! Return the current log message handler //! 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. //! The default log handler. Sends the log message to standard error.
static void defaultHandler(int level, const char* s); 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 easier for library users (they have the option of catching most
things via std::exception). things via std::exception).
*/ */
class EXIV2API AnyError : public std::exception { class AnyError : public std::exception {
public: public:
//! @name Creators //! @name Creators
//@{ //@{
@ -334,10 +335,9 @@ namespace Exiv2 {
// free functions, template and inline definitions // free functions, template and inline definitions
//! Return the error message for the error with code \em code. //! Return the error message for the error with code \em code.
EXIV2API const char* errMsg(int code); const char* errMsg(int code);
template<typename charT> template<typename charT>
//! BasicError constructor
BasicError<charT>::BasicError(ErrorCode code) BasicError<charT>::BasicError(ErrorCode code)
: code_(code), count_(0) : code_(code), count_(0)
{ {
@ -345,7 +345,6 @@ namespace Exiv2 {
} }
template<typename charT> template<typename A> template<typename charT> template<typename A>
//! BasicError constructor
BasicError<charT>::BasicError(ErrorCode code, const A& arg1) BasicError<charT>::BasicError(ErrorCode code, const A& arg1)
: code_(code), count_(1), arg1_(toBasicString<charT>(arg1)) : code_(code), count_(1), arg1_(toBasicString<charT>(arg1))
{ {
@ -353,7 +352,6 @@ namespace Exiv2 {
} }
template<typename charT> template<typename A, typename B> template<typename charT> template<typename A, typename B>
//! BasicError constructor
BasicError<charT>::BasicError(ErrorCode code, const A& arg1, const B& arg2) BasicError<charT>::BasicError(ErrorCode code, const A& arg1, const B& arg2)
: code_(code), count_(2), : code_(code), count_(2),
arg1_(toBasicString<charT>(arg1)), arg1_(toBasicString<charT>(arg1)),
@ -363,7 +361,6 @@ namespace Exiv2 {
} }
template<typename charT> template<typename A, typename B, typename C> template<typename charT> template<typename A, typename B, typename C>
//! BasicError constructor
BasicError<charT>::BasicError(ErrorCode code, const A& arg1, const B& arg2, const C& arg3) BasicError<charT>::BasicError(ErrorCode code, const A& arg1, const B& arg2, const C& arg3)
: code_(code), count_(3), : code_(code), count_(3),
arg1_(toBasicString<charT>(arg1)), arg1_(toBasicString<charT>(arg1)),

@ -209,9 +209,9 @@ namespace Exiv2 {
//! @name Creators //! @name Creators
//@{ //@{
//! Default constructor //! Default constructor
DataBuf() : pData_(0), size_(0) {} DataBuf();
//! Constructor with an initial buffer size //! 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 //! Constructor, copies an existing buffer
DataBuf(const byte* pData, long size); DataBuf(const byte* pData, long size);
/*! /*!
@ -221,7 +221,7 @@ namespace Exiv2 {
*/ */
DataBuf(DataBuf& rhs); DataBuf(DataBuf& rhs);
//! Destructor, deletes the allocated buffer //! Destructor, deletes the allocated buffer
~DataBuf() { delete[] pData_; } ~DataBuf();
//@} //@}
//! @name Manipulators //! @name Manipulators
@ -262,9 +262,9 @@ namespace Exiv2 {
See http://www.josuttis.com/libbook/auto_ptr.html for a discussion. See http://www.josuttis.com/libbook/auto_ptr.html for a discussion.
*/ */
//@{ //@{
DataBuf(DataBufRef rhs) : pData_(rhs.p.first), size_(rhs.p.second) {} DataBuf(DataBufRef rhs);
DataBuf& operator=(DataBufRef rhs) { reset(rhs.p); return *this; } DataBuf& operator=(DataBufRef rhs);
operator DataBufRef() { return DataBufRef(release()); } operator DataBufRef();
//@} //@}
// DATA // DATA

@ -266,17 +266,13 @@ namespace Exiv2 {
//! Shortcut for a %DataValue auto pointer. //! Shortcut for a %DataValue auto pointer.
typedef std::auto_ptr<DataValue> AutoPtr; typedef std::auto_ptr<DataValue> AutoPtr;
//! @name Creators
//@{
//! Default constructor.
explicit DataValue(TypeId typeId =undefined); explicit DataValue(TypeId typeId =undefined);
//! Constructor
DataValue(const byte* buf, DataValue(const byte* buf,
long len, ByteOrder byteOrder =invalidByteOrder, long len, ByteOrder byteOrder =invalidByteOrder,
TypeId typeId =undefined); TypeId typeId =undefined);
//! Virtual destructor.
virtual ~DataValue(); virtual ~DataValue();
//@}
//! @name Manipulators //! @name Manipulators
//@{ //@{

@ -30,10 +30,6 @@
// ***************************************************************************** // *****************************************************************************
// included header files // included header files
#include "tiffimage_int.hpp" #include "tiffimage_int.hpp"
#include "types.hpp"
// + standard includes
#include <string>
// ***************************************************************************** // *****************************************************************************
// namespace extensions // namespace extensions
@ -43,9 +39,7 @@ namespace Exiv2 {
// ***************************************************************************** // *****************************************************************************
// class definitions // class definitions
/*! /// @brief Canon CR2 header structure.
@brief Canon CR2 header structure.
*/
class Cr2Header : public TiffHeaderBase { class Cr2Header : public TiffHeaderBase {
public: public:
//! @name Creators //! @name Creators

@ -29,10 +29,8 @@
// ***************************************************************************** // *****************************************************************************
// included header files // included header files
#include "types.hpp"
#include "tags_int.hpp" #include "tags_int.hpp"
#include "image.hpp" #include "image.hpp"
#include "basicio.hpp"
// + standard includes // + standard includes
#include <iosfwd> #include <iosfwd>

@ -179,6 +179,25 @@ namespace Exiv2 {
LogMsg::Level LogMsg::level_ = LogMsg::warn; // Default output level LogMsg::Level LogMsg::level_ = LogMsg::warn; // Default output level
LogMsg::Handler LogMsg::handler_ = LogMsg::defaultHandler; 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) void LogMsg::defaultHandler(int level, const char* s)
{ {
switch (static_cast<LogMsg::Level>(level)) { switch (static_cast<LogMsg::Level>(level)) {

@ -41,10 +41,6 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <string.h> #include <string.h>
#ifdef _MSC_VER
#pragma message("Using exiv2 http support")
#endif
#define SLEEP 1000 #define SLEEP 1000
#define SNOOZE 0 #define SNOOZE 0

@ -130,6 +130,15 @@ namespace Exiv2 {
UNUSED(ret); 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) DataBuf::DataBuf(const byte* pData, long size)
: pData_(0), size_(0) : pData_(0), size_(0)
{ {
@ -182,6 +191,12 @@ namespace Exiv2 {
size_ = p.second; 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 // free functions

@ -10,6 +10,7 @@ add_executable(unit_tests mainTestRunner.cpp
test_TimeValue.cpp test_TimeValue.cpp
test_cr2header_int.cpp test_cr2header_int.cpp
test_helper_functions.cpp test_helper_functions.cpp
$<TARGET_OBJECTS:exiv2lib_int>
) )
#TODO Use GTest::GTest once we upgrade the minimum CMake version required #TODO Use GTest::GTest once we upgrade the minimum CMake version required
@ -19,6 +20,11 @@ target_link_libraries(unit_tests
${GTEST_BOTH_LIBRARIES} ${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 target_include_directories(unit_tests
PRIVATE PRIVATE
${GTEST_INCLUDE_DIRS} ${GTEST_INCLUDE_DIRS}

Loading…
Cancel
Save