33#include <TargetConditionals.h>
38constexpr static const char TRUE_STR[] =
"true";
41constexpr static const char*
49constexpr inline std::string_view
51 using namespace std::literals;
53 #if defined(__ANDROID__)
60#elif defined(__APPLE__)
71constexpr inline std::string_view
73 using namespace std::literals;
74#if defined(__x86_64__) || defined(_M_X64)
76#elif defined(__i386__) || defined(_M_IX86)
78#elif defined(__aarch64__) || defined(_M_ARM64)
80#elif defined(__arm__) || defined(_M_ARM)
102 auto [p,
ec] = std::from_chars(
str.data(),
str.data()+
str.size(), result);
103 if (
ec == std::errc())
114 auto [p,
ec] = std::from_chars(
str.data(),
str.data()+
str.size(), result);
115 if (
ec == std::errc())
117 if (
ec == std::errc::invalid_argument)
118 throw std::invalid_argument(
"Unable to parse integer: invalid_argument");
119 else if (
ec == std::errc::result_out_of_range)
120 throw std::out_of_range(
"Unable to parse integer: out of range");
121 throw std::system_error(std::make_error_code(
ec));
130template<
typename...
Args>
132 static_assert((std::is_constructible_v<std::string_view, Args&&> && ...));
134 s.reserve((std::string_view{
args }.size() + ...));
135 (s.append(std::forward<Args>(
args)), ...);
139std::string_view
trim(std::string_view s);
168 }
while (
line.empty());
172inline std::vector<std::string_view>
175 std::vector<std::string_view>
output;
186inline std::vector<std::string_view>
189 std::vector<std::string_view>
output;
202void string_replace(std::string&
str,
const std::string& from,
const std::string& to);
216std::string
urlEncode(std::string_view input);
233using svmatch = match_results<string_view::const_iterator>;
236 return string_view(&*submatch.first, submatch.second - submatch.first);
242 regex_constants::match_flag_type flags = regex_constants::match_default)
244 return regex_match(sv.begin(), sv.end(), m, e, flags);
249 regex_constants::match_flag_type flags = regex_constants::match_default)
251 return regex_match(sv.begin(), sv.end(), e, flags);
257 regex_constants::match_flag_type flags = regex_constants::match_default)
T to_int(std::string_view str, T defaultValue)
static constexpr const char TRUE_STR[]
constexpr std::string_view platform()
void emitSignal(Args... args)
std::string string_join(const std::set< std::string > &set, std::string_view separator)
std::string to_hex_string(uint64_t id)
static constexpr const char * bool_to_str(bool b) noexcept
std::string concat(Args &&... args)
std::string to_string(double value)
bool getline(std::string_view &str, std::string_view &line, char delim='\n')
Similar to @getline_full but skips empty results.
const std::string & userAgent()
std::vector< unsigned > split_string_to_unsigned(std::string_view str, char delim)
uint64_t from_hex_string(const std::string &str)
std::string_view string_remove_suffix(std::string_view str, char separator)
static constexpr const char FALSE_STR[]
std::string_view trim(std::string_view s)
std::string urlEncode(std::string_view input)
Percent-encode a string according to RFC 3986 unreserved characters.
static bool starts_with(std::string_view str, std::string_view prefix)
bool getline_full(std::string_view &str, std::string_view &line, char delim='\n')
Split a string_view with an API similar to std::getline.
std::vector< std::string_view > split_string(std::string_view str, char delim)
std::set< std::string > string_split_set(std::string &str, std::string_view separator)
void string_replace(std::string &str, const std::string &from, const std::string &to)
constexpr std::string_view arch()
bool regex_match(string_view sv, svmatch &m, const regex &e, regex_constants::match_flag_type flags=regex_constants::match_default)
match_results< string_view::const_iterator > svmatch
sub_match< string_view::const_iterator > svsub_match
constexpr string_view svsub_match_view(const svsub_match &submatch) noexcept
bool regex_search(string_view sv, svmatch &m, const regex &e, regex_constants::match_flag_type flags=regex_constants::match_default)
string operator+(const string &s, const string_view &sv)