11#ifndef MSGPACK_V1_TYPE_CPP11_CHRONO_HPP
12#define MSGPACK_V1_TYPE_CPP11_CHRONO_HPP
34 bool target_is_signed = std::is_signed<Target>::value,
35 bool source_is_signed = std::is_signed<Source>::value,
36 typename =
typename std::enable_if<
37 std::is_integral<Target>::value &&
38 std::is_integral<Source>::value
48template <
typename Target,
typename Source>
55template <
typename Target,
typename Source>
60 :
value{source < std::numeric_limits<Target>::min()} {}
67 bool target_is_signed = std::is_signed<Target>::value,
68 bool source_is_signed = std::is_signed<Source>::value,
69 typename =
typename std::enable_if<
70 std::is_integral<Target>::value &&
71 std::is_integral<Source>::value
78 :
value{source > std::numeric_limits<Target>::max()} {}
81template <
typename Target,
typename Source>
87 sizeof(Target) >= sizeof(Source)
93 : source > static_cast<Source>(std::numeric_limits<Target>::max())
97template <
typename Target,
typename Source>
103 sizeof(Target) > sizeof(Source)
108 : source > static_cast<Source>(std::numeric_limits<Target>::max())
116 typename =
typename std::enable_if<
117 std::is_integral<Target>::value &&
118 std::is_integral<Source>::value
123 throw std::underflow_error{
124 "casting from Source to Target causes an underflow error"
128 throw std::overflow_error{
129 "casting from Source to Target causes an overflow error"
133 return static_cast<Target
>(source);
137template <
typename Clock,
typename Duration>
138struct as<std::chrono::time_point<Clock, Duration>> {
142 std::chrono::time_point<Clock, Duration> tp;
147 tp += std::chrono::seconds(sec);
153 uint64_t sec = value & 0x00000003ffffffffLL;
154 tp += std::chrono::duration_cast<Duration>(
155 std::chrono::nanoseconds(nanosec));
156 tp += std::chrono::seconds(sec);
165 tp += std::chrono::seconds(sec);
166 tp += std::chrono::duration_cast<Duration>(
167 std::chrono::nanoseconds(nanosec));
171 tp += std::chrono::seconds(sec);
175 tp += std::chrono::seconds(sec);
177 tp += std::chrono::duration_cast<Duration>(
178 std::chrono::nanoseconds(ns));
189template <
typename Clock,
typename Duration>
190struct convert<std::chrono::time_point<Clock, Duration>> {
194 std::chrono::time_point<Clock, Duration> tp;
199 tp += std::chrono::seconds(sec);
206 uint64_t sec = value & 0x00000003ffffffffLL;
207 tp += std::chrono::duration_cast<Duration>(
208 std::chrono::nanoseconds(nanosec));
209 tp += std::chrono::seconds(sec);
219 tp += std::chrono::seconds(sec);
220 tp += std::chrono::duration_cast<Duration>(
221 std::chrono::nanoseconds(nanosec));
225 tp += std::chrono::seconds(sec);
229 tp += std::chrono::seconds(sec);
231 tp += std::chrono::duration_cast<Duration>(
232 std::chrono::nanoseconds(ns));
245template <
typename Clock,
typename Duration>
246struct pack<std::chrono::time_point<Clock, Duration>> {
247 template <
typename Stream>
251 Duration::period::ratio::num *
252 (1000000000L / Duration::period::ratio::den);
254 int64_t nanosec = count % (1000000000L / nano_num) * nano_num;
257 nanosec = 1000000000L + nanosec;
261 * Duration::period::ratio::num
262 / Duration::period::ratio::den;
264 if ((sec >> 34) == 0) {
266 if ((data64 & 0xffffffff00000000L) == 0) {
296template <
typename Clock,
typename Duration>
302 Duration::period::ratio::num *
303 (1000000000L / Duration::period::ratio::den);
305 int64_t nanosec = count % (1000000000L / nano_num) * nano_num;
308 nanosec = 1000000000L + nanosec;
312 * Duration::period::ratio::num
313 / Duration::period::ratio::den;
314 if ((sec >> 34) == 0) {
316 if ((data64 & 0xffffffff00000000L) == 0) {
321 p[0] =
static_cast<char>(-1);
331 p[0] =
static_cast<char>(-1);
341 p[0] =
static_cast<char>(-1);
The class template that supports continuous packing.
Definition pack.hpp:33
packer< Stream > & pack_ext(size_t l, int8_t type)
Packing ext header, type, and length.
Definition pack.hpp:1316
packer< Stream > & pack_ext_body(const char *b, uint32_t l)
Packing ext body.
Definition pack.hpp:1375
Definition object_fwd.hpp:234
void * allocate_no_align(size_t size)
Definition cpp03_zone.hpp:270
Target integral_cast(Source source)
Definition chrono.hpp:121
Definition adaptor_base.hpp:22
Definition array_ref.hpp:24
@ EXT
Definition object_fwd_decl.hpp:42
Definition adaptor_base.hpp:15
std::chrono::time_point< Clock, Duration > operator()(msgpack::object const &o) const
Definition chrono.hpp:139
Definition object_fwd_decl.hpp:61
msgpack::object const & operator()(msgpack::object const &o, std::chrono::time_point< Clock, Duration > &v) const
Definition chrono.hpp:191
Definition adaptor_base.hpp:27
bool value
Definition chrono.hpp:95
would_overflow(Source source)
Definition chrono.hpp:85
bool value
Definition chrono.hpp:110
would_overflow(Source source)
Definition chrono.hpp:101
would_overflow(Source source)
Definition chrono.hpp:77
bool value
Definition chrono.hpp:79
would_underflow(Source source)
Definition chrono.hpp:52
bool value
Definition chrono.hpp:53
bool value
Definition chrono.hpp:61
would_underflow(Source source)
Definition chrono.hpp:59
would_underflow(Source)
Definition chrono.hpp:44
bool value
Definition chrono.hpp:45
void operator()(msgpack::object::with_zone &o, const std::chrono::time_point< Clock, Duration > &v) const
Definition chrono.hpp:298
Definition adaptor_base.hpp:43
msgpack::packer< Stream > & operator()(msgpack::packer< Stream > &o, std::chrono::time_point< Clock, Duration > const &v) const
Definition chrono.hpp:248
Definition adaptor_base.hpp:32
int8_t type() const
Definition object_fwd.hpp:43
const char * ptr
Definition object_fwd.hpp:46
const char * data() const
Definition object_fwd.hpp:44
uint32_t size
Definition object_fwd.hpp:45
msgpack::zone & zone
Definition object.hpp:37
Object class that corresponding to MessagePack format object.
Definition object_fwd.hpp:77
union_type via
Definition object_fwd.hpp:95
msgpack::type::object_type type
Definition object_fwd.hpp:94
object_with_zone_type with_zone
Definition object_fwd.hpp:225
#define _msgpack_load64(cast, from, to)
Definition sysdep.hpp:180
#define _msgpack_store32(to, num)
Definition sysdep.hpp:187
#define _msgpack_store64(to, num)
Definition sysdep.hpp:189
#define _msgpack_load32(cast, from, to)
Definition sysdep.hpp:176
msgpack::object_ext ext
Definition object_fwd.hpp:91
#define MSGPACK_API_VERSION_NAMESPACE(ns)
Definition versioning.hpp:66