23 #ifndef __mqtt_types_h
24 #define __mqtt_types_h
40 using string = std::string;
42 using binary = std::string;
45 using string_ptr = std::shared_ptr<const string>;
47 using binary_ptr = std::shared_ptr<const binary>;
58 template <
class Rep,
class Period>
59 std::chrono::seconds to_seconds(
const std::chrono::duration<Rep, Period>& dur) {
60 return std::chrono::duration_cast<std::chrono::seconds>(dur);
69 template <
class Rep,
class Period>
70 long to_seconds_count(
const std::chrono::duration<Rep, Period>& dur) {
71 return (
long) to_seconds(dur).count();
80 template <
class Rep,
class Period>
81 std::chrono::milliseconds to_milliseconds(
const std::chrono::duration<Rep, Period>& dur) {
82 return std::chrono::duration_cast<std::chrono::milliseconds>(dur);
91 template <
class Rep,
class Period>
92 long to_milliseconds_count(
const std::chrono::duration<Rep, Period>& dur) {
93 return (
long) to_milliseconds(dur).count();
104 inline bool to_bool(
int n) {
return n != 0; }
110 inline int to_int(
bool b) {
return b ? (!0) : 0; }
116 #endif // __mqtt_types_h