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>
69 typename =
typename std::enable_if<
70 std::is_integral<Target>::value &&
71 std::is_integral<Source>::value
81template <
typename Target,
typename Source>
97template <
typename Target,
typename Source>
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"
137template <
typename Clock,
typename Duration>
138struct as<std::chrono::time_point<Clock, Duration>> {
142 std::chrono::time_point<Clock, Duration>
tp;
143 switch(
o.via.ext.size) {
147 tp += std::chrono::seconds(
sec);
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;
195 switch(
o.via.ext.size) {
199 tp += std::chrono::seconds(
sec);
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>
249 int64_t count = detail::integral_cast<int64_t>(
v.time_since_epoch().count());
251 Duration::period::ratio::num *
252 (1000000000L / Duration::period::ratio::den);
261 * Duration::period::ratio::num
262 / Duration::period::ratio::den;
264 if ((
sec >> 34) == 0) {
266 if ((
data64 & 0xffffffff00000000L) == 0) {
272 o.pack_ext_body(
buf, 4);
279 o.pack_ext_body(
buf, 8);
290 o.pack_ext_body(
buf, 12);
296template <
typename Clock,
typename Duration>
299 int64_t count = detail::integral_cast<int64_t>(
v.time_since_epoch().count());
302 Duration::period::ratio::num *
303 (1000000000L / Duration::period::ratio::den);
312 * Duration::period::ratio::num
313 / Duration::period::ratio::den;
314 if ((
sec >> 34) == 0) {
316 if ((
data64 & 0xffffffff00000000L) == 0) {
318 o.type = msgpack::type::EXT;
320 char*
p =
static_cast<char*
>(
o.zone.allocate_no_align(
o.via.ext.size + 1));
321 p[0] =
static_cast<char>(-1);
328 o.type = msgpack::type::EXT;
330 char*
p =
static_cast<char*
>(
o.zone.allocate_no_align(
o.via.ext.size + 1));
331 p[0] =
static_cast<char>(-1);
338 o.type = msgpack::type::EXT;
340 char*
p =
static_cast<char*
>(
o.zone.allocate_no_align(
o.via.ext.size + 1));
341 p[0] =
static_cast<char>(-1);
The class template that supports continuous packing.
Definition pack.hpp:33
Definition object_fwd.hpp:231
Target integral_cast(Source source)
Definition chrono.hpp:121
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
Object class that corresponding to MessagePack format object.
Definition object_fwd.hpp:75
#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
#define MSGPACK_API_VERSION_NAMESPACE(ns)
Definition versioning.hpp:66