Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:48

0001 //===-- AutoHandle.h --------------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_lldb_Host_windows_AutoHandle_h_
0010 #define LLDB_lldb_Host_windows_AutoHandle_h_
0011 
0012 #include "lldb/Host/windows/windows.h"
0013 
0014 namespace lldb_private {
0015 
0016 class AutoHandle {
0017 public:
0018   AutoHandle(HANDLE handle, HANDLE invalid_value = INVALID_HANDLE_VALUE)
0019       : m_handle(handle), m_invalid_value(invalid_value) {}
0020 
0021   ~AutoHandle() {
0022     if (m_handle != m_invalid_value)
0023       ::CloseHandle(m_handle);
0024   }
0025 
0026   bool IsValid() const { return m_handle != m_invalid_value; }
0027 
0028   HANDLE get() const { return m_handle; }
0029 
0030 private:
0031   HANDLE m_handle;
0032   HANDLE m_invalid_value;
0033 };
0034 }
0035 
0036 #endif