2015-11-10 11:50:38 +00:00
|
|
|
// 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.
|
|
|
|
|
2019-06-19 20:56:58 +00:00
|
|
|
#ifndef SHELL_BROWSER_WIN_SCOPED_HSTRING_H_
|
|
|
|
#define SHELL_BROWSER_WIN_SCOPED_HSTRING_H_
|
2015-11-10 11:50:38 +00:00
|
|
|
|
|
|
|
#include <hstring.h>
|
|
|
|
#include <windows.h>
|
|
|
|
|
2017-03-23 19:48:22 +00:00
|
|
|
#include <string>
|
|
|
|
|
2016-03-08 01:14:16 +00:00
|
|
|
#include "base/macros.h"
|
2015-11-10 11:50:38 +00:00
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
namespace electron {
|
2018-10-24 10:49:10 +00:00
|
|
|
|
2015-11-10 11:50:38 +00:00
|
|
|
class ScopedHString {
|
|
|
|
public:
|
|
|
|
// Copy from |source|.
|
2017-03-23 19:48:22 +00:00
|
|
|
explicit ScopedHString(const wchar_t* source);
|
|
|
|
explicit ScopedHString(const std::wstring& source);
|
2015-11-10 11:50:38 +00:00
|
|
|
// Create empty string.
|
|
|
|
ScopedHString();
|
|
|
|
~ScopedHString();
|
|
|
|
|
|
|
|
// Sets to |source|.
|
2015-11-24 07:11:43 +00:00
|
|
|
void Reset();
|
|
|
|
void Reset(const wchar_t* source);
|
|
|
|
void Reset(const std::wstring& source);
|
2015-11-10 11:50:38 +00:00
|
|
|
|
|
|
|
// 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);
|
|
|
|
};
|
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
} // namespace electron
|
2018-10-24 10:49:10 +00:00
|
|
|
|
2019-06-19 20:56:58 +00:00
|
|
|
#endif // SHELL_BROWSER_WIN_SCOPED_HSTRING_H_
|