Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/boost/date_time/c_time.hpp @ 30

Last change on this file since 30 was 29, checked in by landauf, 17 years ago

updated boost from 1_33_1 to 1_34_1

File size: 2.9 KB
Line 
1#ifndef DATE_TIME_C_TIME_HPP___
2#define DATE_TIME_C_TIME_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 or http://www.boost.org/LICENSE-1.0)
8 * Author: Jeff Garland, Bart Garst
9 * $Date: 2005/10/25 02:42:43 $
10 */
11
12
13/*! @file c_time.hpp
14  Provide workarounds related to the ctime header
15*/
16
17#include "boost/date_time/compiler_config.hpp"
18#include <ctime>
19//Work around libraries that don't put time_t and time in namespace std
20
21#ifdef BOOST_NO_STDC_NAMESPACE
22namespace std { using ::time_t; using ::time; using ::localtime;
23                using ::tm;  using ::gmtime; }
24#endif // BOOST_NO_STDC_NAMESPACE
25
26//The following is used to support high precision time clocks
27#ifdef BOOST_HAS_GETTIMEOFDAY
28#include <sys/time.h>
29#endif
30
31#ifdef BOOST_HAS_FTIME
32#include <time.h>
33#endif
34
35namespace boost {
36namespace date_time {
37  //! Provides a uniform interface to some 'ctime' functions
38  /*! Provides a uniform interface to some ctime functions and
39   * their '_r' counterparts. The '_r' functions require a pointer to a
40   * user created std::tm struct whereas the regular functions use a
41   * staticly created struct and return a pointer to that. These wrapper
42   * functions require the user to create a std::tm struct and send in a
43   * pointer to it. A pointer to the user created struct will be returned. */
44  struct c_time {
45    public:
46#if defined(BOOST_DATE_TIME_HAS_REENTRANT_STD_FUNCTIONS)
47      //! requires a pointer to a user created std::tm struct
48      inline
49      static std::tm* localtime(const std::time_t* t, std::tm* result)
50      {
51        // localtime_r() not in namespace std???
52        result = localtime_r(t, result);
53        return result;
54      }
55      //! requires a pointer to a user created std::tm struct
56      inline
57      static std::tm* gmtime(const std::time_t* t, std::tm* result)
58      {
59        // gmtime_r() not in namespace std???
60        result = gmtime_r(t, result);
61        return result;
62      }
63#else // BOOST_HAS_THREADS
64
65#if (defined(_MSC_VER) && (_MSC_VER >= 1400))
66#pragma warning(push) // preserve warning settings
67#pragma warning(disable : 4996) // disable depricated localtime/gmtime warning on vc8
68#endif // _MSC_VER >= 1400
69      //! requires a pointer to a user created std::tm struct
70      inline
71      static std::tm* localtime(const std::time_t* t, std::tm* result)
72      {
73        result = std::localtime(t);
74        return result;
75      }
76      //! requires a pointer to a user created std::tm struct
77      inline
78      static std::tm* gmtime(const std::time_t* t, std::tm* result)
79      {
80        result = std::gmtime(t);
81        return result;
82      }
83#if (defined(_MSC_VER) && (_MSC_VER >= 1400))
84#pragma warning(pop) // restore warnings to previous state
85#endif // _MSC_VER >= 1400
86
87#endif // BOOST_HAS_THREADS
88  };
89}} // namespaces
90               
91#endif // DATE_TIME_C_TIME_HPP___
Note: See TracBrowser for help on using the repository browser.