Line | Branch | Exec | Source |
---|---|---|---|
1 | /* GATE PROJECT LICENSE: | ||
2 | +----------------------------------------------------------------------------+ | ||
3 | | Copyright(c) 2018-2025, Stefan Meislinger <sm@opengate.at> | | ||
4 | | All rights reserved. | | ||
5 | | | | ||
6 | | Redistribution and use in source and binary forms, with or without | | ||
7 | | modification, are permitted provided that the following conditions are met:| | ||
8 | | | | ||
9 | | 1. Redistributions of source code must retain the above copyright notice, | | ||
10 | | this list of conditions and the following disclaimer. | | ||
11 | | 2. Redistributions in binary form must reproduce the above copyright | | ||
12 | | notice, this list of conditions and the following disclaimer in the | | ||
13 | | documentation and/or other materials provided with the distribution. | | ||
14 | | | | ||
15 | | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"| | ||
16 | | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | ||
17 | | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | ||
18 | | ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | | ||
19 | | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | ||
20 | | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | ||
21 | | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | ||
22 | | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | ||
23 | | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | ||
24 | | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | | ||
25 | | THE POSSIBILITY OF SUCH DAMAGE. | | ||
26 | +----------------------------------------------------------------------------+ | ||
27 | */ | ||
28 | |||
29 | #include "gate/times.hpp" | ||
30 | #include "gate/results.hpp" | ||
31 | #include "gate/exceptions.hpp" | ||
32 | |||
33 | namespace gate | ||
34 | { | ||
35 | |||
36 | |||
37 | 25 | Time::Time(timestamp_t microsince1601, int32_t biasminutes) | |
38 | { | ||
39 | 25 | this->timestamp = microsince1601; | |
40 | 25 | this->bias = biasminutes; | |
41 | 25 | } | |
42 | 25 | Time::Time(gate_time_t const& src) | |
43 | { | ||
44 | 25 | this->timestamp = src.timestamp; | |
45 | 25 | this->bias = src.bias; | |
46 | 25 | } | |
47 | |||
48 | |||
49 | 6 | Time Time::now() | |
50 | { | ||
51 | 6 | Time tm; | |
52 |
1/2✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
|
6 | result_t result = gate_time_now(&tm); |
53 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
6 | GATEXX_CHECK_ERROR(result); |
54 | 6 | return tm; | |
55 | } | ||
56 | |||
57 | 1 | DateTime Time::toDateTime() const | |
58 | { | ||
59 | 1 | DateTime ret; | |
60 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | result_t result = gate_time_to_datetime(this, static_cast<gate_datetime_t*>(&ret)); |
61 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
1 | GATEXX_CHECK_ERROR(result); |
62 | 1 | return ret; | |
63 | } | ||
64 | |||
65 | 1 | String Time::toString() const | |
66 | { | ||
67 | char buffer[1024]; | ||
68 | 1 | size_t bufferlen = sizeof(buffer); | |
69 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | result_t result = gate_time_to_string(this, NULL, buffer, &bufferlen); |
70 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
1 | GATEXX_CHECK_ERROR(result); |
71 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | return String(buffer, bufferlen); |
72 | } | ||
73 | 1 | String Time::toString(String const& format) const | |
74 | { | ||
75 | char pattern[1024]; | ||
76 | char buffer[1024]; | ||
77 | 1 | size_t bufferlen = sizeof(buffer); | |
78 | 1 | gate_time_t const* ptr_time = this; | |
79 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | format.copyTo(pattern, sizeof(pattern)); |
80 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | result_t result = gate_time_to_string(ptr_time, pattern, buffer, &bufferlen); |
81 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
1 | GATEXX_CHECK_ERROR(result); |
82 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | return String(buffer, bufferlen); |
83 | } | ||
84 | |||
85 | 2 | int64_t Time::toUnix() const | |
86 | { | ||
87 | 2 | int64_t ret = 0; | |
88 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | result_t result = gate_time_to_unix(this->timestamp, &ret); |
89 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
2 | GATEXX_CHECK_ERROR(result); |
90 | 2 | return ret; | |
91 | } | ||
92 | |||
93 | 2 | Time Time::add(int64_t microseconds) const | |
94 | { | ||
95 | 2 | return Time(this->timestamp + microseconds, this->bias); | |
96 | } | ||
97 | 3 | int64_t Time::diff(Time const& t) const | |
98 | { | ||
99 | 3 | return this->timestamp - t.timestamp; | |
100 | } | ||
101 | 3 | bool_t Time::empty() const | |
102 | { | ||
103 | 3 | return this->timestamp == 0; | |
104 | } | ||
105 | |||
106 | 1 | time::Microseconds Time::operator-(Time const& t) const | |
107 | { | ||
108 | 1 | return time::Microseconds(this->diff(t)); | |
109 | } | ||
110 | 1 | bool Time::operator!() const | |
111 | { | ||
112 | 1 | return this->empty(); | |
113 | } | ||
114 | |||
115 | |||
116 | 2 | Result<Time> Time::tryParse(String const& text) | |
117 | { | ||
118 | 2 | Time tm; | |
119 |
1/2✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
2 | result_t result = gate_time_parse_string(text.c_str(), text.size(), &tm); |
120 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
4 | return makeResult(result, tm); |
121 | } | ||
122 | 1 | Time Time::parse(String const& text) | |
123 | { | ||
124 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | Result<Time> result = Time::tryParse(text); |
125 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | if (result.hasError()) |
126 | { | ||
127 | ✗ | GATEXX_CHECK_EXCEPTION(result.error()); | |
128 | } | ||
129 | 2 | return result.value(); | |
130 | } | ||
131 | 1 | Time Time::fromUnix(int64_t unixSeconds) | |
132 | { | ||
133 | 1 | Time ret; | |
134 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | result_t result = gate_time_from_unix(unixSeconds, &ret.timestamp); |
135 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
1 | GATEXX_CHECK_ERROR(result); |
136 | 1 | return ret; | |
137 | } | ||
138 | 3 | Time Time::fromTimestamp(gate_timestamp_t source) | |
139 | { | ||
140 | 3 | Time ret; | |
141 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
3 | result_t result = gate_time_from_timestamp(source, &ret); |
142 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
3 | GATEXX_CHECK_ERROR(result); |
143 | 3 | return ret; | |
144 | } | ||
145 | |||
146 | 2 | bool Time::operator==(gate_timestamp_t const& src) const { return this->timestamp == src; } | |
147 | 2 | bool Time::operator!=(gate_timestamp_t const& src) const { return this->timestamp != src; } | |
148 | 1 | bool Time::operator< (gate_timestamp_t const& src) const { return this->timestamp < src; } | |
149 | 2 | bool Time::operator<=(gate_timestamp_t const& src) const { return this->timestamp <= src; } | |
150 | 1 | bool Time::operator> (gate_timestamp_t const& src) const { return this->timestamp > src; } | |
151 | 2 | bool Time::operator>=(gate_timestamp_t const& src) const { return this->timestamp >= src; } | |
152 | |||
153 | 2 | bool Time::operator==(Time const& src) const { return *this == src.timestamp; } | |
154 | 2 | bool Time::operator!=(Time const& src) const { return *this != src.timestamp; } | |
155 | 1 | bool Time::operator< (Time const& src) const { return *this < src.timestamp; } | |
156 | 2 | bool Time::operator<=(Time const& src) const { return *this <= src.timestamp; } | |
157 | 1 | bool Time::operator> (Time const& src) const { return *this > src.timestamp; } | |
158 | 2 | bool Time::operator>=(Time const& src) const { return *this >= src.timestamp; } | |
159 | |||
160 | |||
161 | |||
162 | 1 | Date::Date(uint16_t years, uint8_t months, uint8_t days) | |
163 | { | ||
164 | 1 | this->year = years; | |
165 | 1 | this->month = months; | |
166 | 1 | this->day = days; | |
167 | 1 | } | |
168 | 1 | Date::Date(uint16_t years, MonthEnum months, uint8_t days) | |
169 | { | ||
170 | 1 | this->year = years; | |
171 | 1 | this->month = (gate_uint8_t)months; | |
172 | 1 | this->day = days; | |
173 | 1 | } | |
174 | 19 | Date::Date(gate_date_t const& date) | |
175 | { | ||
176 | 19 | this->year = date.year; | |
177 | 19 | this->month = date.month; | |
178 | 19 | this->day = date.day; | |
179 | 19 | } | |
180 | |||
181 | 14 | int Date::compare(Date const& that) const | |
182 | { | ||
183 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
|
14 | if (this->year < that.year) return -1; |
184 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
|
14 | if (this->year > that.year) return +1; |
185 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
|
14 | if (this->month < that.month) return -1; |
186 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
|
14 | if (this->month > that.month) return +1; |
187 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12 times.
|
14 | if (this->day < that.day) return -1; |
188 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 9 times.
|
12 | if (this->day > that.day) return +1; |
189 | 9 | return 0; | |
190 | } | ||
191 | 1 | bool_t Date::operator< (Date const& that) const | |
192 | { | ||
193 | 1 | return this->compare(that) < 0; | |
194 | } | ||
195 | 1 | bool_t Date::operator<=(Date const& that) const | |
196 | { | ||
197 | 1 | return this->compare(that) <= 0; | |
198 | } | ||
199 | 1 | bool_t Date::operator> (Date const& that) const | |
200 | { | ||
201 | 1 | return this->compare(that) > 0; | |
202 | } | ||
203 | 1 | bool_t Date::operator>=(Date const& that) const | |
204 | { | ||
205 | 1 | return this->compare(that) >= 0; | |
206 | } | ||
207 | 1 | bool_t Date::operator==(Date const& that) const | |
208 | { | ||
209 | 1 | return (this->day == that.day) | |
210 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | && (this->month == that.month) |
211 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
2 | && (this->year == that.year); |
212 | } | ||
213 | 1 | bool_t Date::operator!=(Date const& that) const | |
214 | { | ||
215 | 1 | return (this->year != that.year) | |
216 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | || (this->month != that.month) |
217 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
2 | || (this->day != that.day); |
218 | } | ||
219 | |||
220 | |||
221 | |||
222 | 2 | DayTime::DayTime(uint8_t hours, uint8_t minutes, uint8_t seconds, uint32_t microseconds) | |
223 | { | ||
224 | 2 | this->hour = hours; | |
225 | 2 | this->minute = minutes; | |
226 | 2 | this->second = seconds; | |
227 | 2 | this->microsecond = microseconds; | |
228 | 2 | } | |
229 | |||
230 | 19 | DayTime::DayTime(gate_daytime_t const& dtime) | |
231 | { | ||
232 | 19 | this->hour = dtime.hour; | |
233 | 19 | this->minute = dtime.minute; | |
234 | 19 | this->second = dtime.second; | |
235 | 19 | this->microsecond = dtime.microsecond; | |
236 | 19 | } | |
237 | |||
238 | 14 | int DayTime::compare(DayTime const& that) const | |
239 | { | ||
240 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12 times.
|
14 | if (this->hour < that.hour) return -1; |
241 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 9 times.
|
12 | if (this->hour > that.hour) return +1; |
242 | |||
243 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if (this->minute < that.minute) return -1; |
244 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if (this->minute > that.minute) return +1; |
245 | |||
246 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if (this->second < that.second) return -1; |
247 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if (this->second > that.second) return +1; |
248 | |||
249 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 6 times.
|
9 | if (this->microsecond < that.microsecond) return -1; |
250 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
|
6 | if (this->microsecond > that.microsecond) return +1; |
251 | |||
252 | 4 | return 0; | |
253 | } | ||
254 | |||
255 | 1 | bool_t DayTime::operator< (DayTime const& that) const | |
256 | { | ||
257 | 1 | return this->compare(that) < 0; | |
258 | } | ||
259 | 1 | bool_t DayTime::operator<=(DayTime const& that) const | |
260 | { | ||
261 | 1 | return this->compare(that) <= 0; | |
262 | } | ||
263 | 1 | bool_t DayTime::operator> (DayTime const& that) const | |
264 | { | ||
265 | 1 | return this->compare(that) > 0; | |
266 | } | ||
267 | 1 | bool_t DayTime::operator>=(DayTime const& that) const | |
268 | { | ||
269 | 1 | return this->compare(that) >= 0; | |
270 | } | ||
271 | 2 | bool_t DayTime::operator==(DayTime const& that) const | |
272 | { | ||
273 | 2 | return (this->second == that.second) | |
274 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | && (this->minute == that.minute) |
275 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | && (this->hour == that.hour) |
276 |
2/4✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
4 | && (this->microsecond == that.microsecond); |
277 | } | ||
278 | 1 | bool_t DayTime::operator!=(DayTime const& that) const | |
279 | { | ||
280 | 1 | return !(*this == that); | |
281 | } | ||
282 | |||
283 | |||
284 | 1 | DateTime::DateTime(uint16_t years, uint8_t months, uint8_t days, uint8_t hours, uint8_t minutes, uint8_t seconds, uint32_t microseconds) | |
285 | { | ||
286 | 1 | this->date.year = years; | |
287 | 1 | this->date.month = months; | |
288 | 1 | this->date.day = days; | |
289 | 1 | this->time.hour = hours; | |
290 | 1 | this->time.minute = minutes; | |
291 | 1 | this->time.second = seconds; | |
292 | 1 | this->time.microsecond = microseconds; | |
293 | 1 | } | |
294 | 1 | DateTime::DateTime(Date const& date, DayTime const& dt) | |
295 | { | ||
296 | 1 | this->date.year = date.year; | |
297 | 1 | this->date.month = date.month; | |
298 | 1 | this->date.day = date.day; | |
299 | 1 | this->time.hour = dt.hour; | |
300 | 1 | this->time.minute = dt.minute; | |
301 | 1 | this->time.second = dt.second; | |
302 | 1 | this->time.microsecond = dt.microsecond; | |
303 | 1 | } | |
304 | 2 | DateTime::DateTime(gate_time_t const& time) | |
305 | { | ||
306 | 2 | result_t result = gate_time_to_datetime(&time, this); | |
307 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | GATEXX_CHECK_ERROR(result); |
308 | 2 | } | |
309 | 6 | DateTime::DateTime(gate_timestamp_t const& timestamp, bool addSystemBias) | |
310 | { | ||
311 | gate_time_t time; | ||
312 | 6 | time.timestamp = timestamp; | |
313 | 6 | time.bias = 0; | |
314 |
2/4✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
|
6 | if (addSystemBias && (timestamp != 0)) |
315 | { | ||
316 | gate_time_t now; | ||
317 |
2/4✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
|
6 | if (GATE_SUCCEEDED(gate_time_now(&now))) |
318 | { | ||
319 | 6 | time.bias = now.bias; | |
320 | } | ||
321 | } | ||
322 |
1/2✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
|
6 | result_t result = gate_time_to_datetime(&time, this); |
323 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
6 | GATEXX_CHECK_ERROR(result); |
324 | 6 | } | |
325 | |||
326 | 1 | DateTime::DateTime(String const& text) | |
327 | { | ||
328 | gate_time_t tm; | ||
329 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | result_t result = gate_time_parse_string(text.c_str(), text.length(), &tm); |
330 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
1 | GATEXX_CHECK_ERROR(result); |
331 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | result = gate_time_to_datetime(&tm, this); |
332 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
1 | GATEXX_CHECK_ERROR(result); |
333 | 1 | } | |
334 | |||
335 | 2 | bool_t DateTime::empty() const | |
336 | { | ||
337 | 2 | return this->toTime().timestamp == 0; | |
338 | } | ||
339 | |||
340 | |||
341 | 19 | Date DateTime::getDate() const | |
342 | { | ||
343 | 19 | return Date(this->date); | |
344 | } | ||
345 | 19 | DayTime DateTime::getDayTime() const | |
346 | { | ||
347 | 19 | return DayTime(this->time); | |
348 | } | ||
349 | |||
350 | |||
351 | 1 | DateTime DateTime::add(int64_t microseconds) const | |
352 | { | ||
353 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | return DateTime(this->toTime().add(microseconds)); |
354 | } | ||
355 | |||
356 | 2 | int64_t DateTime::diff(DateTime const& dt) const | |
357 | { | ||
358 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | return this->toTime().diff(dt.toTime()); |
359 | } | ||
360 | |||
361 | 9 | int DateTime::compare(DateTime const& that) const | |
362 | { | ||
363 | 9 | int result = this->getDate().compare(that.getDate()); | |
364 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if (result != 0) return result; |
365 | 9 | return this->getDayTime().compare(that.getDayTime()); | |
366 | } | ||
367 | |||
368 | |||
369 | 1 | time::Microseconds DateTime::operator-(DateTime const& dt) const | |
370 | { | ||
371 | 1 | return time::Microseconds(this->diff(dt)); | |
372 | } | ||
373 | |||
374 | |||
375 | 10 | Time DateTime::toTime() const | |
376 | { | ||
377 | 10 | Time ret; | |
378 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | result_t result = gate_date_to_time(this, &ret); |
379 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
10 | GATEXX_CHECK_ERROR(result); |
380 | 10 | return ret; | |
381 | } | ||
382 | 2 | String DateTime::toString(String const& format) const | |
383 | { | ||
384 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | Time tm = this->toTime(); |
385 | char buffer[1024]; | ||
386 | 2 | size_t buffersz = sizeof(buffer); | |
387 |
2/4✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
|
2 | result_t result = gate_time_to_string(&tm, format.empty() ? NULL : format.c_str(), buffer, &buffersz); |
388 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
2 | GATEXX_CHECK_ERROR(result); |
389 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
4 | return String(buffer, buffersz); |
390 | } | ||
391 | 1 | bool DateTime::operator<(DateTime const& that) const { return this->compare(that) < 0; } | |
392 | 1 | bool DateTime::operator<=(DateTime const& that) const { return this->compare(that) <= 0; } | |
393 | 1 | bool DateTime::operator>(DateTime const& that) const { return this->compare(that) > 0; } | |
394 | 1 | bool DateTime::operator>=(DateTime const& that) const { return this->compare(that) >= 0; } | |
395 | 4 | bool DateTime::operator==(DateTime const& that) const { return this->compare(that) == 0; } | |
396 | 1 | bool DateTime::operator!=(DateTime const& that) const { return this->compare(that) != 0; } | |
397 | |||
398 | |||
399 | |||
400 | 7 | TimeCounter TimeCounter::now() | |
401 | { | ||
402 | 7 | TimeCounter tc; | |
403 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | result_t result = gate_timecounter_now(&tc.tc); |
404 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
7 | GATEXX_CHECK_ERROR(result); |
405 | 7 | return tc; | |
406 | } | ||
407 | |||
408 | 8 | TimeCounter::TimeCounter() noexcept | |
409 | 8 | : tc(0) | |
410 | { | ||
411 | 8 | } | |
412 | 3 | TimeCounter::TimeCounter(gate_timecounter_t src) noexcept | |
413 | 3 | : tc(src) | |
414 | { | ||
415 | 3 | } | |
416 | 3 | TimeCounter::TimeCounter(TimeCounter const& src) noexcept | |
417 | 3 | : tc(src.tc) | |
418 | { | ||
419 | 3 | } | |
420 | 1 | TimeCounter& TimeCounter::operator=(TimeCounter const& src) noexcept | |
421 | { | ||
422 | 1 | this->tc = src.tc; | |
423 | 1 | return *this; | |
424 | } | ||
425 | 14 | TimeCounter::~TimeCounter() noexcept | |
426 | { | ||
427 | 14 | } | |
428 | |||
429 | 3 | TimeCounter TimeCounter::add(int64_t microseconds) const noexcept | |
430 | { | ||
431 | 3 | return TimeCounter(gate_timecounter_add(this->tc, microseconds)); | |
432 | } | ||
433 | |||
434 | 18 | int64_t TimeCounter::diff(gate_timecounter_t other) const noexcept | |
435 | { | ||
436 | 18 | return gate_timecounter_diff(this->tc, other); | |
437 | } | ||
438 | 12 | int64_t TimeCounter::diff(TimeCounter const& other) const noexcept | |
439 | { | ||
440 | 12 | return this->diff(other.tc); | |
441 | } | ||
442 | |||
443 | 1 | void TimeCounter::swap(TimeCounter& other) noexcept | |
444 | { | ||
445 | 1 | gate_timecounter_t tmp = this->tc; | |
446 | 1 | this->tc = other.tc; | |
447 | 1 | other.tc = tmp; | |
448 | 1 | } | |
449 | |||
450 | 2 | bool_t TimeCounter::empty() const noexcept | |
451 | { | ||
452 | 2 | return this->tc == 0; | |
453 | } | ||
454 | |||
455 | 7 | gate_timecounter_t const* TimeCounter::c_impl() const noexcept | |
456 | { | ||
457 | 7 | return &this->tc; | |
458 | } | ||
459 | |||
460 | 1 | bool TimeCounter::operator!() const noexcept | |
461 | { | ||
462 | 1 | return this->empty(); | |
463 | } | ||
464 | |||
465 | |||
466 | 1 | time::Microseconds TimeCounter::operator-(TimeCounter const& that) const noexcept | |
467 | { | ||
468 | 1 | return time::Microseconds(this->diff(that)); | |
469 | } | ||
470 | |||
471 | 1 | bool TimeCounter::operator==(gate_timecounter_t that) const noexcept { return this->diff(that) == 0; }; | |
472 | 2 | bool TimeCounter::operator==(TimeCounter const& that) const noexcept { return this->diff(that) == 0; }; | |
473 | |||
474 | 1 | bool TimeCounter::operator!=(gate_timecounter_t that) const noexcept { return this->diff(that) != 0; }; | |
475 | 1 | bool TimeCounter::operator!=(TimeCounter const& that) const noexcept { return this->diff(that) != 0; }; | |
476 | |||
477 | 1 | bool TimeCounter::operator< (gate_timecounter_t that) const noexcept { return this->diff(that) < 0; }; | |
478 | 3 | bool TimeCounter::operator< (TimeCounter const& that) const noexcept { return this->diff(that) < 0; }; | |
479 | |||
480 | 1 | bool TimeCounter::operator> (gate_timecounter_t that) const noexcept { return this->diff(that) > 0; }; | |
481 | 1 | bool TimeCounter::operator> (TimeCounter const& that) const noexcept { return this->diff(that) > 0; }; | |
482 | |||
483 | 1 | bool TimeCounter::operator<=(gate_timecounter_t that) const noexcept { return this->diff(that) <= 0; }; | |
484 | 1 | bool TimeCounter::operator<=(TimeCounter const& that) const noexcept { return this->diff(that) <= 0; }; | |
485 | |||
486 | 1 | bool TimeCounter::operator>=(gate_timecounter_t that) const noexcept { return this->diff(that) >= 0; }; | |
487 | 1 | bool TimeCounter::operator>=(TimeCounter const& that) const noexcept { return this->diff(that) >= 0; }; | |
488 | |||
489 | |||
490 | |||
491 | } // end of namespace gate | ||
492 | |||
493 |