5#ifndef SAPPHIRE_LOGGER_STRING_FORMAT_GUARD
6#define SAPPHIRE_LOGGER_STRING_FORMAT_GUARD
14 template <
typename StringT>
15 uint32_t ReplaceAllInString(StringT& _str,
const StringT& _what,
const StringT& _with){
19 for(
typename StringT::size_type pos{}; (pos = _str.find(_what, pos)) != _str.npos; pos += _with.size())
21 _str.replace(pos, _what.size(), _with);
28 template <
typename FirstT,
typename... Args>
29 void StringFormatImpl(std::wstring& _str, uint32_t _depth, FirstT&& _first, Args&&... _args)
31 const uint32_t count = Intl::ReplaceAllInString(_str, L
'%' + std::to_wstring(_depth),
ToWString(_first));
35 if constexpr (
sizeof...(Args) == 0)
43 StringFormatImpl(_str, _depth + 1, std::forward<Args>(_args)...);
48 template <
typename FirstT,
typename... Args>
49 std::wstring StringFormat(FirstT _first, Args&&... _args)
52 std::wstring str =
SA::ToWString(std::forward<FirstT>(_first));
55 if constexpr (
sizeof...(Args) != 0)
56 Intl::StringFormatImpl(str, 1u, std::forward<Args>(_args)...);
std::wstring ToWString(const Log &_log)
ToWString implementation for log.