17# define vsnprintf _vsnprintf
37 if (
str.size() > 65536) {
42 str.resize(
str.size() * 2, 0);
51 return string(&
str[0]);
57 if (a.size() ==
b.size()) {
58 for (
size_t i = 0; i < a.size(); i++) {
59 if (toupper(a[i]) != toupper(
b[i])) {
72 const string &separators,
73 bool skip_empty_tokens)
75 size_t token_start = 0, token_length = 0;
76 for (
size_t i = 0; i <
str.size(); ++i) {
77 const char ch =
str[i];
78 if (separators.find(ch) == string::npos) {
88 if (!skip_empty_tokens || token_length > 0) {
89 string token =
str.substr(token_start, token_length);
90 tokens.push_back(token);
98 string token =
str.substr(token_start, token_length);
99 tokens.push_back(token);
105 const size_t len = start.size();
106 if (
len > s.size()) {
110 for (
size_t i = 0; i <
len; i++) {
111 if (s[i] != start[i]) {
121 const size_t len = end.size();
122 if (
len > s.size()) {
126 const size_t offset = s.size() -
len;
127 for (
size_t i = 0; i <
len; i++) {
128 if (s[offset + i] != end[i]) {
147 while ((index = haystack.find(needle, i)) != string::npos) {
148 haystack.replace(index, needle.size(), other);
149 i = index + other.size();
155 assert(needle.size() == other.size());
157 while (
pos != string::npos) {
158 pos = haystack.find(needle,
pos);
159 if (
pos != string::npos) {
160 memcpy(haystack.data() +
pos, other.data(), other.size());
204 std::transform(r.begin(), r.end(), r.begin(), [](
char c) { return std::tolower(c); });
212wstring string_to_wstring(
const string &
str)
214 const int length_wc = MultiByteToWideChar(CP_UTF8, 0,
str.c_str(),
str.length(),
NULL, 0);
215 wstring str_wc(length_wc, 0);
216 MultiByteToWideChar(CP_UTF8, 0,
str.c_str(),
str.length(), &str_wc[0], length_wc);
220string string_from_wstring(
const wstring &
str)
222 int length_mb = WideCharToMultiByte(CP_UTF8, 0,
str.c_str(),
str.size(),
NULL, 0,
NULL,
NULL);
223 string str_mb(length_mb, 0);
224 WideCharToMultiByte(CP_UTF8, 0,
str.c_str(),
str.size(), &str_mb[0], length_mb,
NULL,
NULL);
228string string_to_ansi(
const string &
str)
230 const int length_wc = MultiByteToWideChar(CP_UTF8, 0,
str.c_str(),
str.length(),
NULL, 0);
231 wstring str_wc(length_wc, 0);
232 MultiByteToWideChar(CP_UTF8, 0,
str.c_str(),
str.length(), &str_wc[0], length_wc);
234 int length_mb = WideCharToMultiByte(
235 CP_ACP, 0, str_wc.c_str(), str_wc.size(),
NULL, 0,
NULL,
NULL);
237 string str_mb(length_mb, 0);
238 WideCharToMultiByte(CP_ACP, 0, str_wc.c_str(), str_wc.size(), &str_mb[0], length_mb,
NULL,
NULL);
247 static const char suffixes[] =
"BKMGTPEZY";
249 const char *suffix = suffixes;
252 while (
size >= 1024) {
258 if (*suffix !=
'B') {
280 if (++i && i % 3 == 0) {
284 *(--p) =
'0' + (num % 10);
ATTR_WARN_UNUSED_RESULT const BMVert * v
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
local_group_size(16, 16) .push_constant(Type b
#define CCL_NAMESPACE_END
string string_remove_trademark(const string &s)
string string_from_bool(bool var)
string string_human_readable_size(size_t size)
bool string_iequals(const string &a, const string &b)
string string_strip(const string &s)
string to_string(const char *str)
string string_human_readable_number(size_t num)
bool string_startswith(const string_view s, const string_view start)
CCL_NAMESPACE_BEGIN string string_printf(const char *format,...)
void string_replace_same_length(string &haystack, const string &needle, const string &other)
void string_split(vector< string > &tokens, const string &str, const string &separators, bool skip_empty_tokens)
void string_replace(string &haystack, const string &needle, const string &other)
bool string_endswith(const string_view s, const string_view end)
string string_to_lower(const string &s)
VecBase< float, 4 > float4