Main MRPT website > C++ reference for MRPT 1.5.9
xstime.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 #ifndef XSTIME_H
10 #define XSTIME_H
11 
12 #include "xstypesconfig.h"
13 #ifdef _WIN32
14 #include <windows.h>
15 #endif
16 
17 #include <time.h>
18 #include "pstdint.h"
19 #include "xstimestamp.h"
20 
21 #ifdef __cplusplus
22 #include "xsstring.h"
23 extern "C" {
24 #endif
25 
29 
30 XSTYPES_DLL_API uint32_t XsTime_getTimeOfDay(struct tm* date_, time_t* secs_);
32 XSTYPES_DLL_API void XsTime_getDateAsString(char* dest, struct tm const* date);
33 XSTYPES_DLL_API void XsTime_getTimeAsString(char* dest, struct tm const* time);
34 XSTYPES_DLL_API void XsTime_getDateAsWString(wchar_t* dest, struct tm const* date);
35 XSTYPES_DLL_API void XsTime_getTimeAsWString(wchar_t* dest, struct tm const* time);
40 
41 #ifdef __cplusplus
42 } // extern "C"
43 
44 namespace XsTime {
45  /*! \brief The number of seconds in a day */
46  static const XsTimeStamp& secPerDay = XsTime_secPerDay;
47  /*! \brief The number of milliseconds in a day */
48  static const XsTimeStamp& milliSecPerDay = XsTime_milliSecPerDay;
49  /*! \brief The maximum possible timestamp */
50  static const XsTimeStamp& timeStampMax = XsTime_timeStampMax;
51 
52  //! \copydoc XsTime_getTimeOfDay
53  inline uint32_t getTimeOfDay(tm* date_ = NULL, time_t* secs_ = NULL)
54  {
55  return XsTime_getTimeOfDay(date_ , secs_);
56  }
57 
58  //! \copydoc XsTime_getDateTime
59  inline int64_t getDateTime(tm * date = 0)
60  {
61  return XsTime_getDateTime(date);
62  }
63 
64  //! \copydoc XsTime_getDateAsString
65  inline void getDateAsString(char* dest, tm const* date = 0)
66  {
67  XsTime_getDateAsString(dest, date);
68  }
69 
70  //! \copydoc XsTime_getTimeAsString
71  inline void getTimeAsString(char* dest, tm const* date = 0)
72  {
73  XsTime_getTimeAsString(dest, date);
74  }
75 
76  /*! \brief Returns the date as a readable string
77  \param date to convert to string
78  \returns The date as a readable string
79  \sa XsTime_getDateAsWString
80  */
81  inline XsString getDateAsString(tm const* date = 0)
82  {
83  wchar_t wcharBuf[9];
84  XsTime_getDateAsWString(wcharBuf, date);
85  wcharBuf[8] = 0;
86  return XsString(wcharBuf);
87  }
88 
89  /*! \brief Returns the time as a readable string
90  \param time to convert to string
91  \returns The time as a readable string
92  \sa XsTime_getTimeAsWString
93  */
94  inline XsString getTimeAsString(tm const* time = 0)
95  {
96  wchar_t wcharBuf[9];
97  XsTime_getTimeAsWString(wcharBuf, time);
98  wcharBuf[8] = 0;
99  return XsString(wcharBuf);
100  }
101 
102  //! \copydoc XsTime_msleep
103  inline void msleep(uint32_t ms)
104  {
105  XsTime_msleep(ms);
106  }
107 
108  //! \copydoc XsTime_udelay
109  inline void udelay(uint32_t us)
110  {
111  XsTime_udelay(us);
112  }
113 
114  //! \copydoc XsTime_initializeTime
115  inline void initializeTime()
116  {
118  }
119 
120  //! \copydoc XsTime_timeStampNow
121  inline int64_t timeStampNow(XsTimeStamp* now = 0)
122  {
123  return XsTime_timeStampNow(now);
124  }
125 }
126 #endif
127 
128 #endif // file guard
XSTYPES_DLL_API const XsTimeStamp XsTime_milliSecPerDay
XSTYPES_DLL_API void XsTime_msleep(uint32_t ms)
mrpt::system::TTimeStamp now()
A shortcut for system::getCurrentTime.
Definition: datetime.h:70
TimeStamp timeStampNow(void)
Definition: xsens_time.cpp:97
XSTYPES_DLL_API uint32_t XsTime_getTimeOfDay(struct tm *date_, time_t *secs_)
uint32_t getTimeOfDay(tm *date_, time_t *secs_)
A platform-independent clock.
Definition: xsens_time.cpp:29
XSTYPES_DLL_API void XsTime_udelay(uint32_t us)
XSTYPES_DLL_API void XsTime_getTimeAsString(char *dest, struct tm const *time)
void msleep(uint32_t ms)
A platform-independent sleep routine.
Definition: xsens_time.cpp:78
__int64 int64_t
Definition: rptypes.h:51
XSTYPES_DLL_API void XsTime_getTimeAsWString(wchar_t *dest, struct tm const *time)
Class for managing timestamps in a unified way.
Definition: xstimestamp.h:43
XSTYPES_DLL_API void XsTime_initializeTime(void)
XSTYPES_DLL_API void XsTime_getDateAsString(char *dest, struct tm const *date)
#define XSTYPES_DLL_API
Definition: xstypesconfig.h:9
XSTYPES_DLL_API int64_t XsTime_getDateTime(struct tm *date)
XSTYPES_DLL_API const XsTimeStamp XsTime_timeStampMax
XSTYPES_DLL_API const XsTimeStamp XsTime_secPerDay
XSTYPES_DLL_API int64_t XsTime_timeStampNow(XsTimeStamp *now)
struct XsString XsString
Definition: xsstring.h:34
unsigned __int32 uint32_t
Definition: rptypes.h:49
XSTYPES_DLL_API void XsTime_getDateAsWString(wchar_t *dest, struct tm const *date)



Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020