17#ifndef TOOLBOX_UTIL_STRING_HPP
18#define TOOLBOX_UTIL_STRING_HPP
28inline namespace util {
30template <
typename ValueT>
34 return Traits::from_string(
sv);
38template <
typename ValueT>
42 return Traits::from_string(
s);
45template <
typename ValueT>
49 return Traits::from_string(std::string_view{
s});
53template <
typename ValueT>
61template <
typename ValueT>
67 return std::to_string(
val);
70template <std::
size_t SizeN>
84inline void trim(std::string_view&
s)
noexcept
90inline void trim(std::string&
s)
noexcept
96inline std::string_view
ltrim_copy(std::string_view
s)
noexcept
120inline std::string_view
trim_copy(std::string_view
s)
noexcept
133 char delim)
noexcept;
143constexpr std::size_t
pstrlen(
const char*
src, std::size_t
n)
noexcept
145 if constexpr (
PadC ==
'\0') {
162template <
char PadC, std::
size_t SizeN>
177 if constexpr (
PadC ==
'\0') {
179#pragma GCC diagnostic push
180#pragma GCC diagnostic ignored "-Wstringop-truncation"
185#pragma GCC diagnostic pop
189 for (;
i <
n &&
src[
i] !=
'\0'; ++
i) {
205template <
char PadC, std::
size_t SizeN>
218constexpr std::size_t
pstrcpy(
char*
dst, std::string_view
src, std::size_t
n)
noexcept
220 const std::size_t
len{std::min(
n,
src.size())};
236template <
char PadC, std::
size_t SizeN>
243constexpr std::size_t
pstrcpyid(
char*
dst, std::int64_t
id, std::size_t
n)
noexcept
246 const auto [
eptr,
ec] = std::to_chars(
dst, end,
id);
247 if (
ec == std::errc::value_too_large) {
256template <
char PadC, std::
size_t SizeN>
282template <
char PadC, std::
size_t SizeN>
313template <
char PadC, std::
size_t SizeN>
326constexpr std::size_t
lpstrcpy(
char*
dst, std::string_view
src, std::size_t
n)
noexcept
328 const std::size_t
len{std::min(
n,
src.size())};
344template <
char PadC, std::
size_t SizeN>
350template <
typename...
ArgsT>
353 std::stringstream os;