time.hpp 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * Copyright 2010 Vicente J. Botet Escriba
  3. * Copyright (c) Microsoft Corporation 2014
  4. * Copyright 2015, 2017 Andrey Semashev
  5. *
  6. * Distributed under the Boost Software License, Version 1.0.
  7. * See http://www.boost.org/LICENSE_1_0.txt
  8. */
  9. #ifndef BOOST_WINAPI_TIME_HPP_INCLUDED_
  10. #define BOOST_WINAPI_TIME_HPP_INCLUDED_
  11. #include <boost/winapi/basic_types.hpp>
  12. #include <boost/winapi/detail/header.hpp>
  13. #ifdef BOOST_HAS_PRAGMA_ONCE
  14. #pragma once
  15. #endif
  16. #if !defined( BOOST_USE_WINDOWS_H )
  17. extern "C" {
  18. struct _FILETIME;
  19. struct _SYSTEMTIME;
  20. BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::VOID_ BOOST_WINAPI_WINAPI_CC
  21. GetSystemTime(::_SYSTEMTIME* lpSystemTime);
  22. #ifdef BOOST_HAS_GETSYSTEMTIMEASFILETIME // Windows CE does not define GetSystemTimeAsFileTime
  23. BOOST_WINAPI_IMPORT boost::winapi::VOID_ BOOST_WINAPI_WINAPI_CC
  24. GetSystemTimeAsFileTime(::_FILETIME* lpSystemTimeAsFileTime);
  25. #endif
  26. BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
  27. SystemTimeToFileTime(
  28. const ::_SYSTEMTIME* lpSystemTime,
  29. ::_FILETIME* lpFileTime);
  30. BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
  31. FileTimeToSystemTime(
  32. const ::_FILETIME* lpFileTime,
  33. ::_SYSTEMTIME* lpSystemTime);
  34. #if BOOST_WINAPI_PARTITION_APP_SYSTEM
  35. BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
  36. FileTimeToLocalFileTime(
  37. const ::_FILETIME* lpFileTime,
  38. ::_FILETIME* lpLocalFileTime);
  39. BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
  40. LocalFileTimeToFileTime(
  41. const ::_FILETIME* lpLocalFileTime,
  42. ::_FILETIME* lpFileTime);
  43. #endif // BOOST_WINAPI_PARTITION_APP_SYSTEM
  44. #if BOOST_WINAPI_PARTITION_DESKTOP_SYSTEM
  45. BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::DWORD_ BOOST_WINAPI_WINAPI_CC
  46. GetTickCount(BOOST_WINAPI_DETAIL_VOID);
  47. #endif // BOOST_WINAPI_PARTITION_DESKTOP_SYSTEM
  48. #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
  49. BOOST_WINAPI_IMPORT boost::winapi::ULONGLONG_ BOOST_WINAPI_WINAPI_CC
  50. GetTickCount64(BOOST_WINAPI_DETAIL_VOID);
  51. #endif
  52. } // extern "C"
  53. #endif // !defined( BOOST_USE_WINDOWS_H )
  54. namespace boost {
  55. namespace winapi {
  56. typedef struct BOOST_MAY_ALIAS _FILETIME {
  57. DWORD_ dwLowDateTime;
  58. DWORD_ dwHighDateTime;
  59. } FILETIME_, *PFILETIME_, *LPFILETIME_;
  60. typedef struct BOOST_MAY_ALIAS _SYSTEMTIME {
  61. WORD_ wYear;
  62. WORD_ wMonth;
  63. WORD_ wDayOfWeek;
  64. WORD_ wDay;
  65. WORD_ wHour;
  66. WORD_ wMinute;
  67. WORD_ wSecond;
  68. WORD_ wMilliseconds;
  69. } SYSTEMTIME_, *PSYSTEMTIME_, *LPSYSTEMTIME_;
  70. #if BOOST_WINAPI_PARTITION_DESKTOP_SYSTEM
  71. using ::GetTickCount;
  72. #endif
  73. #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
  74. using ::GetTickCount64;
  75. #endif
  76. BOOST_FORCEINLINE VOID_ GetSystemTime(LPSYSTEMTIME_ lpSystemTime)
  77. {
  78. ::GetSystemTime(reinterpret_cast< ::_SYSTEMTIME* >(lpSystemTime));
  79. }
  80. BOOST_FORCEINLINE BOOL_ SystemTimeToFileTime(const SYSTEMTIME_* lpSystemTime, FILETIME_* lpFileTime)
  81. {
  82. return ::SystemTimeToFileTime(reinterpret_cast< const ::_SYSTEMTIME* >(lpSystemTime), reinterpret_cast< ::_FILETIME* >(lpFileTime));
  83. }
  84. BOOST_FORCEINLINE BOOL_ FileTimeToSystemTime(const FILETIME_* lpFileTime, SYSTEMTIME_* lpSystemTime)
  85. {
  86. return ::FileTimeToSystemTime(reinterpret_cast< const ::_FILETIME* >(lpFileTime), reinterpret_cast< ::_SYSTEMTIME* >(lpSystemTime));
  87. }
  88. #if BOOST_WINAPI_PARTITION_APP_SYSTEM
  89. BOOST_FORCEINLINE BOOL_ FileTimeToLocalFileTime(const FILETIME_* lpFileTime, FILETIME_* lpLocalFileTime)
  90. {
  91. return ::FileTimeToLocalFileTime(reinterpret_cast< const ::_FILETIME* >(lpFileTime), reinterpret_cast< ::_FILETIME* >(lpLocalFileTime));
  92. }
  93. BOOST_FORCEINLINE BOOL_ LocalFileTimeToFileTime(const FILETIME_* lpLocalFileTime, FILETIME_* lpFileTime)
  94. {
  95. return ::LocalFileTimeToFileTime(reinterpret_cast< const ::_FILETIME* >(lpLocalFileTime), reinterpret_cast< ::_FILETIME* >(lpFileTime));
  96. }
  97. #endif // BOOST_WINAPI_PARTITION_APP_SYSTEM
  98. #if defined( BOOST_HAS_GETSYSTEMTIMEASFILETIME )
  99. BOOST_FORCEINLINE VOID_ GetSystemTimeAsFileTime(LPFILETIME_ lpSystemTimeAsFileTime)
  100. {
  101. ::GetSystemTimeAsFileTime(reinterpret_cast< ::_FILETIME* >(lpSystemTimeAsFileTime));
  102. }
  103. #else
  104. // Windows CE does not define GetSystemTimeAsFileTime
  105. BOOST_FORCEINLINE VOID_ GetSystemTimeAsFileTime(FILETIME_* lpFileTime)
  106. {
  107. boost::winapi::SYSTEMTIME_ st;
  108. boost::winapi::GetSystemTime(&st);
  109. boost::winapi::SystemTimeToFileTime(&st, lpFileTime);
  110. }
  111. #endif
  112. }
  113. }
  114. #include <boost/winapi/detail/footer.hpp>
  115. #endif // BOOST_WINAPI_TIME_HPP_INCLUDED_