annotate DEPENDENCIES/generic/include/boost/asio/time_traits.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 //
Chris@16 2 // time_traits.hpp
Chris@16 3 // ~~~~~~~~~~~~~~~
Chris@16 4 //
Chris@101 5 // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
Chris@16 6 //
Chris@16 7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@16 8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 9 //
Chris@16 10
Chris@16 11 #ifndef BOOST_ASIO_TIME_TRAITS_HPP
Chris@16 12 #define BOOST_ASIO_TIME_TRAITS_HPP
Chris@16 13
Chris@16 14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
Chris@16 15 # pragma once
Chris@16 16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
Chris@16 17
Chris@16 18 #include <boost/asio/detail/socket_types.hpp> // Must come before posix_time.
Chris@16 19
Chris@16 20 #if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME) \
Chris@16 21 || defined(GENERATING_DOCUMENTATION)
Chris@16 22
Chris@16 23 #include <boost/date_time/posix_time/posix_time_types.hpp>
Chris@16 24
Chris@16 25 #include <boost/asio/detail/push_options.hpp>
Chris@16 26
Chris@16 27 namespace boost {
Chris@16 28 namespace asio {
Chris@16 29
Chris@16 30 /// Time traits suitable for use with the deadline timer.
Chris@16 31 template <typename Time>
Chris@16 32 struct time_traits;
Chris@16 33
Chris@16 34 /// Time traits specialised for posix_time.
Chris@16 35 template <>
Chris@16 36 struct time_traits<boost::posix_time::ptime>
Chris@16 37 {
Chris@16 38 /// The time type.
Chris@16 39 typedef boost::posix_time::ptime time_type;
Chris@16 40
Chris@16 41 /// The duration type.
Chris@16 42 typedef boost::posix_time::time_duration duration_type;
Chris@16 43
Chris@16 44 /// Get the current time.
Chris@16 45 static time_type now()
Chris@16 46 {
Chris@16 47 #if defined(BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK)
Chris@16 48 return boost::posix_time::microsec_clock::universal_time();
Chris@16 49 #else // defined(BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK)
Chris@16 50 return boost::posix_time::second_clock::universal_time();
Chris@16 51 #endif // defined(BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK)
Chris@16 52 }
Chris@16 53
Chris@16 54 /// Add a duration to a time.
Chris@16 55 static time_type add(const time_type& t, const duration_type& d)
Chris@16 56 {
Chris@16 57 return t + d;
Chris@16 58 }
Chris@16 59
Chris@16 60 /// Subtract one time from another.
Chris@16 61 static duration_type subtract(const time_type& t1, const time_type& t2)
Chris@16 62 {
Chris@16 63 return t1 - t2;
Chris@16 64 }
Chris@16 65
Chris@16 66 /// Test whether one time is less than another.
Chris@16 67 static bool less_than(const time_type& t1, const time_type& t2)
Chris@16 68 {
Chris@16 69 return t1 < t2;
Chris@16 70 }
Chris@16 71
Chris@16 72 /// Convert to POSIX duration type.
Chris@16 73 static boost::posix_time::time_duration to_posix_duration(
Chris@16 74 const duration_type& d)
Chris@16 75 {
Chris@16 76 return d;
Chris@16 77 }
Chris@16 78 };
Chris@16 79
Chris@16 80 } // namespace asio
Chris@16 81 } // namespace boost
Chris@16 82
Chris@16 83 #include <boost/asio/detail/pop_options.hpp>
Chris@16 84
Chris@16 85 #endif // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
Chris@16 86 // || defined(GENERATING_DOCUMENTATION)
Chris@16 87
Chris@16 88 #endif // BOOST_ASIO_TIME_TRAITS_HPP