OFFIS DCMTK  Version 3.6.0
timehelp.h
Go to the documentation of this file.
1 // Module: Log4CPLUS
2 // File: timehelper.h
3 // Created: 6/2003
4 // Author: Tad E. Smith
5 //
6 //
7 // Copyright 2003-2009 Tad E. Smith
8 //
9 // Licensed under the Apache License, Version 2.0 (the "License");
10 // you may not use this file except in compliance with the License.
11 // You may obtain a copy of the License at
12 //
13 // http://www.apache.org/licenses/LICENSE-2.0
14 //
15 // Unless required by applicable law or agreed to in writing, software
16 // distributed under the License is distributed on an "AS IS" BASIS,
17 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 // See the License for the specific language governing permissions and
19 // limitations under the License.
20 
23 #ifndef _LOG4CPLUS_HELPERS_TIME_HELPER_HEADER_
24 #define _LOG4CPLUS_HELPERS_TIME_HELPER_HEADER_
25 
26 #include "dcmtk/oflog/config.h"
27 #include "dcmtk/oflog/tstring.h"
28 
29 #ifdef TM_IN_SYS_TIME
30 #include <sys/time.h>
31 #endif
32 
33 //#include <time.h>
34 #define INCLUDE_CTIME
35 #include "dcmtk/ofstd/ofstdinc.h"
36 
37 
38 namespace log4cplus {
39 
40 namespace helpers {
41 
45 class LOG4CPLUS_EXPORT Time {
46 public:
47  Time();
48  Time(time_t tv_sec, long tv_usec);
49  explicit Time(time_t time);
50 
56  static Time gettimeofday();
57 
58  // Methods
62  time_t sec() const { return tv_sec; }
63 
67  long usec() const { return tv_usec; }
68 
72  void sec(time_t s) { tv_sec = s; }
73 
77  void usec(long us) { tv_usec = us; }
78 
82  time_t setTime(struct tm* t);
83 
87  time_t getTime() const;
88 
93  void gmtime(struct tm* t) const;
94 
99  void localtime(struct tm* t) const;
100 
114  log4cplus::tstring getFormattedTime(const log4cplus::tstring& fmt,
115  bool use_gmtime = false) const;
116 
117  // Operators
118  Time& operator+=(const Time& rhs);
119  Time& operator-=(const Time& rhs);
120  Time& operator/=(long rhs);
121  Time& operator*=(long rhs);
122 
123 private:
124  void build_q_value (log4cplus::tstring & q_str) const;
125  void build_uc_q_value (log4cplus::tstring & uc_q_str) const;
126 
127  // Data
128  time_t tv_sec; /* seconds */
129  long tv_usec; /* microseconds */
130 };
131 
132 
133 LOG4CPLUS_EXPORT const log4cplus::helpers::Time operator+
134  (const log4cplus::helpers::Time& lhs,
135  const log4cplus::helpers::Time& rhs);
136 LOG4CPLUS_EXPORT const log4cplus::helpers::Time operator-
137  (const log4cplus::helpers::Time& lhs,
138  const log4cplus::helpers::Time& rhs);
139 LOG4CPLUS_EXPORT const log4cplus::helpers::Time operator/
140  (const log4cplus::helpers::Time& lhs,
141  long rhs);
142 LOG4CPLUS_EXPORT const log4cplus::helpers::Time operator*
143  (const log4cplus::helpers::Time& lhs,
144  long rhs);
145 
146 LOG4CPLUS_EXPORT bool operator<(const log4cplus::helpers::Time& lhs,
147  const log4cplus::helpers::Time& rhs);
148 LOG4CPLUS_EXPORT bool operator<=(const log4cplus::helpers::Time& lhs,
149  const log4cplus::helpers::Time& rhs);
150 
151 LOG4CPLUS_EXPORT bool operator>(const log4cplus::helpers::Time& lhs,
152  const log4cplus::helpers::Time& rhs);
153 LOG4CPLUS_EXPORT bool operator>=(const log4cplus::helpers::Time& lhs,
154  const log4cplus::helpers::Time& rhs);
155 
156 LOG4CPLUS_EXPORT bool operator==(const log4cplus::helpers::Time& lhs,
157  const log4cplus::helpers::Time& rhs);
158 LOG4CPLUS_EXPORT bool operator!=(const log4cplus::helpers::Time& lhs,
159  const log4cplus::helpers::Time& rhs);
160 
161 } // namespace helpers
162 
163 } // namespace log4cplus
164 
165 
166 #endif // _LOG4CPLUS_HELPERS_TIME_HELPER_HEADER_
167 


Generated on Thu Dec 20 2012 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.8.2