1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-03-02 13:29:14 +01:00
dxvk/src/util/util_string.h
Joshua Ashton bf14371f9e [util] Wide character conversion changes
Replaces tows with an easier helper that fits in nicer with fixed-size arrays in DXGI, etc.

Prefer UTF8 in tows/fromws.
2019-11-26 01:53:49 +01:00

42 lines
870 B
C++

#pragma once
#include <string>
#include <sstream>
#include <vector>
#include "./com/com_include.h"
namespace dxvk::str {
std::string fromws(const WCHAR *ws);
void tows(const char* mbs, WCHAR* wcs, size_t wcsLen);
template <size_t N>
void tows(const char* mbs, WCHAR (&wcs)[N]) {
return tows(mbs, wcs, N);
}
inline void format1(std::stringstream&) { }
template<typename... Tx>
void format1(std::stringstream& str, const WCHAR *arg, const Tx&... args) {
str << fromws(arg);
format1(str, args...);
}
template<typename T, typename... Tx>
void format1(std::stringstream& str, const T& arg, const Tx&... args) {
str << arg;
format1(str, args...);
}
template<typename... Args>
std::string format(const Args&... args) {
std::stringstream stream;
format1(stream, args...);
return stream.str();
}
}