23 #ifndef STDEXT_STRING_H
24 #define STDEXT_STRING_H
35 template<
typename T> std::string
to_string(
const T& t) {
return unsafe_cast<std::string, T>(t); }
36 template<
typename T> T
from_string(
const std::string& str, T def = T()) {
return unsafe_cast<T, std::string>(str, def); }
39 std::string
resolve_path(
const std::string& filePath, std::string sourcePath);
47 void trim(std::string& str);
51 bool ends_with(
const std::string& str,
const std::string& test);
52 bool starts_with(
const std::string& str,
const std::string& test);
53 void replace_all(std::string& str,
const std::string& search,
const std::string& replacement);
60 std::wstring utf8_to_utf16(
const std::string& src);
61 std::string utf16_to_utf8(
const std::wstring& src);
62 std::string utf16_to_latin1(
const std::wstring& src);
63 std::wstring latin1_to_utf16(
const std::string& src);
66 std::vector<std::string>
split(
const std::string& str,
const std::string& separators =
" ");
67 template<
typename T> std::vector<T>
split(
const std::string& str,
const std::string& separators =
" ") {
68 std::vector<std::string> splitted =
split(str, separators);
69 std::vector<T> results(splitted.size());
70 for(
uint i=0;i<splitted.size();++i)
71 results[i] = safe_cast<T>(splitted[i]);