BRE12
StringUtils.h
1 #pragma once
2 
3 #include <codecvt>
4 
5 namespace BRE {
6 namespace StringUtils {
7 inline void ToWideString(const std::string& source,
8  std::wstring& destination) noexcept
9 {
10  destination.assign(source.begin(), source.end());
11 }
12 
13 inline std::wstring ToWideString(const std::string& source) noexcept
14 {
15  std::wstring dest;
16  dest.assign(source.begin(), source.end());
17  return dest;
18 }
19 
20 inline std::string ToString(const std::wstring& source) noexcept
21 {
22  using convert_type = std::codecvt_utf8<wchar_t>;
23  std::wstring_convert<convert_type, wchar_t> converter;
24  return converter.to_bytes(source);
25 }
26 
27 inline std::wstring AnsiToWString(const std::string& str) noexcept
28 {
29  static const std::uint32_t bufferMaxSize = 512U;
30  WCHAR buffer[bufferMaxSize];
31  MultiByteToWideChar(CP_ACP, 0U, str.c_str(), -1, buffer, bufferMaxSize);
32  return std::wstring(buffer);
33 }
34 }
35 }
36 
Definition: Camera.cpp:8