-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbinded_str.cpp
More file actions
43 lines (37 loc) · 793 Bytes
/
binded_str.cpp
File metadata and controls
43 lines (37 loc) · 793 Bytes
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
#include "binded_str.h"
using namespace DrvLoader;
DrvLoader::binded_str::binded_str()
{
data = nullptr;
};
binded_str::~binded_str()
{
if (data != nullptr)
{
free(data);
data = nullptr;
}
}
binded_str::operator String ^ () { return data_str; }
binded_str::operator PWSTR() { return data; }
binded_str^ binded_str::operator=(String^ source)
{
data_str = source;
this->~binded_str();
const pin_ptr<const WCHAR> s = PtrToStringChars(source);
const size_t len = wcslen(s) + 1;
data = static_cast<PWSTR>(malloc(len * sizeof(WCHAR)));
if (data != nullptr)
{
wcscpy_s(data, len, s);
}
return this;
}
size_t binded_str::Length::get()
{
if (data != nullptr)
{
return wcslen(data);
}
return 0;
}