electron/brightray/browser/win/scoped_hstring.h

42 lines
966 B
C
Raw Normal View History

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.
#ifndef BRIGHTRAY_BROWSER_WIN_SCOPED_HSTRING_H_
#define BRIGHTRAY_BROWSER_WIN_SCOPED_HSTRING_H_
2015-11-10 12:07:12 +00:00
#include <string>
2015-11-10 11:50:38 +00:00
#include <hstring.h>
#include <windows.h>
#include "base/basictypes.h"
class ScopedHString {
public:
// Copy from |source|.
ScopedHString(const wchar_t* source);
2015-11-10 12:07:12 +00:00
ScopedHString(const std::wstring& source);
2015-11-10 11:50:38 +00:00
// Create empty string.
ScopedHString();
~ScopedHString();
// Sets to |source|.
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);
};
#endif // BRIGHTRAY_BROWSER_WIN_SCOPED_HSTRING_H_