17# define vsnprintf _vsnprintf
37 if (
str.size() > 65536) {
42 str.resize(
str.size() * 2, 0);
51 return string(
str.data());
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;
76 size_t token_length = 0;
77 for (
size_t i = 0;
i <
str.size(); ++
i) {
78 const char ch =
str[
i];
79 if (separators.find(ch) == string::npos) {
89 if (!skip_empty_tokens || token_length > 0) {
90 const string token =
str.substr(token_start, token_length);
91 tokens.push_back(token);
99 const string token =
str.substr(token_start, token_length);
100 tokens.push_back(token);
106 const size_t len = start.size();
107 if (
len > s.size()) {
111 for (
size_t i = 0;
i <
len;
i++) {
112 if (s[
i] != start[
i]) {
122 const size_t len = end.size();
123 if (
len > s.size()) {
127 const size_t offset = s.size() -
len;
128 for (
size_t i = 0;
i <
len;
i++) {
129 if (s[offset +
i] != end[
i]) {
149 while ((index = haystack.find(needle,
i)) != string::npos) {
150 haystack.replace(index, needle.size(), other);
151 i = index + other.size();
157 assert(needle.size() == other.size());
159 while (
pos != string::npos) {
160 pos = haystack.find(needle,
pos);
161 if (
pos != string::npos) {
162 memcpy(haystack.data() +
pos, other.data(), other.size());
194 for (
size_t i = 0;
i <
size;
i++) {
213 std::transform(r.begin(), r.end(), r.begin(), [](
char c) { return std::tolower(c); });
221wstring string_to_wstring(
const string &
str)
223 const int length_wc = MultiByteToWideChar(CP_UTF8, 0,
str.c_str(),
str.length(),
nullptr, 0);
224 wstring str_wc(length_wc, 0);
225 MultiByteToWideChar(CP_UTF8, 0,
str.c_str(),
str.length(), &str_wc[0], length_wc);
229string string_from_wstring(
const wstring &
str)
231 int length_mb = WideCharToMultiByte(
232 CP_UTF8, 0,
str.c_str(),
str.size(),
nullptr, 0,
nullptr,
nullptr);
233 string str_mb(length_mb, 0);
235 CP_UTF8, 0,
str.c_str(),
str.size(), &str_mb[0], length_mb,
nullptr,
nullptr);
239string string_to_ansi(
const string &
str)
241 const int length_wc = MultiByteToWideChar(CP_UTF8, 0,
str.c_str(),
str.length(),
nullptr, 0);
242 wstring str_wc(length_wc, 0);
243 MultiByteToWideChar(CP_UTF8, 0,
str.c_str(),
str.length(), &str_wc[0], length_wc);
245 int length_mb = WideCharToMultiByte(
246 CP_ACP, 0, str_wc.c_str(), str_wc.size(),
nullptr, 0,
nullptr,
nullptr);
248 string str_mb(length_mb, 0);
250 CP_ACP, 0, str_wc.c_str(), str_wc.size(), &str_mb[0], length_mb,
nullptr,
nullptr);
259 static const char suffixes[] =
"BKMGTPEZY";
261 const char *suffix = suffixes;
264 while (
size >= 1024) {
270 if (*suffix !=
'B') {
291 if (
i &&
i % 3 == 0) {
295 *(--p) =
'0' + (
num % 10);
ATTR_WARN_UNUSED_RESULT const size_t num
BMesh const char void * data
ATTR_WARN_UNUSED_RESULT const BMVert * v
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
#define CCL_NAMESPACE_END
#define assert(assertion)
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_hex(const uint8_t *data, const size_t size)
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)