forked from tomazos/QtDirectX11WidgetDemo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWinUtils.h
65 lines (50 loc) · 916 Bytes
/
WinUtils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// (C) 2011, Andrew Tomazos <andrew@tomazos.com>.
#ifndef WINUTILS_H
#define WINUTILS_H
#include "windows.h"
#include <QtCore/QString>
class WinUtils
{
public:
static QString WinUtils::stringify(LPTSTR str);
static QString WinUtils::stringify(HRESULT hresult);
};
class DestringifyLPTSTR
{
public:
DestringifyLPTSTR(const QString& s)
#ifdef UNICODE
: m_s(s)
{
}
#else
: m_b(s.toAscii())
{
}
#endif
operator LPTSTR()
#ifdef UNICODE
{ return (LPTSTR) m_s.utf16(); }
#else
{ return m_b.data(); }
#endif
private:
#ifdef UNICODE
QString m_s;
#else
QByteArray m_b;
#endif
};
class DestringifyLPCSTR
{
public:
DestringifyLPCSTR(const QString& s)
: m_b(s.toAscii())
{
}
operator LPCSTR()
{ return (LPCSTR) m_b.data(); }
private:
QByteArray m_b;
};
#endif // WINUTILS_H