1
/* $Id: types.hpp 2394 2008-12-23 17:27:53Z bennylp $ */
3
* Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
4
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
#ifndef __PJPP_TYPES_HPP__
21
#define __PJPP_TYPES_HPP__
43
// Class Pj_Object is declared in pool.hpp
47
// Time value wrapper.
49
class Pj_Time_Val : public pj_time_val
56
Pj_Time_Val(long init_sec, long init_msec)
62
Pj_Time_Val(const Pj_Time_Val &rhs)
68
explicit Pj_Time_Val(const pj_time_val &tv)
89
void set_msec(long ms)
97
return PJ_TIME_VAL_MSEC((*this));
100
bool operator == (const Pj_Time_Val &rhs) const
102
return PJ_TIME_VAL_EQ((*this), rhs);
105
bool operator > (const Pj_Time_Val &rhs) const
107
return PJ_TIME_VAL_GT((*this), rhs);
110
bool operator >= (const Pj_Time_Val &rhs) const
112
return PJ_TIME_VAL_GTE((*this), rhs);
115
bool operator < (const Pj_Time_Val &rhs) const
117
return PJ_TIME_VAL_LT((*this), rhs);
120
bool operator <= (const Pj_Time_Val &rhs) const
122
return PJ_TIME_VAL_LTE((*this), rhs);
125
Pj_Time_Val & operator = (const Pj_Time_Val &rhs)
132
Pj_Time_Val & operator += (const Pj_Time_Val &rhs)
134
PJ_TIME_VAL_ADD((*this), rhs);
138
Pj_Time_Val & operator -= (const Pj_Time_Val &rhs)
140
PJ_TIME_VAL_SUB((*this), rhs);
144
/* Must include os.hpp to use these, otherwise unresolved in linking */
145
inline pj_status_t gettimeofday();
146
inline pj_parsed_time decode();
147
inline pj_status_t encode(const pj_parsed_time *pt);
148
inline pj_status_t to_gmt();
149
inline pj_status_t to_local();
155
pj_time_val_normalize(this);
161
// Macro to declare common object comparison operators.
163
#define PJ_DECLARE_OPERATORS(rhs_type) \
164
bool operator!=(rhs_type rhs) const { \
165
return !operator==(rhs); } \
166
bool operator<=(rhs_type rhs) const { \
167
return operator<(rhs) || operator==(rhs); } \
168
bool operator>(rhs_type rhs) const { \
169
return !operator<=(rhs); } \
170
bool operator>=(rhs_type rhs) const { \
171
return !operator<(rhs); }
174
#endif /* __PJPP_TYPES_HPP__ */