blob: 22670172174f1ebc2ecf494be18cac4f587d0247 (
plain)
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
|
#ifndef WCHARPTR_H
#define WCHARPTR_H
#include <windows.h>
/* WcharPtr: Simple wrapper for wide C strings. */
struct WcharPtr
{
/* Named copy constructors (expensive). */
static WcharPtr FromNarrow(const char* buf, int cp = CP_UTF8);
static WcharPtr Copy(const wchar_t* s);
/* Non-explicit copies are disabled. */
WcharPtr(WcharPtr& other) = delete;
WcharPtr& operator=(WcharPtr& other) = delete;
WcharPtr() noexcept;
~WcharPtr();
operator wchar_t*() noexcept;
WcharPtr(wchar_t* s) noexcept;
WcharPtr& operator=(wchar_t* s) noexcept;
WcharPtr(WcharPtr&& other) noexcept;
WcharPtr& operator=(WcharPtr&& other) noexcept;
/* Return pointer, releasing ownership. */
wchar_t *Release() noexcept;
private:
wchar_t* m_p = nullptr;
};
#endif
|