diff options
Diffstat (limited to 'cpp/src/qpid/sys')
| -rw-r--r-- | cpp/src/qpid/sys/Shlib.h | 6 | ||||
| -rw-r--r-- | cpp/src/qpid/sys/Time.h | 4 | ||||
| -rw-r--r-- | cpp/src/qpid/sys/posix/Time.cpp | 28 |
3 files changed, 30 insertions, 8 deletions
diff --git a/cpp/src/qpid/sys/Shlib.h b/cpp/src/qpid/sys/Shlib.h index debf231125..e2752dc7d6 100644 --- a/cpp/src/qpid/sys/Shlib.h +++ b/cpp/src/qpid/sys/Shlib.h @@ -56,12 +56,6 @@ class Shlib { this->getSymbol(symbol))); } - /** Look up symbol in shared library. */ - template <class T*> - void* getSymbol(const std::string& symbol) { - return getSymbol<T>(symbol.c_str()); - } - private: void* handle; void load(const char* libname); diff --git a/cpp/src/qpid/sys/Time.h b/cpp/src/qpid/sys/Time.h index c87bd6f05b..860fc49097 100644 --- a/cpp/src/qpid/sys/Time.h +++ b/cpp/src/qpid/sys/Time.h @@ -24,6 +24,7 @@ #include <stdint.h> #include <limits> +#include <iosfwd> namespace qpid { namespace sys { @@ -54,6 +55,8 @@ class AbsTime { friend bool operator>(const AbsTime& a, const AbsTime& b); }; +std::ostream& operator << (std::ostream&, const AbsTime&); + class Duration { static int64_t max() { return std::numeric_limits<int64_t>::max(); } int64_t nanosecs; @@ -67,6 +70,7 @@ class Duration { inline operator int64_t() const; }; +std::ostream& operator << (std::ostream&, const Duration&); AbsTime::AbsTime(const AbsTime& t, const Duration& d) : time_ns(d == Duration::max() ? max() : t.time_ns+d.nanosecs) diff --git a/cpp/src/qpid/sys/posix/Time.cpp b/cpp/src/qpid/sys/posix/Time.cpp index ac63a3d038..b2b7a81130 100644 --- a/cpp/src/qpid/sys/posix/Time.cpp +++ b/cpp/src/qpid/sys/posix/Time.cpp @@ -22,7 +22,7 @@ #include "PrivatePosix.h" #include "qpid/sys/Time.h" - +#include <ostream> #include <time.h> #include <sys/time.h> @@ -40,7 +40,7 @@ AbsTime AbsTime::now() { struct timespec& toTimespec(struct timespec& ts, const Duration& t) { ts.tv_sec = t / TIME_SEC; ts.tv_nsec = t % TIME_SEC; - return ts; + return ts; } struct timeval& toTimeval(struct timeval& tv, const Duration& t) { @@ -53,5 +53,29 @@ Duration toTime(const struct timespec& ts) { return ts.tv_sec*TIME_SEC + ts.tv_nsec; } +std::ostream& operator<<(std::ostream& o, const Duration& d) { + return o << int64_t(d) << "ns"; +} + +std::ostream& operator<<(std::ostream& o, const AbsTime& t) { + static const char * month_abbrevs[] = { + "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec" + }; + struct tm * timeinfo; + time_t rawtime(t.timeValue()/TIME_SEC); + timeinfo = localtime (&rawtime); + char time_string[100]; + sprintf ( time_string, + "%d-%s-%02d %02d:%02d:%02d", + 1900 + timeinfo->tm_year, + month_abbrevs[timeinfo->tm_mon], + timeinfo->tm_mday, + timeinfo->tm_hour, + timeinfo->tm_min, + timeinfo->tm_sec + ); + return o << time_string; +} + }} |
