11#ifndef EASY3D_UTIL_STRING_H
12#define EASY3D_UTIL_STRING_H
39 void split(
const std::string &in,
char separator, std::vector<std::string> &out,
bool skip_empty_fields =
true);
54 bool split(
const std::string &in,
char separator, std::string &left, std::string &right);
65 std::string
join(
const std::vector<std::string> &in,
char separator);
76 std::string
join(
const std::vector<std::string> &in,
const std::string &separator);
81 void replace(std::string &in,
const std::string &old_substr,
const std::string &new_substr);
105 const char s[2] = { c,
'\0' };
106 return std::string(s);
117 std::string
quote(
const std::string &s,
char quotes =
'\"');
126 bool starts_with(
const std::string &haystack,
const std::string &needle);
135 bool ends_with(
const std::string &haystack,
const std::string &needle);
142 std::string
to_string(
int value,
int width,
char fill =
'0');
147 std::string
printf(
const char *format, ...);
152 void appendf(std::string &dst,
const char *format, ...);
163 std::string
time(
double time,
int num_digits = 1);
168 std::wstring
to_wstring(
const std::string &str);
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:72
bool ends_with(const std::string &haystack, const std::string &needle)
Checks if a string ends with a substring.
Definition: string.cpp:119
std::string printf(const char *format,...)
Definition: string.cpp:183
std::string from_wstring(const std::wstring &wstr)
Converts from std::wstring to std::string.
Definition: string.cpp:257
std::string quote(const std::string &s, char quotes)
Adds quotes to a string.
Definition: string.cpp:111
std::string date_time()
Gets the time string, e.g., "Fri Jan 09 11:39:32 2015".
Definition: string.cpp:201
std::string to_uppercase(const std::string &str)
Converts a string to uppercase.
Definition: string.cpp:87
void appendf(std::string &dst, const char *format,...)
Appends the resulting string to a supplied string.
Definition: string.cpp:192
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:24
std::string to_string(int v, int width, char fill)
Converts an integer value to a string of a desired length.
Definition: string.cpp:125
std::string to_lowercase(const std::string &str)
Converts a string to lowercase.
Definition: string.cpp:81
std::wstring to_wstring(const std::string &str)
Converts from std::string to std::wstring.
Definition: string.cpp:252
std::string join(const std::vector< std::string > &in, char separator)
Join multiple strings.
Definition: string.cpp:51
bool starts_with(const std::string &haystack, const std::string &needle)
Checks if a string starts with a substring.
Definition: string.cpp:115
std::string time(double time, int num_digits)
Converts time (in millisecond) into a string with the most suitable/readable unit....
Definition: string.cpp:223
Definition: collider.cpp:182