5#ifndef MLAB_STRUTILS_HPP
6#define MLAB_STRUTILS_HPP
13 using datetime = std::chrono::time_point<std::chrono::system_clock>;
18 template <std::
size_t N>
19 [[nodiscard]] std::string
data_to_string(std::array<std::uint8_t, N>
const &v);
20 [[nodiscard]] std::string
data_to_string(std::vector<std::uint8_t>
const &v);
24 template <std::
size_t N>
35 [[nodiscard]] std::string
replace_all(std::string_view text, std::string_view search, std::string_view replace);
37 [[nodiscard]] std::string
concatenate(std::vector<std::string_view>
const &strs, std::string_view separator =
"");
38 [[nodiscard]] std::string
concatenate_s(std::vector<std::string>
const &strs, std::string_view separator =
"");
43 [[nodiscard]] std::optional<datetime>
strptime(std::string_view s, std::string_view fmt);
48 [[nodiscard]] std::string
strftime(
datetime const &dt, std::string_view fmt);
57 template <std::
size_t N>
62 template <std::
size_t N>
71 retval.resize(2 * std::distance(begin,
end) + 1);
72 auto it = std::begin(retval);
73 for (; begin !=
end; ++begin, it += 2) {
74 std::snprintf(&*it, 3,
"%02x", *begin);
Definition bin_data.hpp:127
Definition bin_data.hpp:177
std::chrono::time_point< std::chrono::system_clock > datetime
Definition strutils.hpp:13
bin_data data_from_hex_string(std::string_view s)
Definition strutils.cpp:64
bin_data data_from_string(std::string_view s)
Definition strutils.cpp:40
std::string strftime(datetime const &dt, std::string_view fmt)
Definition strutils.cpp:145
std::string data_to_hex_string(std::vector< std::uint8_t > const &v)
Definition strutils.cpp:98
bin_data & operator<<(encode_length< bin_data > w, std::string_view sv)
Definition strutils.cpp:155
std::string concatenate_s(std::vector< std::string > const &strs, std::string_view separator)
Definition strutils.cpp:8
std::string concatenate(std::vector< std::string_view > const &strs, std::string_view separator)
Definition strutils.cpp:15
constexpr range< Iterator > make_range(Iterator begin, Iterator end)
Definition bin_data.hpp:70
bin_stream & operator>>(encode_length< bin_stream > w, std::string &c)
Definition strutils.cpp:159
std::string replace_all(std::string_view text, std::string_view search, std::string_view replace)
Definition strutils.cpp:110
std::optional< datetime > strptime(std::string_view s, std::string_view fmt)
Definition strutils.cpp:137
range< std::uint8_t const * > data_view_from_string(std::string_view s)
Definition strutils.cpp:34
std::string data_to_string(std::vector< std::uint8_t > const &v)
Definition strutils.cpp:73
Definition bin_data.hpp:308
Definition bin_data.hpp:31