| 
									
										
										
										
											2015-11-10 19:50:38 +08: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.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-22 08:34:31 +01:00
										 |  |  | #ifndef ELECTRON_SHELL_BROWSER_WIN_SCOPED_HSTRING_H_
 | 
					
						
							|  |  |  | #define ELECTRON_SHELL_BROWSER_WIN_SCOPED_HSTRING_H_
 | 
					
						
							| 
									
										
										
										
											2015-11-10 19:50:38 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <hstring.h>
 | 
					
						
							|  |  |  | #include <windows.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-23 12:48:22 -07:00
										 |  |  | #include <string>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-19 14:23:04 -07:00
										 |  |  | namespace electron { | 
					
						
							| 
									
										
										
										
											2018-10-24 12:49:10 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-10 19:50:38 +08:00
										 |  |  | class ScopedHString { | 
					
						
							|  |  |  |  public: | 
					
						
							|  |  |  |   // Copy from |source|.
 | 
					
						
							| 
									
										
										
										
											2017-03-23 12:48:22 -07:00
										 |  |  |   explicit ScopedHString(const wchar_t* source); | 
					
						
							|  |  |  |   explicit ScopedHString(const std::wstring& source); | 
					
						
							| 
									
										
										
										
											2015-11-10 19:50:38 +08:00
										 |  |  |   // Create empty string.
 | 
					
						
							|  |  |  |   ScopedHString(); | 
					
						
							|  |  |  |   ~ScopedHString(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-03 12:41:45 +01:00
										 |  |  |   // disable copy
 | 
					
						
							|  |  |  |   ScopedHString(const ScopedHString&) = delete; | 
					
						
							|  |  |  |   ScopedHString& operator=(const ScopedHString&) = delete; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-10 19:50:38 +08:00
										 |  |  |   // Sets to |source|.
 | 
					
						
							| 
									
										
										
										
											2015-11-24 15:11:43 +08:00
										 |  |  |   void Reset(); | 
					
						
							|  |  |  |   void Reset(const wchar_t* source); | 
					
						
							|  |  |  |   void Reset(const std::wstring& source); | 
					
						
							| 
									
										
										
										
											2015-11-10 19:50:38 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // Returns string.
 | 
					
						
							|  |  |  |   operator HSTRING() const { return str_; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // Whether there is a string created.
 | 
					
						
							|  |  |  |   bool success() const { return str_; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  private: | 
					
						
							| 
									
										
										
										
											2021-01-26 19:16:21 +01:00
										 |  |  |   HSTRING str_ = nullptr; | 
					
						
							| 
									
										
										
										
											2015-11-10 19:50:38 +08:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-19 14:23:04 -07:00
										 |  |  | }  // namespace electron
 | 
					
						
							| 
									
										
										
										
											2018-10-24 12:49:10 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-22 08:34:31 +01:00
										 |  |  | #endif  // ELECTRON_SHELL_BROWSER_WIN_SCOPED_HSTRING_H_
 |