LCOV - code coverage report
Current view: top level - usr/include/boost/date_time/posix_time - posix_time_config.hpp (source / functions) Hit Total Coverage
Test: ROSE Lines: 0 6 0.0 %
Date: 2022-12-08 13:48:47 Functions: 0 0 -
Legend: Lines: hit not hit

          Line data    Source code
       1             : #ifndef POSIX_TIME_CONFIG_HPP___
       2             : #define POSIX_TIME_CONFIG_HPP___
       3             : 
       4             : /* Copyright (c) 2002,2003,2005 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             : //Remove the following line if you want 64 bit millisecond resolution time
      26             : //#define BOOST_GDTL_POSIX_TIME_STD_CONFIG
      27             : 
      28             : #ifdef BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
      29             :   // set up conditional test compilations
      30             : #define BOOST_DATE_TIME_HAS_MILLISECONDS
      31             : #define BOOST_DATE_TIME_HAS_MICROSECONDS
      32             : #define BOOST_DATE_TIME_HAS_NANOSECONDS
      33             :   typedef date_time::time_resolution_traits<boost::date_time::time_resolution_traits_adapted64_impl, boost::date_time::nano,
      34             :     1000000000, 9 > time_res_traits;
      35             : #else
      36             :   // set up conditional test compilations
      37             : #define BOOST_DATE_TIME_HAS_MILLISECONDS
      38             : #define BOOST_DATE_TIME_HAS_MICROSECONDS
      39             : #undef  BOOST_DATE_TIME_HAS_NANOSECONDS
      40             :   typedef date_time::time_resolution_traits<
      41             :     boost::date_time::time_resolution_traits_adapted64_impl, boost::date_time::micro,
      42             :                                             1000000, 6 > time_res_traits;
      43             : 
      44             : 
      45             : // #undef BOOST_DATE_TIME_HAS_MILLISECONDS
      46             : // #undef BOOST_DATE_TIME_HAS_MICROSECONDS
      47             : // #undef BOOST_DATE_TIME_HAS_NANOSECONDS
      48             : //   typedef date_time::time_resolution_traits<boost::int64_t, boost::date_time::tenth,
      49             : //                                              10, 0 > time_res_traits;
      50             : 
      51             : #endif
      52             : 
      53             : 
      54             :   //! Base time duration type
      55             :   /*! \ingroup time_basics
      56             :    */
      57           0 :   class BOOST_SYMBOL_VISIBLE time_duration :
      58             :     public date_time::time_duration<time_duration, time_res_traits>
      59             :   {
      60             :   public:
      61             :     typedef time_res_traits rep_type;
      62             :     typedef time_res_traits::day_type day_type;
      63             :     typedef time_res_traits::hour_type hour_type;
      64             :     typedef time_res_traits::min_type min_type;
      65             :     typedef time_res_traits::sec_type sec_type;
      66             :     typedef time_res_traits::fractional_seconds_type fractional_seconds_type;
      67             :     typedef time_res_traits::tick_type tick_type;
      68             :     typedef time_res_traits::impl_type impl_type;
      69           0 :     time_duration(hour_type hour,
      70             :                   min_type min,
      71             :                   sec_type sec,
      72             :                   fractional_seconds_type fs=0) :
      73           0 :       date_time::time_duration<time_duration, time_res_traits>(hour,min,sec,fs)
      74           0 :     {}
      75             :     time_duration() :
      76             :       date_time::time_duration<time_duration, time_res_traits>(0,0,0)
      77             :     {}
      78             :     //! Construct from special_values
      79           0 :     time_duration(boost::date_time::special_values sv) :
      80           0 :       date_time::time_duration<time_duration, time_res_traits>(sv)
      81             :     {}
      82             :     //Give duration access to ticks constructor -- hide from users
      83             :     friend class date_time::time_duration<time_duration, time_res_traits>;
      84             :   protected:
      85             :     explicit time_duration(impl_type tick_count) :
      86             :       date_time::time_duration<time_duration, time_res_traits>(tick_count)
      87             :     {}
      88             :   };
      89             : 
      90             : #ifdef BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
      91             : 
      92             :   //! Simple implementation for the time rep
      93             :   struct simple_time_rep
      94             :   {
      95             :     typedef gregorian::date      date_type;
      96             :     typedef time_duration        time_duration_type;
      97             :     simple_time_rep(date_type d, time_duration_type tod) :
      98             :       day(d),
      99             :       time_of_day(tod)
     100             :     {
     101             :       // make sure we have sane values for date & time
     102             :       if(!day.is_special() && !time_of_day.is_special()){
     103             :         if(time_of_day >= time_duration_type(24,0,0)) {
     104             :           while(time_of_day >= time_duration_type(24,0,0)) {
     105             :             day += date_type::duration_type(1);
     106             :             time_of_day -= time_duration_type(24,0,0);
     107             :           }
     108             :         }
     109             :         else if(time_of_day.is_negative()) {
     110             :           while(time_of_day.is_negative()) {
     111             :             day -= date_type::duration_type(1);
     112             :             time_of_day += time_duration_type(24,0,0);
     113             :           }
     114             :         }
     115             :       }
     116             :     }
     117             :     date_type day;
     118             :     time_duration_type time_of_day;
     119             :     bool is_special()const
     120             :     {
     121             :       return(is_pos_infinity() || is_neg_infinity() || is_not_a_date_time());
     122             :     }
     123             :     bool is_pos_infinity()const
     124             :     {
     125             :       return(day.is_pos_infinity() || time_of_day.is_pos_infinity());
     126             :     }
     127             :     bool is_neg_infinity()const
     128             :     {
     129             :       return(day.is_neg_infinity() || time_of_day.is_neg_infinity());
     130             :     }
     131             :     bool is_not_a_date_time()const
     132             :     {
     133             :       return(day.is_not_a_date() || time_of_day.is_not_a_date_time());
     134             :     }
     135             :   };
     136             : 
     137             :   class BOOST_SYMBOL_VISIBLE posix_time_system_config
     138             :   {
     139             :    public:
     140             :     typedef simple_time_rep time_rep_type;
     141             :     typedef gregorian::date date_type;
     142             :     typedef gregorian::date_duration date_duration_type;
     143             :     typedef time_duration time_duration_type;
     144             :     typedef time_res_traits::tick_type int_type;
     145             :     typedef time_res_traits resolution_traits;
     146             : #if (defined(BOOST_DATE_TIME_NO_MEMBER_INIT)) //help bad compilers
     147             : #else
     148             :     BOOST_STATIC_CONSTANT(boost::int64_t, tick_per_second = 1000000000);
     149             : #endif
     150             :   };
     151             : 
     152             : #else
     153             : 
     154             :   class millisec_posix_time_system_config
     155             :   {
     156             :    public:
     157             :     typedef boost::int64_t time_rep_type;
     158             :     //typedef time_res_traits::tick_type time_rep_type;
     159             :     typedef gregorian::date date_type;
     160             :     typedef gregorian::date_duration date_duration_type;
     161             :     typedef time_duration time_duration_type;
     162             :     typedef time_res_traits::tick_type int_type;
     163             :     typedef time_res_traits::impl_type impl_type;
     164             :     typedef time_res_traits resolution_traits;
     165             : #if (defined(BOOST_DATE_TIME_NO_MEMBER_INIT)) //help bad compilers
     166             : #else
     167             :     BOOST_STATIC_CONSTANT(boost::int64_t, tick_per_second = 1000000);
     168             : #endif
     169             :   };
     170             : 
     171             : #endif
     172             : 
     173             : } }//namespace posix_time
     174             : 
     175             : 
     176             : #endif
     177             : 
     178             : 

Generated by: LCOV version 1.14