9
9
#include < string>
10
10
11
11
namespace utils {
12
+ /* *
13
+ * @brief Returns the current date and time as a string in ISO 8601 format without using any separators except for
14
+ * 'T' between the date and the time.
15
+ * @return The current date and time string.
16
+ */
12
17
[[nodiscard]] std::string current_date_time_iso8601 ();
13
18
19
+ /* *
20
+ * @brief Converts between big endian and little endian. This function is needed since not all compilers support
21
+ * std::byteswap as of yet.
22
+ * @tparam Integral The type of the value to convert.
23
+ * @param value The value to convert.
24
+ * @return The converted value.
25
+ */
14
26
template <std::integral Integral>
15
27
[[nodiscard]] constexpr inline Integral byte_swap (Integral value) noexcept {
16
28
// source: https://en.cppreference.com/w/cpp/numeric/byteswap
@@ -20,6 +32,12 @@ namespace utils {
20
32
return std::bit_cast<Integral>(value_representation);
21
33
}
22
34
35
+ /* *
36
+ * @brief Converts from the machine's native byte order to little endian. On a little endian machine, this function
37
+ * does return the input value.
38
+ * @param value A value in the machine's native byte order.
39
+ * @return The value in little endian.
40
+ */
23
41
[[nodiscard]] constexpr inline auto to_little_endian (std::integral auto value) {
24
42
if constexpr (std::endian::native == std::endian::little) {
25
43
return value;
@@ -28,6 +46,12 @@ namespace utils {
28
46
}
29
47
}
30
48
49
+ /* *
50
+ * @brief Converts from little endian to the machine's native byte order. On a little endian machine, this function
51
+ * does return the input value.
52
+ * @param value A value in little endian.
53
+ * @return The value in the machine's native byte order.
54
+ */
31
55
[[nodiscard]] constexpr inline auto from_little_endian (std::integral auto value) {
32
56
return to_little_endian (value);
33
57
}
0 commit comments