11 #ifndef MSGPACK_V1_TYPE_CPP11_CHRONO_HPP
12 #define MSGPACK_V1_TYPE_CPP11_CHRONO_HPP
20 #include <boost/numeric/conversion/cast.hpp>
30 template <
typename Clock,
typename Duration>
31 struct as<std::chrono::time_point<Clock, Duration>> {
35 std::chrono::time_point<Clock, Duration> tp;
40 tp += std::chrono::seconds(sec);
45 uint32_t nanosec = boost::numeric_cast<uint32_t>(value >> 34);
46 uint64_t sec = value & 0x00000003ffffffffLL;
47 tp += std::chrono::duration_cast<Duration>(
48 std::chrono::nanoseconds(nanosec));
49 tp += std::chrono::seconds(sec);
58 tp += std::chrono::seconds(sec);
59 tp += std::chrono::duration_cast<Duration>(
60 std::chrono::nanoseconds(nanosec));
64 tp += std::chrono::seconds(sec);
68 tp += std::chrono::seconds(sec);
69 int64_t ns = boost::numeric_cast<int64_t>(nanosec) - 1000000000L;
70 tp += std::chrono::duration_cast<Duration>(
71 std::chrono::nanoseconds(ns));
82 template <
typename Clock,
typename Duration>
83 struct convert<std::chrono::time_point<Clock, Duration>> {
87 std::chrono::time_point<Clock, Duration> tp;
92 tp += std::chrono::seconds(sec);
98 uint32_t nanosec = boost::numeric_cast<uint32_t>(value >> 34);
99 uint64_t sec = value & 0x00000003ffffffffLL;
100 tp += std::chrono::duration_cast<Duration>(
101 std::chrono::nanoseconds(nanosec));
102 tp += std::chrono::seconds(sec);
112 tp += std::chrono::seconds(sec);
113 tp += std::chrono::duration_cast<Duration>(
114 std::chrono::nanoseconds(nanosec));
118 tp += std::chrono::seconds(sec);
122 tp += std::chrono::seconds(sec);
123 int64_t ns = boost::numeric_cast<int64_t>(nanosec) - 1000000000L;
124 tp += std::chrono::duration_cast<Duration>(
125 std::chrono::nanoseconds(ns));
138 template <
typename Clock,
typename Duration>
139 struct pack<std::chrono::time_point<Clock, Duration>> {
140 template <
typename Stream>
142 int64_t count = boost::numeric_cast<int64_t>(v.time_since_epoch().count());
144 Duration::period::ratio::num *
145 (1000000000L / Duration::period::ratio::den);
147 int64_t nanosec = count % (1000000000L / nano_num) * nano_num;
150 nanosec = 1000000000L + nanosec;
154 * Duration::period::ratio::num
155 / Duration::period::ratio::den;
157 if ((sec >> 34) == 0) {
158 uint64_t data64 = (boost::numeric_cast<uint64_t>(nanosec) << 34) | boost::numeric_cast<uint64_t>(sec);
159 if ((data64 & 0xffffffff00000000L) == 0) {
162 uint32_t data32 = boost::numeric_cast<uint32_t>(data64);
189 template <
typename Clock,
typename Duration>
192 int64_t count = boost::numeric_cast<int64_t>(v.time_since_epoch().count());
195 Duration::period::ratio::num *
196 (1000000000L / Duration::period::ratio::den);
198 int64_t nanosec = count % (1000000000L / nano_num) * nano_num;
201 nanosec = 1000000000L + nanosec;
205 * Duration::period::ratio::num
206 / Duration::period::ratio::den;
207 if ((sec >> 34) == 0) {
208 uint64_t data64 = (boost::numeric_cast<uint64_t>(nanosec) << 34) | boost::numeric_cast<uint64_t>(sec);
209 if ((data64 & 0xffffffff00000000L) == 0) {
214 p[0] =
static_cast<char>(-1);
215 uint32_t data32 = boost::numeric_cast<uint32_t>(data64);
224 p[0] =
static_cast<char>(-1);
234 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:231
void * allocate_no_align(size_t size)
Definition: cpp03_zone.hpp:271
@ 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:32
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:84
Definition: adaptor_base.hpp:27
void operator()(msgpack::object::with_zone &o, const std::chrono::time_point< Clock, Duration > &v) const
Definition: chrono.hpp:191
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:141
Definition: adaptor_base.hpp:32
Definition: object.hpp:35
msgpack::zone & zone
Definition: object.hpp:37
const char * data() const
Definition: object_fwd.hpp:44
int8_t type() const
Definition: object_fwd.hpp:43
const char * ptr
Definition: object_fwd.hpp:46
uint32_t size
Definition: object_fwd.hpp:45
Object class that corresponding to MessagePack format object.
Definition: object_fwd.hpp:75
union_type via
Definition: object_fwd.hpp:93
msgpack::type::object_type type
Definition: object_fwd.hpp:92
#define _msgpack_load64(cast, from, to)
Definition: sysdep.hpp:172
#define _msgpack_store32(to, num)
Definition: sysdep.hpp:179
#define _msgpack_store64(to, num)
Definition: sysdep.hpp:181
#define _msgpack_load32(cast, from, to)
Definition: sysdep.hpp:168
msgpack::object_ext ext
Definition: object_fwd.hpp:89
#define MSGPACK_API_VERSION_NAMESPACE(ns)
Definition: versioning.hpp:66