@@ -15,8 +15,20 @@ namespace utils {
1515 template <class T >
1616 concept integral = std::is_integral_v<T>;
1717
18+ /* *
19+ * @brief Returns the current date and time as a string in ISO 8601 format without using any separators except for
20+ * 'T' between the date and the time.
21+ * @return The current date and time string.
22+ */
1823 [[nodiscard]] std::string current_date_time_iso8601 ();
1924
25+ /* *
26+ * @brief Converts between big endian and little endian. This function is needed since not all compilers support
27+ * std::byteswap as of yet.
28+ * @tparam Integral The type of the value to convert.
29+ * @param value The value to convert.
30+ * @return The converted value.
31+ */
2032 template <integral Integral>
2133 [[nodiscard]] constexpr Integral byte_swap (Integral value) noexcept {
2234 // based on source: slartibartswift
@@ -29,6 +41,12 @@ namespace utils {
2941 return result;
3042 }
3143
44+ /* *
45+ * @brief Converts from the machine's native byte order to little endian. On a little endian machine, this function
46+ * does return the input value.
47+ * @param value A value in the machine's native byte order.
48+ * @return The value in little endian.
49+ */
3250 [[nodiscard]] constexpr auto to_little_endian (integral auto value) {
3351 if constexpr (std::endian::native == std::endian::little) {
3452 return value;
@@ -37,6 +55,12 @@ namespace utils {
3755 }
3856 }
3957
58+ /* *
59+ * @brief Converts from little endian to the machine's native byte order. On a little endian machine, this function
60+ * does return the input value.
61+ * @param value A value in little endian.
62+ * @return The value in the machine's native byte order.
63+ */
4064 [[nodiscard]] constexpr auto from_little_endian (integral auto value) {
4165 return to_little_endian (value);
4266 }
0 commit comments