20 #ifndef LUNCHBOX_UINT128_H
21 #define LUNCHBOX_UINT128_H
30 typedef UINT64 uint64_t;
38 std::ostream&
operator << ( std::ostream& os,
const uint128_t&
id );
49 : _high( 0 ), _low( low_ ) {}
55 explicit uint128_t(
const uint64_t high_,
const uint64_t low_ )
56 : _high( high_ ), _low( low_ ) {}
63 : _high( 0 ), _low( 0 ) { *
this = string; }
97 {
return _high == rhs._high && _low == rhs._low; }
104 {
return _high != rhs._high || _low != rhs._low; }
112 if( _high < rhs._high )
114 if( _high > rhs._high )
116 return _low < rhs._low;
125 if( _high > rhs._high )
127 if( _high < rhs._high )
129 return _low > rhs._low;
139 if( _high < rhs._high )
141 if( _high > rhs._high )
143 return _low <= rhs._low;
153 if( _high > rhs._high )
155 if( _high < rhs._high )
157 return _low >= rhs._low;
182 const uint64_t oldLow = _low;
185 _high += rhs._high + 1;
192 const uint64_t&
low()
const {
return _low; }
194 const uint64_t&
high()
const {
return _high; }
197 uint64_t&
low() {
return _low; }
199 uint64_t&
high() {
return _high; }
204 std::stringstream stream;
205 stream << std::hex << _high << _low;
206 const std::string str = stream.str();
207 return str.substr( 0, 3 ) +
".." +
208 str.substr( str.length() - 3, std::string::npos );
214 std::stringstream stream;
220 template<
class Archive >
221 void serialize( Archive& ar,
const unsigned int version )
227 #ifdef LUNCHBOX_USE_V1_API
229 static LUNCHBOX_API
const uint128_t ZERO;
241 os << std::hex <<
id.low() << std::dec;
243 os << std::hex <<
id.high() <<
':' <<
id.low() << std::dec;
261 if( result.
low() < a.
low( ))
279 if( result.
low() > a.
low( ))
310 LUNCHBOX_API uint128_t
make_uint128(
const char*
string );
312 #endif // LUNCHBOX_UINT128_H