mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
refactor: rename the atom directory to shell
This commit is contained in:
committed by
Samuel Attard
parent
4575a4aae3
commit
d7f07e8a80
42
shell/browser/win/scoped_hstring.cc
Normal file
42
shell/browser/win/scoped_hstring.cc
Normal file
@@ -0,0 +1,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 "atom/browser/win/scoped_hstring.h"
|
||||
|
||||
#include <winstring.h>
|
||||
|
||||
namespace atom {
|
||||
|
||||
ScopedHString::ScopedHString(const wchar_t* source) : str_(nullptr) {
|
||||
Reset(source);
|
||||
}
|
||||
|
||||
ScopedHString::ScopedHString(const std::wstring& source) : str_(nullptr) {
|
||||
Reset(source);
|
||||
}
|
||||
|
||||
ScopedHString::ScopedHString() : str_(nullptr) {}
|
||||
|
||||
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 atom
|
||||
45
shell/browser/win/scoped_hstring.h
Normal file
45
shell/browser/win/scoped_hstring.h
Normal file
@@ -0,0 +1,45 @@
|
||||
// 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.
|
||||
|
||||
#ifndef ATOM_BROWSER_WIN_SCOPED_HSTRING_H_
|
||||
#define ATOM_BROWSER_WIN_SCOPED_HSTRING_H_
|
||||
|
||||
#include <hstring.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/macros.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
class ScopedHString {
|
||||
public:
|
||||
// Copy from |source|.
|
||||
explicit ScopedHString(const wchar_t* source);
|
||||
explicit ScopedHString(const std::wstring& source);
|
||||
// Create empty string.
|
||||
ScopedHString();
|
||||
~ScopedHString();
|
||||
|
||||
// Sets to |source|.
|
||||
void Reset();
|
||||
void Reset(const wchar_t* source);
|
||||
void Reset(const std::wstring& source);
|
||||
|
||||
// Returns string.
|
||||
operator HSTRING() const { return str_; }
|
||||
|
||||
// Whether there is a string created.
|
||||
bool success() const { return str_; }
|
||||
|
||||
private:
|
||||
HSTRING str_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ScopedHString);
|
||||
};
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_WIN_SCOPED_HSTRING_H_
|
||||
Reference in New Issue
Block a user