diff --git a/Foundation/include/Poco/Bugcheck.h b/Foundation/include/Poco/Bugcheck.h index f48ffb27c..0bd62eae8 100644 --- a/Foundation/include/Poco/Bugcheck.h +++ b/Foundation/include/Poco/Bugcheck.h @@ -21,6 +21,7 @@ #include "Poco/Foundation.h" +#include #include #if defined(_DEBUG) # include @@ -40,7 +41,7 @@ class Foundation_API Bugcheck /// automatically provide useful context information. { public: - static void assertion(const char* cond, const char* file, int line); + static void assertion(const char* cond, const char* file, int line, const char* text = NULL); /// An assertion failed. Break into the debugger, if /// possible, then throw an AssertionViolationException. @@ -71,7 +72,7 @@ public: /// possible. protected: - static std::string what(const char* msg, const char* file, int line); + static std::string what(const char* msg, const char* file, int line, const char* text = NULL); }; @@ -84,7 +85,11 @@ protected: #if defined(_DEBUG) #define poco_assert_dbg(cond) \ if (!(cond)) Poco::Bugcheck::assertion(#cond, __FILE__, __LINE__); else (void) 0 + + #define poco_assert_msg_dbg(cond, text) \ + if (!(cond)) Poco::Bugcheck::assertion(#cond, __FILE__, __LINE__, text); else (void) 0 #else + #define poco_assert_msg_dbg(cond, text) #define poco_assert_dbg(cond) #endif @@ -92,6 +97,8 @@ protected: #define poco_assert(cond) \ if (!(cond)) Poco::Bugcheck::assertion(#cond, __FILE__, __LINE__); else (void) 0 +#define poco_assert_msg(cond, text) \ + if (!(cond)) Poco::Bugcheck::assertion(#cond, __FILE__, __LINE__, text); else (void) 0 #define poco_check_ptr(ptr) \ if (!(ptr)) Poco::Bugcheck::nullPointer(#ptr, __FILE__, __LINE__); else (void) 0 diff --git a/Foundation/include/Poco/Timestamp.h b/Foundation/include/Poco/Timestamp.h index 2ce171048..3cc79cc03 100644 --- a/Foundation/include/Poco/Timestamp.h +++ b/Foundation/include/Poco/Timestamp.h @@ -47,6 +47,9 @@ public: typedef Int64 UtcTimeVal; /// monotonic UTC time value in 100 nanosecond resolution typedef Int64 TimeDiff; /// difference between two timestamps in microseconds + static const TimeVal Min; + static const TimeVal Max; + Timestamp(); /// Creates a timestamp with the current time. diff --git a/Foundation/src/Bugcheck.cpp b/Foundation/src/Bugcheck.cpp index ea2cfe9f5..c7609bc50 100644 --- a/Foundation/src/Bugcheck.cpp +++ b/Foundation/src/Bugcheck.cpp @@ -23,10 +23,10 @@ namespace Poco { -void Bugcheck::assertion(const char* cond, const char* file, int line) +void Bugcheck::assertion(const char* cond, const char* file, int line, const char* text) { - Debugger::enter(std::string("Assertion violation: ") + cond, file, line); - throw AssertionViolationException(what(cond, file, line)); + Debugger::enter(std::string("Assertion violation: ") + cond + (text != NULL ? (std::string(" (") + text + std::string(")")) : ""), file, line); + throw AssertionViolationException(what(cond, file, line, text)); } @@ -100,10 +100,11 @@ void Bugcheck::debugger(const char* msg, const char* file, int line) } -std::string Bugcheck::what(const char* msg, const char* file, int line) +std::string Bugcheck::what(const char* msg, const char* file, int line, const char* text) { std::ostringstream str; if (msg) str << msg << " "; + if (text != NULL) str << "(" << text << ") "; str << "in file \"" << file << "\", line " << line; return str.str(); } diff --git a/Foundation/src/Timestamp.cpp b/Foundation/src/Timestamp.cpp index a3c8a55f0..2497eb291 100644 --- a/Foundation/src/Timestamp.cpp +++ b/Foundation/src/Timestamp.cpp @@ -18,6 +18,13 @@ #include "Poco/Timespan.h" #include "Poco/Exception.h" #include +#ifdef min + #undef min +#endif +#ifdef max + #undef max +#endif +#include #if defined(POCO_OS_FAMILY_UNIX) #include #include @@ -260,6 +267,8 @@ Timestamp& Timestamp::operator -= (const Timespan& span) return *this -= span.totalMicroseconds(); } +const Timestamp::TimeVal Timestamp::Min = std::numeric_limits::min(); +const Timestamp::TimeVal Timestamp::Max = std::numeric_limits::max(); #if defined(_WIN32)