LCOV - code coverage report
Current view: top level - opt/homebrew/include/boost/date_time/posix_time - posix_time_config.hpp (source / functions) Hit Total Coverage
Test: test_dash_coverage.info Lines: 6 9 66.7 %
Date: 2026-06-25 07:23:51 Functions: 4 6 66.7 %

          Line data    Source code
       1             : #ifndef POSIX_TIME_CONFIG_HPP___
       2             : #define POSIX_TIME_CONFIG_HPP___
       3             : 
       4             : /* Copyright (c) 2002,2003,2005,2020 CrystalClear Software, Inc.
       5             :  * Use, modification and distribution is subject to the
       6             :  * Boost Software License, Version 1.0. (See accompanying
       7             :  * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
       8             :  * Author: Jeff Garland, Bart Garst
       9             :  * $Date$
      10             :  */
      11             : 
      12             : #include <cstdlib> //for MCW 7.2 std::abs(long long)
      13             : #include <boost/limits.hpp>
      14             : #include <boost/cstdint.hpp>
      15             : #include <boost/config/no_tr1/cmath.hpp>
      16             : #include <boost/date_time/time_duration.hpp>
      17             : #include <boost/date_time/time_resolution_traits.hpp>
      18             : #include <boost/date_time/gregorian/gregorian_types.hpp>
      19             : #include <boost/date_time/wrapping_int.hpp>
      20             : #include <boost/date_time/compiler_config.hpp>
      21             : 
      22             : namespace boost {
      23             : namespace posix_time {
      24             : 
      25             : 
      26             : #ifdef BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
      27             :   // set up conditional test compilations
      28             : #define BOOST_DATE_TIME_HAS_NANOSECONDS
      29             :   typedef date_time::time_resolution_traits<boost::date_time::time_resolution_traits_adapted64_impl, boost::date_time::nano,
      30             :     1000000000, 9 > time_res_traits;
      31             : #else
      32             :   // set up conditional test compilations
      33             : #undef  BOOST_DATE_TIME_HAS_NANOSECONDS
      34             :   typedef date_time::time_resolution_traits<
      35             :     boost::date_time::time_resolution_traits_adapted64_impl, boost::date_time::micro,
      36             :                                             1000000, 6 > time_res_traits;
      37             : 
      38             : #endif
      39             : 
      40             : 
      41             :   //! Base time duration type
      42             :   /*! \ingroup time_basics
      43             :    */
      44             :   class BOOST_SYMBOL_VISIBLE time_duration :
      45             :     public date_time::time_duration<time_duration, time_res_traits>
      46             :   {
      47             :   public:
      48             :     typedef time_res_traits rep_type;
      49             :     typedef time_res_traits::day_type day_type;
      50             :     typedef time_res_traits::hour_type hour_type;
      51             :     typedef time_res_traits::min_type min_type;
      52             :     typedef time_res_traits::sec_type sec_type;
      53             :     typedef time_res_traits::fractional_seconds_type fractional_seconds_type;
      54             :     typedef time_res_traits::tick_type tick_type;
      55             :     typedef time_res_traits::impl_type impl_type;
      56          28 :     BOOST_CXX14_CONSTEXPR time_duration(hour_type hour,
      57             :                                         min_type min,
      58             :                                         sec_type sec,
      59             :                                         fractional_seconds_type fs=0) :
      60          15 :       date_time::time_duration<time_duration, time_res_traits>(hour,min,sec,fs)
      61          28 :     {}
      62             :    BOOST_CXX14_CONSTEXPR time_duration() :
      63             :       date_time::time_duration<time_duration, time_res_traits>(0,0,0)
      64             :     {}
      65             :     //! Construct from special_values
      66          12 :     BOOST_CXX14_CONSTEXPR time_duration(boost::date_time::special_values sv) :
      67           6 :       date_time::time_duration<time_duration, time_res_traits>(sv)
      68          12 :     {}
      69             :     //Give duration access to ticks constructor -- hide from users
      70             :     friend class date_time::time_duration<time_duration, time_res_traits>;
      71             :   protected:
      72           0 :     BOOST_CXX14_CONSTEXPR explicit time_duration(impl_type tick_count) :
      73           0 :       date_time::time_duration<time_duration, time_res_traits>(tick_count)
      74           0 :     {}
      75             :   };
      76             : 
      77             : #ifdef BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
      78             : 
      79             :   //! Simple implementation for the time rep
      80             :   struct simple_time_rep
      81             :   {
      82             :     typedef gregorian::date      date_type;
      83             :     typedef time_duration        time_duration_type;
      84             :     BOOST_CXX14_CONSTEXPR simple_time_rep(date_type d, time_duration_type tod) :
      85             :       day(d),
      86             :       time_of_day(tod)
      87             :     {
      88             :       // make sure we have sane values for date & time
      89             :       if(!day.is_special() && !time_of_day.is_special()){
      90             :         if(time_of_day >= time_duration_type(24,0,0)) {
      91             :           while(time_of_day >= time_duration_type(24,0,0)) {
      92             :             day += date_type::duration_type(1);
      93             :             time_of_day -= time_duration_type(24,0,0);
      94             :           }
      95             :         }
      96             :         else if(time_of_day.is_negative()) {
      97             :           while(time_of_day.is_negative()) {
      98             :             day -= date_type::duration_type(1);
      99             :             time_of_day += time_duration_type(24,0,0);
     100             :           }
     101             :         }
     102             :       }
     103             :     }
     104             :     date_type day;
     105             :     time_duration_type time_of_day;
     106             :     BOOST_CXX14_CONSTEXPR bool is_special()const
     107             :     {
     108             :       return(is_pos_infinity() || is_neg_infinity() || is_not_a_date_time());
     109             :     }
     110             :     BOOST_CXX14_CONSTEXPR bool is_pos_infinity()const
     111             :     {
     112             :       return(day.is_pos_infinity() || time_of_day.is_pos_infinity());
     113             :     }
     114             :     BOOST_CXX14_CONSTEXPR bool is_neg_infinity()const
     115             :     {
     116             :       return(day.is_neg_infinity() || time_of_day.is_neg_infinity());
     117             :     }
     118             :     BOOST_CXX14_CONSTEXPR bool is_not_a_date_time()const
     119             :     {
     120             :       return(day.is_not_a_date() || time_of_day.is_not_a_date_time());
     121             :     }
     122             :   };
     123             : 
     124             :   class BOOST_SYMBOL_VISIBLE posix_time_system_config
     125             :   {
     126             :    public:
     127             :     typedef simple_time_rep time_rep_type;
     128             :     typedef gregorian::date date_type;
     129             :     typedef gregorian::date_duration date_duration_type;
     130             :     typedef time_duration time_duration_type;
     131             :     typedef time_res_traits::tick_type int_type;
     132             :     typedef time_res_traits resolution_traits;
     133             : #if (defined(BOOST_DATE_TIME_NO_MEMBER_INIT)) //help bad compilers
     134             : #else
     135             :     BOOST_STATIC_CONSTANT(boost::int64_t, tick_per_second = 1000000000);
     136             : #endif
     137             :   };
     138             : 
     139             : #else
     140             : 
     141             :   class millisec_posix_time_system_config
     142             :   {
     143             :    public:
     144             :     typedef boost::int64_t time_rep_type;
     145             :     //typedef time_res_traits::tick_type time_rep_type;
     146             :     typedef gregorian::date date_type;
     147             :     typedef gregorian::date_duration date_duration_type;
     148             :     typedef time_duration time_duration_type;
     149             :     typedef time_res_traits::tick_type int_type;
     150             :     typedef time_res_traits::impl_type impl_type;
     151             :     typedef time_res_traits resolution_traits;
     152             : #if (defined(BOOST_DATE_TIME_NO_MEMBER_INIT)) //help bad compilers
     153             : #else
     154             :     BOOST_STATIC_CONSTANT(boost::int64_t, tick_per_second = 1000000);
     155             : #endif
     156             :   };
     157             : 
     158             : #endif
     159             : 
     160             : } }//namespace posix_time
     161             : 
     162             : 
     163             : #endif
     164             : 
     165             : 

Generated by: LCOV version 1.16