11#ifndef EASY3D_UTIL_STRING_H
12#define EASY3D_UTIL_STRING_H
38 void split(
const std::string &in,
char separator, std::vector<std::string> &out,
bool skip_empty_fields =
true);
53 bool split(
const std::string &in,
char separator, std::string &left, std::string &right);
64 std::string
join(
const std::vector<std::string> &in,
char separator);
75 std::string
join(
const std::vector<std::string> &in,
const std::string &separator);
80 void replace(std::string &in,
const std::string &old_substr,
const std::string &new_substr);
104 const char s[2] = { c,
'\0' };
105 return std::string(s);
116 std::string
quote(
const std::string &s,
char quotes =
'\"');
125 bool starts_with(
const std::string &haystack,
const std::string &needle);
134 bool ends_with(
const std::string &haystack,
const std::string &needle);
141 std::string
to_string(
int value,
int width,
char fill =
'0');
146 std::string
printf(
const char *format, ...);
151 void appendf(std::string &dst,
const char *format, ...);
167 std::string
time(
double time,
int num_digits = 1);
172 std::wstring
to_wstring(
const std::string &str);
String manipulation utilities.
Definition string.cpp:24
void replace(std::string &in, const std::string &old_substr, const std::string &new_substr)
Replaces the old sub-string by a new sub-string.
Definition string.cpp:74
bool ends_with(const std::string &haystack, const std::string &needle)
Checks if a string ends with a substring.
Definition string.cpp:121
std::string printf(const char *format,...)
Definition string.cpp:185
std::string current_time_detailed()
Gets the detailed current time as a string, e.g., "2024-10-24-17-41-16-753".
Definition string.cpp:214
std::string from_wstring(const std::wstring &wstr)
Converts from std::wstring to std::string.
Definition string.cpp:261
std::string quote(const std::string &s, char quotes)
Adds quotes to a string.
Definition string.cpp:113
std::string to_uppercase(const std::string &str)
Converts a string to uppercase.
Definition string.cpp:89
void appendf(std::string &dst, const char *format,...)
Appends the resulting string to a supplied string.
Definition string.cpp:194
void split(const std::string &in, char separator, std::vector< std::string > &out, bool skip_empty_fields)
Splits a string into parts.
Definition string.cpp:26
std::string to_string(int v, int width, char fill)
Converts an integer value to a string of a desired length.
Definition string.cpp:127
std::string to_lowercase(const std::string &str)
Converts a string to lowercase.
Definition string.cpp:83
std::wstring to_wstring(const std::string &str)
Converts from std::string to std::wstring.
Definition string.cpp:256
std::string join(const std::vector< std::string > &in, char separator)
Join multiple strings.
Definition string.cpp:53
bool starts_with(const std::string &haystack, const std::string &needle)
Checks if a string starts with a substring.
Definition string.cpp:117
std::string time(double time, int num_digits)
Converts time (in millisecond) into a string with the most suitable/readable unit....
Definition string.cpp:227
std::string current_time()
Gets the time string, e.g., "Fri Jan 09 11:39:32 2015".
Definition string.cpp:202
Definition collider.cpp:182