libfswatch  1.9.3
Public Member Functions | Static Public Member Functions | List of all members
fsw::win_handle Class Reference

A RAII wrapper around Microsoft Windows HANDLE. More...

#include <win_handle.hpp>

Public Member Functions

 win_handle ()
 Constructs an instance wrapping INVALID_HANDLE_VALUE.
 
 win_handle (HANDLE handle)
 Constructs an instance wrapping handle.
 
virtual ~win_handle ()
 Destructs a handle. More...
 
 operator HANDLE () const
 Returns the handle value as HANDLE instance.
 
bool is_valid () const
 Checks whether the handle is valid. More...
 
 win_handle (const win_handle &)=delete
 Deleted copy constructor.
 
win_handleoperator= (const win_handle &)=delete
 Deleted copy assignment operator.
 
 win_handle (win_handle &&other) noexcept
 Move constructor. More...
 
win_handleoperator= (win_handle &&other) noexcept
 Move assignment operator. More...
 
win_handleoperator= (const HANDLE &handle)
 Assigns a handle to the current instance. More...
 

Static Public Member Functions

static bool is_valid (const HANDLE &handle)
 Checks whether handle is valid. More...
 

Detailed Description

A RAII wrapper around Microsoft Windows HANDLE.

This class is a movable, non-copyable RAII wrapper on HANDLE.

Constructor & Destructor Documentation

virtual fsw::win_handle::~win_handle ( )
virtual

Destructs a handle.

If the handle is valid (is_valid()) it is closed invoking CloseHandle().

See also
is_valid(const HANDLE &)
fsw::win_handle::win_handle ( win_handle &&  other)
noexcept

Move constructor.

The move constructors moves the handle value wrapped by other to the target instance. The handle value in other is set to INVALID_HANDLE_VALUE. The previously wrapped instance is closed invoking CloseHandle if it is valid.

Parameters
otherThe handle to move.

Member Function Documentation

static bool fsw::win_handle::is_valid ( const HANDLE &  handle)
static

Checks whether handle is valid.

A handle is valid is if its value is not null and if is not INVALID_HANDLE_VALUE.

Parameters
handleThe handle to check.
Returns
Returns true if handle is valid, false otherwise.
bool fsw::win_handle::is_valid ( ) const

Checks whether the handle is valid.

Returns
Returns true if the handle is valid, false otherwise.
See also
is_valid()
win_handle& fsw::win_handle::operator= ( win_handle &&  other)
noexcept

Move assignment operator.

The move assignment operator moves the handle value wrapped by other to the target instance. The handle value in other is set to INVALID_HANDLE_VALUE. The previously wrapped instance is closed invoking CloseHandle if it is valid.

Parameters
otherThe handle to move.
win_handle& fsw::win_handle::operator= ( const HANDLE &  handle)

Assigns a handle to the current instance.

The previously wrapped instance is closed invoking CloseHandle if it is valid.

Parameters
handleThe handle value to assign to the current instance.

The documentation for this class was generated from the following file: