Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:43:59

0001 /*-----------------------------------------------------------------------------+
0002 Copyright (c) 2008-2009: Joachim Faulhaber
0003 +------------------------------------------------------------------------------+
0004    Distributed under the Boost Software License, Version 1.0.
0005       (See accompanying file LICENCE.txt or copy at
0006            http://www.boost.org/LICENSE_1_0.txt)
0007 +-----------------------------------------------------------------------------*/
0008 
0009 /*------------------------------------------------------------------------------
0010 itl_ptime provides adapter code for boost::posix_time::ptime.
0011 It implements incrementation (++) decrementation (--) and a neutral element
0012 w.r.t. addition (identity_element()).
0013 ------------------------------------------------------------------------------*/
0014 
0015 #ifndef BOOST_ICL_PTIME_HPP_JOFA_080416
0016 #define BOOST_ICL_PTIME_HPP_JOFA_080416
0017 
0018 #include <boost/icl/detail/boost_config.hpp>
0019 #include <boost/detail/workaround.hpp>
0020 
0021 #ifdef BOOST_MSVC 
0022 #pragma warning(push)
0023 #pragma warning(disable:4100) // boost/date_time/time.hpp(80) : warning C4100: 'as_offset' : unreferenced formal parameter
0024 #pragma warning(disable:4127) // conditional expression is constant
0025 #pragma warning(disable:4244) // 'argument' : conversion from 'int' to 'unsigned short', possible loss of data
0026 #pragma warning(disable:4702) // boost\lexical_cast.hpp(1159) : warning C4702: unreachable code
0027 #pragma warning(disable:4996) // Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators'
0028 #endif                        
0029 
0030 #include <stdio.h>
0031 #include <string>
0032 #include <sstream>
0033 #include <iostream>
0034 #include <boost/date_time/posix_time/posix_time.hpp>
0035 
0036 #ifdef BOOST_MSVC
0037 #pragma warning(pop)
0038 #endif
0039 
0040 #include <boost/icl/type_traits/identity_element.hpp>
0041 #include <boost/icl/type_traits/difference_type_of.hpp>
0042 #include <boost/icl/type_traits/size_type_of.hpp>
0043 #include <boost/icl/type_traits/is_discrete.hpp>
0044 
0045 namespace boost{namespace icl
0046 {
0047     template<> struct is_discrete<boost::posix_time::ptime>
0048     {
0049         typedef is_discrete type;
0050         BOOST_STATIC_CONSTANT(bool, value = true);
0051     };
0052 
0053     template<> 
0054     inline boost::posix_time::ptime identity_element<boost::posix_time::ptime>::value()
0055     { 
0056         return boost::posix_time::ptime(boost::posix_time::min_date_time); 
0057     }
0058 
0059     template<> 
0060     struct has_difference<boost::posix_time::ptime> 
0061     { 
0062         typedef has_difference type;
0063         BOOST_STATIC_CONSTANT(bool, value = true);
0064     };  
0065 
0066     template<> 
0067     struct difference_type_of<boost::posix_time::ptime> 
0068     { 
0069         typedef boost::posix_time::time_duration type; 
0070     };  
0071 
0072     template<> 
0073     struct size_type_of<boost::posix_time::ptime> 
0074     { 
0075         typedef boost::posix_time::time_duration type; 
0076     };  
0077 
0078     // ------------------------------------------------------------------------
0079     inline boost::posix_time::ptime operator ++(boost::posix_time::ptime& x)
0080     {
0081         return x += boost::posix_time::ptime::time_duration_type::unit();
0082     }
0083 
0084     inline boost::posix_time::ptime operator --(boost::posix_time::ptime& x)
0085     {
0086         return x -= boost::posix_time::ptime::time_duration_type::unit();
0087     }
0088 
0089     // ------------------------------------------------------------------------
0090     template<> struct is_discrete<boost::posix_time::time_duration>
0091     {
0092         typedef is_discrete type;
0093         BOOST_STATIC_CONSTANT(bool, value = true);
0094     };
0095 
0096     template<> 
0097     struct has_difference<boost::posix_time::time_duration> 
0098     { 
0099         typedef has_difference type;
0100         BOOST_STATIC_CONSTANT(bool, value = true);
0101     };  
0102 
0103     template<> 
0104     struct size_type_of<boost::posix_time::time_duration> 
0105     { 
0106         typedef boost::posix_time::time_duration type; 
0107     };  
0108 
0109     inline boost::posix_time::time_duration operator ++(boost::posix_time::time_duration& x)
0110     {
0111         return x += boost::posix_time::ptime::time_duration_type::unit();
0112     }
0113 
0114     inline boost::posix_time::time_duration operator --(boost::posix_time::time_duration& x)
0115     {
0116         return x -= boost::posix_time::ptime::time_duration_type::unit();
0117     }
0118 }} // namespace icl boost
0119 
0120 #endif
0121 
0122