Debian Codegraph @

chrono/timespan.h

raw symbols SCIP
1 #cxx . . $ `<file>/chrono/timespan.h`/ifndef CHRONO_UTILITIES_TIMESPAN_H
2 #define CHRONO_UTILITIES_TIMESPAN_Hcxx . . $ `chrono/timespan.h:2:9`!
3
4 #include "../global.h"cxx . . $ `<file>/global.h`/
5
6 #include <cstdint>
7 #include <functional>
8 #include <limits>
9 #include <string>
10
11 namespace CppUtilitiescxx . . $ CppUtilities/ {
12
13 class DateTimecxx . . $ CppUtilities/DateTime#;
14
15 /*!
16 * \brief Specifies the output format.
17 * \sa TimeSpan::toString()
18 */
19 enum class TimeSpanOutputFormatcxx . . $ CppUtilities/TimeSpanOutputFormat# {
20 Normalcxx . . $ CppUtilities/TimeSpanOutputFormat#Normal., /**< the normal form of specifying a time interval: hh:mm:ss */
21 WithMeasurescxx . . $ CppUtilities/TimeSpanOutputFormat#WithMeasures., /**< measures are used, eg.: 34 d 5 h 10 min 7 s 31 ms */
22 TotalSecondscxx . . $ CppUtilities/TimeSpanOutputFormat#TotalSeconds., /**< total seconds (as returned by totalSeconds()), eg. 2304.342 */
23 };
24
25 class CPP_UTILITIES_EXPORTcxx . . $ `global.h:11:9`! TimeSpancxx . . $ CppUtilities/TimeSpan# {
26 friend class DateTimecxx . . $ CppUtilities/DateTime#;
27
28 public:
29 using TickTypecxx . . $ CppUtilities/TimeSpan#TickType# = stdcxx . . $ std/::int64_tcxx . . $ std/int64_t#;
30
31 explicit constexpr TimeSpancxx . . $ CppUtilities/TimeSpan#TimeSpan(49f6e7a06ebc5aa8).();
32 explicit constexpr TimeSpancxx . . $ CppUtilities/TimeSpan#TimeSpan(1624ee8275b10bda).(TickTypecxx . . $ CppUtilities/TimeSpan#TickType# ticks);
33
34 static constexpr TimeSpancxx . . $ CppUtilities/TimeSpan# fromMillisecondscxx . . $ CppUtilities/TimeSpan#fromMilliseconds(1a0c28e1b314a5ba).(double milliseconds);
35 static constexpr TimeSpancxx . . $ CppUtilities/TimeSpan# fromSecondscxx . . $ CppUtilities/TimeSpan#fromSeconds(1a0c28e1b314a5ba).(double seconds);
36 static constexpr TimeSpancxx . . $ CppUtilities/TimeSpan# fromMinutescxx . . $ CppUtilities/TimeSpan#fromMinutes(1a0c28e1b314a5ba).(double minutes);
37 static constexpr TimeSpancxx . . $ CppUtilities/TimeSpan# fromHourscxx . . $ CppUtilities/TimeSpan#fromHours(1a0c28e1b314a5ba).(double hours);
38 static constexpr TimeSpancxx . . $ CppUtilities/TimeSpan# fromDayscxx . . $ CppUtilities/TimeSpan#fromDays(1a0c28e1b314a5ba).(double days);
39 #ifdef CHRONO_UTILITIES_TIMESPAN_INTEGER_SCALE_OVERLOADS
40 static constexpr TimeSpan fromMilliseconds(TickType milliseconds);
41 static constexpr TimeSpan fromSeconds(TickType seconds);
42 static constexpr TimeSpan fromMinutes(TickType minutes);
43 static constexpr TimeSpan fromHours(TickType hours);
44 static constexpr TimeSpan fromDays(TickType days);
45 #endif
46 static TimeSpancxx . . $ CppUtilities/TimeSpan# fromStringcxx . . $ CppUtilities/TimeSpan#fromString(31d415b812f12da7).(const stdcxx . . $ std/::stringcxx . . $ std/string# &str, char separator = ':');
47 static TimeSpancxx . . $ CppUtilities/TimeSpan# fromStringcxx . . $ CppUtilities/TimeSpan#fromString(9eca79b0e5ad183a).(const char *str, char separator);
48 static constexpr TimeSpancxx . . $ CppUtilities/TimeSpan# negativeInfinitycxx . . $ CppUtilities/TimeSpan#negativeInfinity(837c3fb75701f984).();
49 static constexpr TimeSpancxx . . $ CppUtilities/TimeSpan# infinitycxx . . $ CppUtilities/TimeSpan#infinity(837c3fb75701f984).();
50
51 TickTypecxx . . $ CppUtilities/TimeSpan#TickType# &tickscxx . . $ CppUtilities/TimeSpan#ticks(5a30cdb1e5ba0b78).();
52 constexpr TickTypecxx . . $ CppUtilities/TimeSpan#TickType# totalTickscxx . . $ CppUtilities/TimeSpan#totalTicks(57a65ae535d7db84).() const;
53 constexpr double totalMicrosecondscxx . . $ CppUtilities/TimeSpan#totalMicroseconds(21b6c25e127938e2).() const;
54 constexpr double totalMillisecondscxx . . $ CppUtilities/TimeSpan#totalMilliseconds(21b6c25e127938e2).() const;
55 constexpr double totalSecondscxx . . $ CppUtilities/TimeSpan#totalSeconds(21b6c25e127938e2).() const;
56 constexpr double totalMinutescxx . . $ CppUtilities/TimeSpan#totalMinutes(21b6c25e127938e2).() const;
57 constexpr double totalHourscxx . . $ CppUtilities/TimeSpan#totalHours(21b6c25e127938e2).() const;
58 constexpr double totalDayscxx . . $ CppUtilities/TimeSpan#totalDays(21b6c25e127938e2).() const;
59
60 constexpr int nanosecondscxx . . $ CppUtilities/TimeSpan#nanoseconds(455f465bc33b4cdf).() const;
61 constexpr int microsecondscxx . . $ CppUtilities/TimeSpan#microseconds(455f465bc33b4cdf).() const;
62 constexpr int millisecondscxx . . $ CppUtilities/TimeSpan#milliseconds(455f465bc33b4cdf).() const;
63 constexpr int secondscxx . . $ CppUtilities/TimeSpan#seconds(455f465bc33b4cdf).() const;
64 constexpr int minutescxx . . $ CppUtilities/TimeSpan#minutes(455f465bc33b4cdf).() const;
65 constexpr int hourscxx . . $ CppUtilities/TimeSpan#hours(455f465bc33b4cdf).() const;
66 constexpr int dayscxx . . $ CppUtilities/TimeSpan#days(455f465bc33b4cdf).() const;
67
68 constexpr bool operatorcxx . . $ CppUtilities/TimeSpan#`operator==`(c3dceef1c3b34f85).==(const TimeSpancxx . . $ CppUtilities/TimeSpan# &other) const;
69 constexpr bool operatorcxx . . $ CppUtilities/TimeSpan#`operator!=`(c3dceef1c3b34f85).!=(const TimeSpancxx . . $ CppUtilities/TimeSpan# &other) const;
70 constexpr bool operatorcxx . . $ CppUtilities/TimeSpan#`operator<`(c3dceef1c3b34f85).<(const TimeSpancxx . . $ CppUtilities/TimeSpan# &other) const;
71 constexpr bool operatorcxx . . $ CppUtilities/TimeSpan#`operator>`(c3dceef1c3b34f85).>(const TimeSpancxx . . $ CppUtilities/TimeSpan# &other) const;
72 constexpr bool operatorcxx . . $ CppUtilities/TimeSpan#`operator<=`(c3dceef1c3b34f85).<=(const TimeSpancxx . . $ CppUtilities/TimeSpan# &other) const;
73 constexpr bool operatorcxx . . $ CppUtilities/TimeSpan#`operator>=`(c3dceef1c3b34f85).>=(const TimeSpancxx . . $ CppUtilities/TimeSpan# &other) const;
74 constexpr TimeSpancxx . . $ CppUtilities/TimeSpan# operatorcxx . . $ CppUtilities/TimeSpan#operator+(e5ca4f88e5212dc0).+(const TimeSpancxx . . $ CppUtilities/TimeSpan# &other) const;
75 constexpr TimeSpancxx . . $ CppUtilities/TimeSpan# operatorcxx . . $ CppUtilities/TimeSpan#operator-(e5ca4f88e5212dc0).-(const TimeSpancxx . . $ CppUtilities/TimeSpan# &other) const;
76 constexpr TimeSpancxx . . $ CppUtilities/TimeSpan# operatorcxx . . $ CppUtilities/TimeSpan#`operator*`(3896298fc9fd2c67).*(double factor) const;
77 constexpr TimeSpancxx . . $ CppUtilities/TimeSpan# operatorcxx . . $ CppUtilities/TimeSpan#`operator/`(3896298fc9fd2c67)./(double factor) const;
78 #ifdef CHRONO_UTILITIES_TIMESPAN_INTEGER_SCALE_OVERLOADS
79 constexpr TimeSpan operator*(TickType factor) const;
80 constexpr TimeSpan operator/(TickType factor) const;
81 #endif
82 constexpr double operatorcxx . . $ CppUtilities/TimeSpan#`operator/`(bd46e7452c76d90a)./(TimeSpancxx . . $ CppUtilities/TimeSpan# other) const;
83 TimeSpancxx . . $ CppUtilities/TimeSpan# &operatorcxx . . $ CppUtilities/TimeSpan#`operator+=`(ef23eeb8e62ed3de).+=(const TimeSpancxx . . $ CppUtilities/TimeSpan# &other);
84 TimeSpancxx . . $ CppUtilities/TimeSpan# &operatorcxx . . $ CppUtilities/TimeSpan#`operator-=`(ef23eeb8e62ed3de).-=(const TimeSpancxx . . $ CppUtilities/TimeSpan# &other);
85 TimeSpancxx . . $ CppUtilities/TimeSpan# &operatorcxx . . $ CppUtilities/TimeSpan#`operator*=`(6048b2c3dbfa6865).*=(double factor);
86 TimeSpancxx . . $ CppUtilities/TimeSpan# &operatorcxx . . $ CppUtilities/TimeSpan#`operator/=`(6048b2c3dbfa6865)./=(double factor);
87 #ifdef CHRONO_UTILITIES_TIMESPAN_INTEGER_SCALE_OVERLOADS
88 TimeSpan &operator*=(TickType factor);
89 TimeSpan &operator/=(TickType factor);
90 #endif
91
92 stdcxx . . $ std/::stringcxx . . $ std/string# toStringcxx . . $ CppUtilities/TimeSpan#toString(371643e8aee3bcbd).(TimeSpanOutputFormatcxx . . $ CppUtilities/TimeSpanOutputFormat# format = TimeSpanOutputFormatcxx . . $ CppUtilities/TimeSpanOutputFormat#::Normalcxx . . $ CppUtilities/TimeSpanOutputFormat#Normal., bool fullSeconds = false) const;
93 void toStringcxx . . $ CppUtilities/TimeSpan#toString(72d541dfcf10d9ed).(stdcxx . . $ std/::stringcxx . . $ std/string# &result, TimeSpanOutputFormatcxx . . $ CppUtilities/TimeSpanOutputFormat# format = TimeSpanOutputFormatcxx . . $ CppUtilities/TimeSpanOutputFormat#::Normalcxx . . $ CppUtilities/TimeSpanOutputFormat#Normal., bool fullSeconds = false) const;
94 constexpr bool isNullcxx . . $ CppUtilities/TimeSpan#isNull(50ce9a9e25b4a850).() const;
95 constexpr bool isNegativecxx . . $ CppUtilities/TimeSpan#isNegative(50ce9a9e25b4a850).() const;
96 constexpr bool isNegativeInfinitycxx . . $ CppUtilities/TimeSpan#isNegativeInfinity(50ce9a9e25b4a850).() const;
97 constexpr bool isInfinitycxx . . $ CppUtilities/TimeSpan#isInfinity(50ce9a9e25b4a850).() const;
98
99 static constexpr TickTypecxx . . $ CppUtilities/TimeSpan#TickType# nanosecondsPerTickcxx . . $ CppUtilities/TimeSpan#nanosecondsPerTick. = 100L;
100 static constexpr TickTypecxx . . $ CppUtilities/TimeSpan#TickType# ticksPerMicrosecondcxx . . $ CppUtilities/TimeSpan#ticksPerMicrosecond. = 10L;
101 static constexpr TickTypecxx . . $ CppUtilities/TimeSpan#TickType# ticksPerMillisecondcxx . . $ CppUtilities/TimeSpan#ticksPerMillisecond. = 10000L;
102 static constexpr TickTypecxx . . $ CppUtilities/TimeSpan#TickType# ticksPerSecondcxx . . $ CppUtilities/TimeSpan#ticksPerSecond. = 10000000L;
103 static constexpr TickTypecxx . . $ CppUtilities/TimeSpan#TickType# ticksPerMinutecxx . . $ CppUtilities/TimeSpan#ticksPerMinute. = 600000000L;
104 static constexpr TickTypecxx . . $ CppUtilities/TimeSpan#TickType# ticksPerHourcxx . . $ CppUtilities/TimeSpan#ticksPerHour. = 36000000000L;
105 static constexpr TickTypecxx . . $ CppUtilities/TimeSpan#TickType# ticksPerDaycxx . . $ CppUtilities/TimeSpan#ticksPerDay. = 864000000000L;
106
107 private:
108 TickTypecxx . . $ CppUtilities/TimeSpan#TickType# m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks.;
109 };
110
111 /*!
112 * \brief Constructs a new instance of the TimeSpan class with zero ticks.
113 */
114 constexpr inline TimeSpancxx . . $ CppUtilities/TimeSpan#::TimeSpancxx . . $ CppUtilities/TimeSpan#TimeSpan(49f6e7a06ebc5aa8).()
115 : m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks.(0)
116 {
117 }
118
119 /*!
120 * \brief Constructs a new instance of the TimeSpan class with the specified number of ticks.
121 */
122 constexpr inline TimeSpancxx . . $ CppUtilities/TimeSpan#::TimeSpancxx . . $ CppUtilities/TimeSpan#TimeSpan(1624ee8275b10bda).(TickTypecxx . . $ CppUtilities/TimeSpan#TickType# ticks)
123 : m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks.(ticks)
124 {
125 }
126
127 /*!
128 * \brief Constructs a new instance of the TimeSpan class with the specified number of milliseconds.
129 */
130 constexpr inline TimeSpancxx . . $ CppUtilities/TimeSpan# TimeSpancxx . . $ CppUtilities/TimeSpan#::fromMillisecondscxx . . $ CppUtilities/TimeSpan#fromMilliseconds(1a0c28e1b314a5ba).(double milliseconds)
131 {
132 return TimeSpancxx . . $ CppUtilities/TimeSpan#(static_cast<TickTypecxx . . $ CppUtilities/TimeSpan#TickType#>(milliseconds * static_cast<double>(ticksPerMillisecondcxx . . $ CppUtilities/TimeSpan#ticksPerMillisecond.)));
133 }
134
135 /*!
136 * \brief Constructs a new instance of the TimeSpan class with the specified number of seconds.
137 */
138 constexpr inline TimeSpancxx . . $ CppUtilities/TimeSpan# TimeSpancxx . . $ CppUtilities/TimeSpan#::fromSecondscxx . . $ CppUtilities/TimeSpan#fromSeconds(1a0c28e1b314a5ba).(double seconds)
139 {
140 return TimeSpancxx . . $ CppUtilities/TimeSpan#TimeSpan(1624ee8275b10bda).(static_cast<TickTypecxx . . $ CppUtilities/TimeSpan#TickType#>(seconds * static_cast<double>(ticksPerSecondcxx . . $ CppUtilities/TimeSpan#ticksPerSecond.)));
141 }
142
143 /*!
144 * \brief Constructs a new instance of the TimeSpan class with the specified number of minutes.
145 */
146 constexpr inline TimeSpancxx . . $ CppUtilities/TimeSpan# TimeSpancxx . . $ CppUtilities/TimeSpan#::fromMinutescxx . . $ CppUtilities/TimeSpan#fromMinutes(1a0c28e1b314a5ba).(double minutes)
147 {
148 return TimeSpancxx . . $ CppUtilities/TimeSpan#(static_cast<TickTypecxx . . $ CppUtilities/TimeSpan#TickType#>(minutes * static_cast<double>(ticksPerMinutecxx . . $ CppUtilities/TimeSpan#ticksPerMinute.)));
149 }
150
151 /*!
152 * \brief Constructs a new instance of the TimeSpan class with the specified number of hours.
153 */
154 constexpr inline TimeSpancxx . . $ CppUtilities/TimeSpan# TimeSpancxx . . $ CppUtilities/TimeSpan#::fromHourscxx . . $ CppUtilities/TimeSpan#fromHours(1a0c28e1b314a5ba).(double hours)
155 {
156 return TimeSpancxx . . $ CppUtilities/TimeSpan#(static_cast<TickTypecxx . . $ CppUtilities/TimeSpan#TickType#>(hours * static_cast<double>(ticksPerHourcxx . . $ CppUtilities/TimeSpan#ticksPerHour.)));
157 }
158
159 /*!
160 * \brief Constructs a new instance of the TimeSpan class with the specified number of days.
161 */
162 constexpr inline TimeSpancxx . . $ CppUtilities/TimeSpan# TimeSpancxx . . $ CppUtilities/TimeSpan#::fromDayscxx . . $ CppUtilities/TimeSpan#fromDays(1a0c28e1b314a5ba).(double days)
163 {
164 return TimeSpancxx . . $ CppUtilities/TimeSpan#TimeSpan(1624ee8275b10bda).(static_cast<TickTypecxx . . $ CppUtilities/TimeSpan#TickType#>(days * static_cast<double>(ticksPerDaycxx . . $ CppUtilities/TimeSpan#ticksPerDay.)));
165 }
166
167 #ifdef CHRONO_UTILITIES_TIMESPAN_INTEGER_SCALE_OVERLOADS
168 /*!
169 * \brief Constructs a new instance of the TimeSpan class with the specified number of milliseconds.
170 */
171 constexpr inline TimeSpan TimeSpan::fromMilliseconds(TickType milliseconds)
172 {
173 return TimeSpan(milliseconds * ticksPerMillisecond);
174 }
175
176 /*!
177 * \brief Constructs a new instance of the TimeSpan class with the specified number of seconds.
178 */
179 constexpr inline TimeSpan TimeSpan::fromSeconds(TickType seconds)
180 {
181 return TimeSpan(seconds * ticksPerSecond);
182 }
183
184 /*!
185 * \brief Constructs a new instance of the TimeSpan class with the specified number of minutes.
186 */
187 constexpr inline TimeSpan TimeSpan::fromMinutes(TickType minutes)
188 {
189 return TimeSpan(minutes * ticksPerMinute);
190 }
191
192 /*!
193 * \brief Constructs a new instance of the TimeSpan class with the specified number of hours.
194 */
195 constexpr inline TimeSpan TimeSpan::fromHours(TickType hours)
196 {
197 return TimeSpan(hours * ticksPerHour);
198 }
199
200 /*!
201 * \brief Constructs a new instance of the TimeSpan class with the specified number of days.
202 */
203 constexpr inline TimeSpan TimeSpan::fromDays(TickType days)
204 {
205 return TimeSpan(days * ticksPerDay);
206 }
207 #endif
208
209 /*!
210 * \brief Parses the given std::string as TimeSpan.
211 * \throws Throws a ConversionException if the specified \a str does not match the expected format.
212 *
213 * The expected format is "days:hours:minutes:seconds", eg. "5:31:4.521" for 5 hours, 31 minutes
214 * and 4.521 seconds. So parts at the front can be omitted and the parts can be fractions. The
215 * colon can be changed by specifying another \a separator.
216 */
217 inline TimeSpancxx . . $ CppUtilities/TimeSpan# TimeSpancxx . . $ CppUtilities/TimeSpan#::fromStringcxx . . $ CppUtilities/TimeSpan#fromString(31d415b812f12da7).(const stdcxx . . $ std/::stringcxx . . $ std/string# &str, char separator)
218 {
219 return TimeSpancxx . . $ CppUtilities/TimeSpan#::fromStringcxx . . $ CppUtilities/TimeSpan#fromString(9eca79b0e5ad183a).(str.datacxx . . $ std/__cxx11/basic_string#data(8e614c7de0b1573e).(), separator);
220 }
221
222 /*!
223 * \brief Constructs a new instance of the TimeSpan class with the minimal number of ticks.
224 */
225 constexpr inline TimeSpancxx . . $ CppUtilities/TimeSpan# TimeSpancxx . . $ CppUtilities/TimeSpan#::negativeInfinitycxx . . $ CppUtilities/TimeSpan#negativeInfinity(837c3fb75701f984).()
226 {
227 return TimeSpancxx . . $ CppUtilities/TimeSpan#(stdcxx . . $ std/::numeric_limitscxx . . $ std/numeric_limits#<TickType>::mincxx . . $ std/numeric_limits#min(5a25411868dabf75).());
228 }
229
230 /*!
231 * \brief Constructs a new instance of the TimeSpan class with the maximal number of ticks.
232 */
233 constexpr inline TimeSpancxx . . $ CppUtilities/TimeSpan# TimeSpancxx . . $ CppUtilities/TimeSpan#::infinitycxx . . $ CppUtilities/TimeSpan#infinity(837c3fb75701f984).()
234 {
235 return TimeSpancxx . . $ CppUtilities/TimeSpan#(stdcxx . . $ std/::numeric_limitscxx . . $ std/numeric_limits#<TickType>::maxcxx . . $ std/numeric_limits#max(5a25411868dabf75).());
236 }
237
238 /*!
239 * \brief Returns a mutable reference to the total ticks.
240 */
241 inline TimeSpancxx . . $ CppUtilities/TimeSpan#::TickTypecxx . . $ CppUtilities/TimeSpan#TickType# &TimeSpancxx . . $ CppUtilities/TimeSpan#::tickscxx . . $ CppUtilities/TimeSpan#ticks(5a30cdb1e5ba0b78).()
242 {
243 return m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks.;
244 }
245
246 /*!
247 * \brief Returns the number of ticks that represent the value of the current TimeSpan class.
248 */
249 constexpr inline TimeSpancxx . . $ CppUtilities/TimeSpan#::TickTypecxx . . $ CppUtilities/TimeSpan#TickType# TimeSpancxx . . $ CppUtilities/TimeSpan#::totalTickscxx . . $ CppUtilities/TimeSpan#totalTicks(57a65ae535d7db84).() const
250 {
251 return m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks.;
252 }
253
254 /*!
255 * \brief Returns the value of the current TimeSpan class expressed in whole and fractional microseconds.
256 */
257 constexpr double TimeSpancxx . . $ CppUtilities/TimeSpan#::totalMicrosecondscxx . . $ CppUtilities/TimeSpan#totalMicroseconds(21b6c25e127938e2).() const
258 {
259 return static_cast<double>(m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks.) / static_cast<double>(ticksPerMicrosecondcxx . . $ CppUtilities/TimeSpan#ticksPerMicrosecond.);
260 }
261
262 /*!
263 * \brief Returns the value of the current TimeSpan class expressed in whole and fractional milliseconds.
264 */
265 constexpr inline double TimeSpancxx . . $ CppUtilities/TimeSpan#::totalMillisecondscxx . . $ CppUtilities/TimeSpan#totalMilliseconds(21b6c25e127938e2).() const
266 {
267 return static_cast<double>(m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks.) / static_cast<double>(ticksPerMillisecondcxx . . $ CppUtilities/TimeSpan#ticksPerMillisecond.);
268 }
269
270 /*!
271 * \brief Returns the value of the current TimeSpan class expressed in whole and fractional seconds.
272 */
273 constexpr inline double TimeSpancxx . . $ CppUtilities/TimeSpan#::totalSecondscxx . . $ CppUtilities/TimeSpan#totalSeconds(21b6c25e127938e2).() const
274 {
275 return static_cast<double>(m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks.) / static_cast<double>(ticksPerSecondcxx . . $ CppUtilities/TimeSpan#ticksPerSecond.);
276 }
277
278 /*!
279 * \brief Returns the value of the current TimeSpan class expressed in whole and fractional minutes.
280 */
281 constexpr inline double TimeSpancxx . . $ CppUtilities/TimeSpan#::totalMinutescxx . . $ CppUtilities/TimeSpan#totalMinutes(21b6c25e127938e2).() const
282 {
283 return static_cast<double>(m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks.) / static_cast<double>(ticksPerMinutecxx . . $ CppUtilities/TimeSpan#ticksPerMinute.);
284 }
285
286 /*!
287 * \brief Returns the value of the current TimeSpan class expressed in whole and fractional hours.
288 */
289 constexpr inline double TimeSpancxx . . $ CppUtilities/TimeSpan#::totalHourscxx . . $ CppUtilities/TimeSpan#totalHours(21b6c25e127938e2).() const
290 {
291 return static_cast<double>(m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks.) / static_cast<double>(ticksPerHourcxx . . $ CppUtilities/TimeSpan#ticksPerHour.);
292 }
293
294 /*!
295 * \brief Returns the value of the current TimeSpan class expressed in whole and fractional days.
296 */
297 constexpr inline double TimeSpancxx . . $ CppUtilities/TimeSpan#::totalDayscxx . . $ CppUtilities/TimeSpan#totalDays(21b6c25e127938e2).() const
298 {
299 return static_cast<double>(m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks.) / static_cast<double>(ticksPerDaycxx . . $ CppUtilities/TimeSpan#ticksPerDay.);
300 }
301
302 /*!
303 * \brief Returns the nanoseconds component of the time interval represented by the current TimeSpan class.
304 * \remarks The accuracy of the TimeSpan class is 100-nanoseconds. Hence the returned value
305 * will always have two zeros at the end (in decimal representation).
306 */
307 constexpr int TimeSpancxx . . $ CppUtilities/TimeSpan#::nanosecondscxx . . $ CppUtilities/TimeSpan#nanoseconds(455f465bc33b4cdf).() const
308 {
309 return static_cast<int>(m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks. % 10l * TimeSpancxx . . $ CppUtilities/TimeSpan#::nanosecondsPerTickcxx . . $ CppUtilities/TimeSpan#nanosecondsPerTick.);
310 }
311
312 /*!
313 * \brief Returns the microseconds component of the time interval represented by the current TimeSpan class.
314 */
315 constexpr int TimeSpancxx . . $ CppUtilities/TimeSpan#::microsecondscxx . . $ CppUtilities/TimeSpan#microseconds(455f465bc33b4cdf).() const
316 {
317 return static_cast<int>((m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks. / ticksPerMicrosecondcxx . . $ CppUtilities/TimeSpan#ticksPerMicrosecond.) % 1000l);
318 }
319
320 /*!
321 * \brief Returns the milliseconds component of the time interval represented by the current TimeSpan class.
322 */
323 constexpr inline int TimeSpancxx . . $ CppUtilities/TimeSpan#::millisecondscxx . . $ CppUtilities/TimeSpan#milliseconds(455f465bc33b4cdf).() const
324 {
325 return static_cast<int>((m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks. / ticksPerMillisecondcxx . . $ CppUtilities/TimeSpan#ticksPerMillisecond.) % 1000l);
326 }
327
328 /*!
329 * \brief Returns the seconds component of the time interval represented by the current TimeSpan class.
330 */
331 constexpr inline int TimeSpancxx . . $ CppUtilities/TimeSpan#::secondscxx . . $ CppUtilities/TimeSpan#seconds(455f465bc33b4cdf).() const
332 {
333 return static_cast<int>((m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks. / ticksPerSecondcxx . . $ CppUtilities/TimeSpan#ticksPerSecond.) % 60l);
334 }
335
336 /*!
337 * \brief Returns the minutes component of the time interval represented by the current TimeSpan class.
338 */
339 constexpr inline int TimeSpancxx . . $ CppUtilities/TimeSpan#::minutescxx . . $ CppUtilities/TimeSpan#minutes(455f465bc33b4cdf).() const
340 {
341 return static_cast<int>((m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks. / ticksPerMinutecxx . . $ CppUtilities/TimeSpan#ticksPerMinute.) % 60l);
342 }
343
344 /*!
345 * \brief Returns the hours component of the time interval represented by the current TimeSpan class.
346 */
347 constexpr inline int TimeSpancxx . . $ CppUtilities/TimeSpan#::hourscxx . . $ CppUtilities/TimeSpan#hours(455f465bc33b4cdf).() const
348 {
349 return static_cast<int>((m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks. / ticksPerHourcxx . . $ CppUtilities/TimeSpan#ticksPerHour.) % 24l);
350 }
351
352 /*!
353 * \brief Returns the days component of the time interval represented by the current TimeSpan class.
354 */
355 constexpr inline int TimeSpancxx . . $ CppUtilities/TimeSpan#::dayscxx . . $ CppUtilities/TimeSpan#days(455f465bc33b4cdf).() const
356 {
357 return static_cast<int>((m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks. / ticksPerDaycxx . . $ CppUtilities/TimeSpan#ticksPerDay.));
358 }
359
360 /*!
361 * \brief Indicates whether two TimeSpan instances are equal.
362 */
363 constexpr inline bool TimeSpancxx . . $ CppUtilities/TimeSpan#::operatorcxx . . $ CppUtilities/TimeSpan#`operator==`(c3dceef1c3b34f85).==(const TimeSpancxx . . $ CppUtilities/TimeSpan# &other) const
364 {
365 return m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks. == other.m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks.;
366 }
367
368 /*!
369 * \brief Indicates whether two TimeSpan instances are not equal.
370 */
371 constexpr inline bool TimeSpancxx . . $ CppUtilities/TimeSpan#::operatorcxx . . $ CppUtilities/TimeSpan#`operator!=`(c3dceef1c3b34f85).!=(const TimeSpancxx . . $ CppUtilities/TimeSpan# &other) const
372 {
373 return m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks. != other.m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks.;
374 }
375
376 /*!
377 * \brief Indicates whether a specified TimeSpan is less than another specified TimeSpan.
378 */
379 constexpr inline bool TimeSpancxx . . $ CppUtilities/TimeSpan#::operatorcxx . . $ CppUtilities/TimeSpan#`operator<`(c3dceef1c3b34f85).<(const TimeSpancxx . . $ CppUtilities/TimeSpan# &other) const
380 {
381 return m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks. < other.m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks.;
382 }
383
384 /*!
385 * \brief Indicates whether a specified TimeSpan is greater than another specified TimeSpan.
386 */
387 constexpr inline bool TimeSpancxx . . $ CppUtilities/TimeSpan#::operatorcxx . . $ CppUtilities/TimeSpan#`operator>`(c3dceef1c3b34f85).>(const TimeSpancxx . . $ CppUtilities/TimeSpan# &other) const
388 {
389 return m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks. > other.m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks.;
390 }
391
392 /*!
393 * \brief Indicates whether a specified TimeSpan is less or equal than another specified TimeSpan.
394 */
395 constexpr inline bool TimeSpancxx . . $ CppUtilities/TimeSpan#::operatorcxx . . $ CppUtilities/TimeSpan#`operator<=`(c3dceef1c3b34f85).<=(const TimeSpancxx . . $ CppUtilities/TimeSpan# &other) const
396 {
397 return m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks. <= other.m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks.;
398 }
399
400 /*!
401 * \brief Indicates whether a specified TimeSpan is greater or equal than another specified TimeSpan.
402 */
403 constexpr inline bool TimeSpancxx . . $ CppUtilities/TimeSpan#::operatorcxx . . $ CppUtilities/TimeSpan#`operator>=`(c3dceef1c3b34f85).>=(const TimeSpancxx . . $ CppUtilities/TimeSpan# &other) const
404 {
405 return m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks. >= other.m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks.;
406 }
407
408 /*!
409 * \brief Adds two TimeSpan instances.
410 */
411 constexpr inline TimeSpancxx . . $ CppUtilities/TimeSpan# TimeSpancxx . . $ CppUtilities/TimeSpan#::operatorcxx . . $ CppUtilities/TimeSpan#operator+(e5ca4f88e5212dc0).+(const TimeSpancxx . . $ CppUtilities/TimeSpan# &other) const
412 {
413 return TimeSpancxx . . $ CppUtilities/TimeSpan#(m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks. + other.m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks.);
414 }
415
416 /*!
417 * \brief Subtracts one TimeSpan instance from another.
418 */
419 constexpr inline TimeSpancxx . . $ CppUtilities/TimeSpan# TimeSpancxx . . $ CppUtilities/TimeSpan#::operatorcxx . . $ CppUtilities/TimeSpan#operator-(e5ca4f88e5212dc0).-(const TimeSpancxx . . $ CppUtilities/TimeSpan# &other) const
420 {
421 return TimeSpancxx . . $ CppUtilities/TimeSpan#(m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks. - other.m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks.);
422 }
423
424 /*!
425 * \brief Multiplies a TimeSpan by the specified \a factor.
426 */
427 constexpr inline TimeSpancxx . . $ CppUtilities/TimeSpan# TimeSpancxx . . $ CppUtilities/TimeSpan#::operatorcxx . . $ CppUtilities/TimeSpan#`operator*`(3896298fc9fd2c67).*(double factor) const
428 {
429 return TimeSpancxx . . $ CppUtilities/TimeSpan#(static_cast<stdcxx . . $ std/::int64_tcxx . . $ std/int64_t#>(static_cast<double>(m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks.) * factor));
430 }
431
432 /*!
433 * \brief Divides a TimeSpan by the specified \a factor.
434 */
435 constexpr inline TimeSpancxx . . $ CppUtilities/TimeSpan# TimeSpancxx . . $ CppUtilities/TimeSpan#::operatorcxx . . $ CppUtilities/TimeSpan#`operator/`(3896298fc9fd2c67)./(double factor) const
436 {
437 return TimeSpancxx . . $ CppUtilities/TimeSpan#(static_cast<stdcxx . . $ std/::int64_tcxx . . $ std/int64_t#>(static_cast<double>(m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks.) / factor));
438 }
439
440 #ifdef CHRONO_UTILITIES_TIMESPAN_INTEGER_SCALE_OVERLOADS
441 /*!
442 * \brief Multiplies a TimeSpan by the specified \a factor.
443 */
444 constexpr inline TimeSpan TimeSpan::operator*(std::int64_t factor) const
445 {
446 return TimeSpan(m_ticks * factor);
447 }
448
449 /*!
450 * \brief Divides a TimeSpan by the specified \a factor.
451 */
452 constexpr inline TimeSpan TimeSpan::operator/(std::int64_t factor) const
453 {
454 return TimeSpan(m_ticks / factor);
455 }
456 #endif
457
458 /*!
459 * \brief Computes the ratio between two TimeSpan instances.
460 */
461 constexpr inline double TimeSpancxx . . $ CppUtilities/TimeSpan#::operatorcxx . . $ CppUtilities/TimeSpan#`operator/`(bd46e7452c76d90a)./(TimeSpancxx . . $ CppUtilities/TimeSpan# other) const
462 {
463 return static_cast<double>(m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks.) / static_cast<double>(other.m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks.);
464 }
465
466 /*!
467 * \brief Adds another TimeSpan to the current instance.
468 */
469 inline TimeSpancxx . . $ CppUtilities/TimeSpan# &TimeSpancxx . . $ CppUtilities/TimeSpan#::operatorcxx . . $ CppUtilities/TimeSpan#`operator+=`(ef23eeb8e62ed3de).+=(const TimeSpancxx . . $ CppUtilities/TimeSpan# &other)
470 {
471 m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks. += other.m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks.;
472 return *this;
473 }
474
475 /*!
476 * \brief Subtracts another TimeSpan from the current instance.
477 */
478 inline TimeSpancxx . . $ CppUtilities/TimeSpan# &TimeSpancxx . . $ CppUtilities/TimeSpan#::operatorcxx . . $ CppUtilities/TimeSpan#`operator-=`(ef23eeb8e62ed3de).-=(const TimeSpancxx . . $ CppUtilities/TimeSpan# &other)
479 {
480 m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks. -= other.m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks.;
481 return *this;
482 }
483
484 /*!
485 * \brief Multiplies the current instance by the specified \a factor.
486 */
487 inline TimeSpancxx . . $ CppUtilities/TimeSpan# &TimeSpancxx . . $ CppUtilities/TimeSpan#::operatorcxx . . $ CppUtilities/TimeSpan#`operator*=`(6048b2c3dbfa6865).*=(double factor)
488 {
489 m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks. = static_cast<stdcxx . . $ std/::int64_tcxx . . $ std/int64_t#>(static_cast<double>(m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks.) * factor);
490 return *this;
491 }
492
493 /*!
494 * \brief Divides the current instance by the specified \a factor.
495 */
496 inline TimeSpancxx . . $ CppUtilities/TimeSpan# &TimeSpancxx . . $ CppUtilities/TimeSpan#::operatorcxx . . $ CppUtilities/TimeSpan#`operator/=`(6048b2c3dbfa6865)./=(double factor)
497 {
498 m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks. = static_cast<stdcxx . . $ std/::int64_tcxx . . $ std/int64_t#>(static_cast<double>(m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks.) / factor);
499 return *this;
500 }
501
502 #ifdef CHRONO_UTILITIES_TIMESPAN_INTEGER_SCALE_OVERLOADS
503 /*!
504 * \brief Multiplies the current instance by the specified \a factor.
505 */
506 inline TimeSpan &TimeSpan::operator*=(std::int64_t factor)
507 {
508 m_ticks *= factor;
509 return *this;
510 }
511
512 /*!
513 * \brief Divides the current instance by the specified \a factor.
514 */
515 inline TimeSpan &TimeSpan::operator/=(std::int64_t factor)
516 {
517 m_ticks /= factor;
518 return *this;
519 }
520 #endif
521
522 /*!
523 * \brief Converts the value of the current TimeSpan object to its equivalent std::string representation
524 * according the given \a format.
525 *
526 * If \a fullSeconds is true the time interval will be rounded to full seconds.
527 */
528 inline stdcxx . . $ std/::stringcxx . . $ std/string# TimeSpancxx . . $ CppUtilities/TimeSpan#::toStringcxx . . $ CppUtilities/TimeSpan#toString(371643e8aee3bcbd).(TimeSpanOutputFormatcxx . . $ CppUtilities/TimeSpanOutputFormat# format, bool fullSeconds) const
529 {
530 stdcxx . . $ std/::stringcxx . . $ std/string# resultcxx . . $ std/__cxx11/basic_string#basic_string(925dcc5e17f50391).;
531 toStringcxx . . $ CppUtilities/TimeSpan#toString(72d541dfcf10d9ed).(result, format, fullSeconds);
532 return resultcxx . . $ std/__cxx11/basic_string#basic_string(8f3aaafa33d05d0b).;
533 }
534
535 /*!
536 * \brief Returns true if the time interval represented by the current TimeSpan class is null.
537 */
538 constexpr inline bool TimeSpancxx . . $ CppUtilities/TimeSpan#::isNullcxx . . $ CppUtilities/TimeSpan#isNull(50ce9a9e25b4a850).() const
539 {
540 return m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks. == 0;
541 }
542
543 /*!
544 * \brief Returns true if the time interval represented by the current TimeSpan class is negative.
545 */
546 constexpr inline bool TimeSpancxx . . $ CppUtilities/TimeSpan#::isNegativecxx . . $ CppUtilities/TimeSpan#isNegative(50ce9a9e25b4a850).() const
547 {
548 return m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks. < 0;
549 }
550
551 /*!
552 * \brief Returns whether the time interval represented by the current instance is the smallest representable TimeSpan.
553 */
554 constexpr inline bool TimeSpancxx . . $ CppUtilities/TimeSpan#::isNegativeInfinitycxx . . $ CppUtilities/TimeSpan#isNegativeInfinity(50ce9a9e25b4a850).() const
555 {
556 return m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks. == stdcxx . . $ std/::numeric_limitscxx . . $ std/numeric_limits#<decltype(m_ticks)>::mincxx . . $ std/numeric_limits#min(5a25411868dabf75).();
557 }
558
559 /*!
560 * \brief Returns whether the time interval represented by the current instance is the longest representable TimeSpan.
561 */
562 constexpr inline bool TimeSpancxx . . $ CppUtilities/TimeSpan#::isInfinitycxx . . $ CppUtilities/TimeSpan#isInfinity(50ce9a9e25b4a850).() const
563 {
564 return m_tickscxx . . $ CppUtilities/TimeSpan#m_ticks. == stdcxx . . $ std/::numeric_limitscxx . . $ std/numeric_limits#<decltype(m_ticks)>::maxcxx . . $ std/numeric_limits#max(5a25411868dabf75).();
565 }
566 } // namespace CppUtilities
567
568 namespace stdcxx . . $ std/ {
569 /// \brief Computes the hash for the CppUtilities::TimeSpan instance.
570 template <> struct hashcxx . . $ std/hash#<CppUtilitiescxx . . $ CppUtilities/::TimeSpancxx . . $ CppUtilities/TimeSpan#> {
571 inline size_tcxx . . $ std/size_t# operatorcxx . . $ std/hash#`operator()`(1a88c6dd1a1298cd).()(const CppUtilitiescxx . . $ CppUtilities/::TimeSpancxx . . $ CppUtilities/TimeSpan# &timeSpan) const
572 {
573 return hashcxx . . $ std/hash#<decltype(timeSpan.totalTickscxx . . $ CppUtilities/TimeSpan#totalTicks(57a65ae535d7db84).())>()(cxx . . $ std/hash#`operator()`(1d85005d73761176).timeSpan.totalTickscxx . . $ CppUtilities/TimeSpan#totalTicks(57a65ae535d7db84).());
574 }
575 };
576 } // namespace std
577
578 #endif // CHRONO_UTILITIES_TIMESPAN_H