23 template <
typename T,
typename =
void>
24 struct _HasToString : std::false_type {
33 decltype(void(std::declval<T>().ToString()))> : std::true_type {
43 static std::wstring
ToWideStr(
const std::string &str,
bool utf8 =
false);
51 static std::string
ToMultiByteStr(
const std::wstring &wstr,
bool utf8 =
false);
58 static std::wstring
Trim(
const std::wstring &str);
65 static std::wstring
TrimStart(
const std::wstring &str);
72 static std::wstring
TrimEnd(
const std::wstring &str);
80 static std::vector<std::wstring>
Split(
const std::wstring &str,
const std::wstring &delimiter);
88 static std::wstring
FormatStr(
const wchar_t *fmt, ...);
95 static constexpr inline T
Max(
const T &a,
const T &b)
103 template <
typename T>
104 static constexpr inline T
Min(
const T &a,
const T &b)
106 return a < b ? a : b;
112 template <
typename... Args>
113 static inline std::wstring
BuildStr(
const Args &...args)
115 std::wstringstream wss;
116 int _[]{(Utils::_BuildStr(wss, args), 0)...};
124 template <
typename T>
125 static inline typename std::enable_if<!_IsProperty<T>::value && !_HasToString<T>::value,
void>::type
126 _BuildStr(std::wostream &wos,
const T &arg)
134 template <
typename T>
135 static inline typename std::enable_if<!_IsProperty<T>::value && _HasToString<T>::value,
void>::type
136 _BuildStr(std::wostream &wos,
const T &arg)
138 Utils::_BuildStr(wos, arg.ToString());
144 template <
typename T>
145 static inline typename std::enable_if<_IsProperty<T>::value,
void>::type
146 _BuildStr(std::wostream &wos,
const T &prop)
148 Utils::_BuildStr(wos, prop.Get());
154 static inline void _BuildStr(std::wostream &wos,
bool b)
156 wos << (b ? L
"true" : L
"false");
162 static inline void _BuildStr(std::wostream &wos,
const char *str)
170 static inline void _BuildStr(std::wostream &wos,
const std::string &str)
178 template <
typename T>
179 static inline void _BuildStr(std::wostream &wos,
const std::vector<T> &vec)
181 auto beg = vec.begin();
182 auto end = vec.end();
184 for (
auto it = beg; it != end; ++it) {
187 Utils::_BuildStr(wos, *it);
195 template <
typename TKey,
typename TVal>
196 static inline void _BuildStr(std::wostream &wos,
const std::map<TKey, TVal> &map)
198 auto beg = map.begin();
199 auto end = map.end();
201 for (
auto it = beg; it != end; ++it) {
204 Utils::_BuildStr(wos, it->first);
206 Utils::_BuildStr(wos, it->second);
214 template <
typename TKey,
typename TVal>
215 static inline void _BuildStr(std::wostream &wos,
const std::unordered_map<TKey, TVal> &map)
217 auto beg = map.begin();
218 auto end = map.end();
220 for (
auto it = beg; it != end; ++it) {
223 Utils::_BuildStr(wos, it->first);
225 Utils::_BuildStr(wos, it->second);