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

          Line data    Source code
       1             : #ifndef GREG_DURATION_HPP___
       2             : #define GREG_DURATION_HPP___
       3             : 
       4             : /* Copyright (c) 2002,2003 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 <boost/date_time/compiler_config.hpp>
      13             : #include <boost/date_time/date_duration.hpp>
      14             : #include <boost/date_time/int_adapter.hpp>
      15             : #include <boost/date_time/special_defs.hpp>
      16             : 
      17             : namespace boost {
      18             : namespace gregorian {
      19             : 
      20             :   //!An internal date representation that includes infinities, not a date
      21             :   typedef boost::date_time::duration_traits_adapted date_duration_rep;
      22             : 
      23             :   //! Durations in days for gregorian system
      24             :   /*! \ingroup date_basics
      25             :    */
      26             :   class BOOST_SYMBOL_VISIBLE date_duration :
      27             :     public boost::date_time::date_duration< date_duration_rep >
      28             :   {
      29             :     typedef boost::date_time::date_duration< date_duration_rep > base_type;
      30             : 
      31             :   public:
      32             :     typedef base_type::duration_rep duration_rep;
      33             : 
      34             :     //! Construct from a day count
      35           0 :     explicit date_duration(duration_rep day_count = 0) : base_type(day_count) {}
      36             : 
      37             :     //! construct from special_values
      38           0 :     date_duration(date_time::special_values sv) : base_type(sv) {}
      39             : 
      40             :     //! Copy constructor
      41             :     date_duration(const date_duration& other) : base_type(static_cast< base_type const& >(other))
      42             :     {}
      43             : 
      44             :     //! Construct from another date_duration
      45             :     date_duration(const base_type& other) : base_type(other)
      46             :     {}
      47             : 
      48             :     //  Relational operators
      49             :     //  NOTE: Because of date_time::date_duration< T > design choice we don't use Boost.Operators here,
      50             :     //  because we need the class to be a direct base. Either lose EBO, or define operators by hand.
      51             :     //  The latter is more effecient.
      52             :     bool operator== (const date_duration& rhs) const
      53             :     {
      54             :       return base_type::operator== (rhs);
      55             :     }
      56             :     bool operator!= (const date_duration& rhs) const
      57             :     {
      58             :       return !operator== (rhs);
      59             :     }
      60             :     bool operator< (const date_duration& rhs) const
      61             :     {
      62             :       return base_type::operator< (rhs);
      63             :     }
      64             :     bool operator> (const date_duration& rhs) const
      65             :     {
      66             :       return !(base_type::operator< (rhs) || base_type::operator== (rhs));
      67             :     }
      68             :     bool operator<= (const date_duration& rhs) const
      69             :     {
      70             :       return (base_type::operator< (rhs) || base_type::operator== (rhs));
      71             :     }
      72             :     bool operator>= (const date_duration& rhs) const
      73             :     {
      74             :       return !base_type::operator< (rhs);
      75             :     }
      76             : 
      77             :     //! Subtract another duration -- result is signed
      78             :     date_duration& operator-= (const date_duration& rhs)
      79             :     {
      80             :       base_type::operator-= (rhs);
      81             :       return *this;
      82             :     }
      83             :     friend date_duration operator- (date_duration rhs, date_duration const& lhs)
      84             :     {
      85             :       rhs -= lhs;
      86             :       return rhs;
      87             :     }
      88             : 
      89             :     //! Add a duration -- result is signed
      90             :     date_duration& operator+= (const date_duration& rhs)
      91             :     {
      92             :       base_type::operator+= (rhs);
      93             :       return *this;
      94             :     }
      95             :     friend date_duration operator+ (date_duration rhs, date_duration const& lhs)
      96             :     {
      97             :       rhs += lhs;
      98             :       return rhs;
      99             :     }
     100             : 
     101             :     //! unary- Allows for dd = -date_duration(2); -> dd == -2
     102             :     date_duration operator- ()const
     103             :     {
     104             :       return date_duration(get_rep() * (-1));
     105             :     }
     106             : 
     107             :     //! Division operations on a duration with an integer.
     108             :     date_duration& operator/= (int divisor)
     109             :     {
     110             :       base_type::operator/= (divisor);
     111             :       return *this;
     112             :     }
     113             :     friend date_duration operator/ (date_duration rhs, int lhs)
     114             :     {
     115             :       rhs /= lhs;
     116             :       return rhs;
     117             :     }
     118             : 
     119             :     //! Returns the smallest duration -- used by to calculate 'end'
     120             :     static date_duration unit()
     121             :     {
     122             :       return date_duration(base_type::unit().get_rep());
     123             :     }
     124             :   };      
     125             : 
     126             :   //! Shorthand for date_duration
     127             :   typedef date_duration days;
     128             : 
     129             : } } //namespace gregorian
     130             : 
     131             : #if defined(BOOST_DATE_TIME_OPTIONAL_GREGORIAN_TYPES)
     132             : #include <boost/date_time/date_duration_types.hpp>
     133             : #endif
     134             : 
     135             : #endif

Generated by: LCOV version 1.14