2 #include <samchon/API.hpp> 5 #include <samchon/WeakString.hpp> 9 #include <samchon/IndexPair.hpp> 10 #include <samchon/library/Math.hpp> 54 template <
typename T,
typename ... _Args>
56 const T& val,
const _Args& ... args) -> std::string
58 std::string &res = _substitute(format, val);
62 template <
typename T>
static auto substitute(
const std::string &format,
const T& val) -> std::string
64 return _substitute(format, val);
80 template <
typename T,
typename ... _Args >
82 const T& value,
const _Args& ... args) -> std::string
84 std::string &res = _substituteSQL(format, value);
87 template <
typename T>
static auto substituteSQL(
const std::string &format,
const T& value) -> std::string
89 return _substituteSQL(format, value);
93 template <
typename T>
static auto _substitute(
const std::string &format,
const T& value) -> std::string
95 std::vector<std::string> &parenthesisArray = betweens(format, { (char)
'{' }, { (char)
'}' });
96 std::vector<long> vec;
98 for (
auto it = parenthesisArray.begin(); it != parenthesisArray.end(); it++)
99 if (isNumeric(*it) ==
true)
100 vec.push_back(stoi(*it));
105 std::string &to = toString(value);
106 return replaceAll(format,
"{" + toString(index) +
"}", to);
108 template <
typename T>
static auto _substituteSQL(
const std::string &format,
const T& value) -> std::string
110 std::vector<std::string> &parenthesisArray = betweens(format,
"{",
"}");
111 std::vector<long> vec;
113 for (
auto it = parenthesisArray.begin(); it != parenthesisArray.end(); it++)
114 if (isNumeric(*it) ==
true)
115 vec.push_back(stoi(*it));
120 std::string &to = toSQL(value);
121 return replaceAll(format,
"{" + toString(index) +
"}", to);
127 template <
typename T>
128 static auto toString(
const T &val) -> std::string
130 std::basic_stringstream<char> stream;
135 template<>
static auto toString(
const WeakString &str) -> std::string;
137 template <
typename T>
138 static auto toSQL(
const T &val) -> std::string
143 std::basic_stringstream<char> stream;
148 template<>
static auto toSQL(
const bool &flag) -> std::string;
149 template<>
static auto toSQL(
const char &val) -> std::string;
150 template<>
static auto toSQL(
const std::string &str) -> std::string;
151 template<>
static auto toSQL(
const WeakString &str) -> std::string;
152 static auto toSQL(
const char *) -> std::string;
170 static auto isNumeric(
const std::string &str) -> bool;
178 static auto toNumber(
const std::string &str) -> double;
191 static auto numberFormat(
double val,
int precision = 2) -> std::string;
202 static auto percentFormat(
double val,
int precision = 2) -> std::string;
219 static auto colorNumberFormat(
double value,
int precision = 2,
double delimiter = 0.0) -> std::string;
229 static auto colorPercentFormat(
double value,
int precision = 2,
double delimiter = 0.0) -> std::string;
242 static auto trim(
const std::string &val,
const std::vector<std::string> &delims) -> std::string;
251 static auto ltrim(
const std::string &val,
const std::vector<std::string> &delims) -> std::string;
260 static auto rtrim(
const std::string &val,
const std::vector<std::string> &delims) -> std::string;
262 static auto trim(
const std::string &str) -> std::string;
263 static auto ltrim(
const std::string &str) -> std::string;
264 static auto rtrim(
const std::string &str) -> std::string;
266 static auto trim(
const std::string &str,
const std::string &delim) -> std::string;
267 static auto ltrim(
const std::string &str,
const std::string &delim) -> std::string;
268 static auto rtrim(
const std::string &str,
const std::string &delim) -> std::string;
288 static auto finds(
const std::string &str,
289 const std::vector<std::string> &delims,
size_t startIndex = 0)->IndexPair<std::string>;
306 static auto rfinds(
const std::string &str,
307 const std::vector<std::string> &delims,
size_t endIndex = SIZE_MAX)->IndexPair<std::string>;
324 static auto substring(
const std::string &str,
325 size_t startIndex,
size_t endIndex = SIZE_MAX) -> std::string;
346 static auto between(
const std::string &str,
347 const std::string &start =
"",
const std::string &end =
"") -> std::string;
357 static auto addTab(
const std::string &str,
size_t n = 1) -> std::string;
368 static auto split(
const std::string &str,
const std::string &delim) -> std::vector<std::string>;
390 const std::string &str,
391 const std::string &start =
"",
const std::string &end =
"" 392 ) -> std::vector<std::string>;
404 static auto toLowerCase(
const std::string &str) -> std::string;
412 static auto toUpperCase(
const std::string &str) -> std::string;
422 static auto replaceAll
424 const std::string &str,
425 const std::string &before,
const std::string &after
435 static auto replaceAll(
const std::string &str,
436 const std::vector<std::pair<std::string, std::string>> &pairs) -> std::string;
443 static auto removeHTMLSpaces(
const std::string &) -> std::string;
static auto substituteSQL(const std::string &format, const T &value, const _Args &...args) -> std::string
Substitutes "{n}" tokens within the specified sql-string with the respective arguments passed in...
static auto substitute(const std::string &format, const T &val, const _Args &...args) -> std::string
Substitutes "{n}" tokens within the specified string with the respective arguments passed in...
static auto minimum(const _Cont &container) -> IndexPair< T >
Calculate minimum value with its index.
Top level namespace of products built from samchon.
A string class only references characeters, reference only.
Utility class for string.