forked from adamlaska/electron
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscoped_hstring.cc
More file actions
42 lines (31 loc) · 895 Bytes
/
scoped_hstring.cc
File metadata and controls
42 lines (31 loc) · 895 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
// Copyright (c) 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE-CHROMIUM file.
#include "shell/browser/win/scoped_hstring.h"
#include <winstring.h>
namespace electron {
ScopedHString::ScopedHString(const wchar_t* source) {
Reset(source);
}
ScopedHString::ScopedHString(const std::wstring& source) {
Reset(source);
}
ScopedHString::ScopedHString() = default;
ScopedHString::~ScopedHString() {
Reset();
}
void ScopedHString::Reset() {
if (str_) {
WindowsDeleteString(str_);
str_ = nullptr;
}
}
void ScopedHString::Reset(const wchar_t* source) {
Reset();
WindowsCreateString(source, wcslen(source), &str_);
}
void ScopedHString::Reset(const std::wstring& source) {
Reset();
WindowsCreateString(source.c_str(), source.length(), &str_);
}
} // namespace electron