WinStd Additional templates and function helpers for Microsoft Windows using Standard C++ classes

Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
winstd::handle< T, INVAL > Class Template Referenceabstract
System Handles

Base abstract template class to support generic object handle keeping. More...

`#include <Common.h>`

Inheritance diagram for winstd::handle< T, INVAL >:

## Public Types
typedef T | handle_type
| Datatype of the object handle this template class handles.

## Public Member Functions
| handle () noexcept
| Initializes a new class instance with the object handle set to INVAL.
| handle (_In_opt_ handle_type h) noexcept
| Initializes a new class instance with an already available object handle. More...
| handle (_Inout_ handle< handle_type, INVAL > &&h) noexcept
| Move constructor. More...
handle< handle_type, INVAL > & | operator= (_In_opt_ handle_type h) noexcept
| Attaches already available object handle. More...
handle< handle_type, INVAL > & | operator= (_Inout_ handle< handle_type, INVAL > &&h) noexcept
| Move assignment. More...
| operator handle_type () const
| Auto-typecasting operator. More...
handle_type *& | operator* () const
| Returns the object handle value when the object handle is a pointer to a value (class, struct, etc.). More...
handle_type * | operator& ()
| Returns the object handle reference. More...
handle_type | operator-> () const
| Provides object handle member access when the object handle is a pointer to a class or struct. More...
bool | operator! () const
| Tests if the object handle is INVAL. More...
bool | operator< (_In_opt_ handle_type h) const
| Is handle less than? More...
bool | operator<= (_In_opt_ handle_type h) const
| Is handle less than or equal to? More...
bool | operator>= (_In_opt_ handle_type h) const
| Is handle greater than or equal to? More...
bool | operator> (_In_opt_ handle_type h) const
| Is handle greater than? More...
bool | operator!= (_In_opt_ handle_type h) const
| Is handle not equal to? More...
bool | operator== (_In_opt_ handle_type h) const
| Is handle equal to? More...
void | attach (_In_opt_ handle_type h) noexcept
| Sets a new object handle for the class. More...
handle_type | detach ()
| Dismisses the object handle from this class. More...
void | free ()
| Destroys the object.

## Static Public Attributes
static const T | invalid = INVAL
| Invalid handle value.

## Protected Member Functions
virtual void | free_internal () noexcept=0
| Abstract member function that must be implemented by child classes to do the actual object destruction. More...

## Protected Attributes
handle_type | m_h
| Object handle.

## Detailed Description

template<class T, const T INVAL>
class winstd::handle< T, INVAL >

Base abstract template class to support generic object handle keeping.

It provides basic operators and methods common to all descendands of this class establishing a base to ease the replacement of native object handle type with classes in object-oriented approach.

## Constructor & Destructor Documentation

## ◆ handle() [1/2]

template<class T , const T INVAL>

winstd::handle< T, INVAL >::handle | ( | _In_opt_ handle_type | h | ) |
| inline noexcept

Initializes a new class instance with an already available object handle.

Parameters

  [in] | h | Initial object handle value

## ◆ handle() [2/2]

template<class T , const T INVAL>

winstd::handle< T, INVAL >::handle | ( | _Inout_ handle< handle_type, INVAL > && | h | ) |
| inline noexcept

Move constructor.

Parameters

  [in,out] | h | A rvalue reference of another object

## Member Function Documentation

## ◆ attach()

template<class T , const T INVAL>

void winstd::handle< T, INVAL >::attach | ( | _In_opt_ handle_type | h | ) |
| inline noexcept

Sets a new object handle for the class.

When the current object handle of the class is non-INVAL, the object is destroyed first.

Parameters

  [in] | h | New object handle

## ◆ detach()

template<class T , const T INVAL>

handle_type winstd::handle< T, INVAL >::detach | ( |  | ) |
| inline

Dismisses the object handle from this class.

Returns
  Object handle

## ◆ free_internal()

template<class T , const T INVAL>

virtual void winstd::handle< T, INVAL >::free_internal | ( |  | ) |
| protected pure virtual noexcept

Abstract member function that must be implemented by child classes to do the actual object destruction.

Implemented in winstd::com_obj< T >, winstd::bstr, winstd::cert_context, winstd::cert_chain_context, winstd::cert_store, winstd::crypt_prov, winstd::crypt_hash, winstd::crypt_key, winstd::eap_packet, winstd::event_provider, winstd::event_session, winstd::event_trace, winstd::gdi_handle< T >, winstd::dc, winstd::window_dc, winstd::sec_credentials, winstd::sec_context, winstd::setup_device_info_list, winstd::win_handle< INVALID >, winstd::win_handle< NULL >, winstd::win_handle< INVALID_HANDLE_VALUE >, winstd::library, winstd::find_file, winstd::heap, winstd::vmemory, winstd::reg_key, winstd::security_id, winstd::addrinfo, and winstd::wlan_handle.

## ◆ operator handle_type()

template<class T , const T INVAL>

winstd::handle< T, INVAL >::operator handle_type | ( |  | ) | const
| inline

Auto-typecasting operator.

Returns
  Object handle

## ◆ operator!()

template<class T , const T INVAL>

bool winstd::handle< T, INVAL >::operator! | ( |  | ) | const
| inline

Tests if the object handle is INVAL.

Returns
  - Non zero when object handle is INVAL;
  - Zero otherwise.

## ◆ operator!=()

template<class T , const T INVAL>

bool winstd::handle< T, INVAL >::operator!= | ( | _In_opt_ handle_type | h | ) | const
| inline

Is handle not equal to?

Parameters

  [in] | h | Object handle to compare against

Returns
  - Non zero when object handle is not equal to h;
  - Zero otherwise.

## ◆ operator&()

template<class T , const T INVAL>

handle_type * winstd::handle< T, INVAL >::operator& | ( |  | ) |
| inline

Returns the object handle reference.

Returns
  Object handle reference

## ◆ operator*()

template<class T , const T INVAL>

handle_type *& winstd::handle< T, INVAL >::operator* | ( |  | ) | const
| inline

Returns the object handle value when the object handle is a pointer to a value (class, struct, etc.).

Returns
  Object handle value

## ◆ operator->()

template<class T , const T INVAL>

handle_type winstd::handle< T, INVAL >::operator-> | ( |  | ) | const
| inline

Provides object handle member access when the object handle is a pointer to a class or struct.

Returns
  Object handle

## ◆ operator<()

template<class T , const T INVAL>

bool winstd::handle< T, INVAL >::operator< | ( | _In_opt_ handle_type | h | ) | const
| inline

Is handle less than?

Parameters

  [in] | h | Object handle to compare against

Returns
  - Non zero when object handle is less than h;
  - Zero otherwise.

## ◆ operator<=()

template<class T , const T INVAL>

bool winstd::handle< T, INVAL >::operator<= | ( | _In_opt_ handle_type | h | ) | const
| inline

Is handle less than or equal to?

Parameters

  [in] | h | Object handle to compare against

Returns
  - Non zero when object handle is less than or equal to h;
  - Zero otherwise.

## ◆ operator=() [1/2]

template<class T , const T INVAL>

handle< handle_type, INVAL > & winstd::handle< T, INVAL >::operator= | ( | _In_opt_ handle_type | h | ) |
| inline noexcept

Attaches already available object handle.

Parameters

  [in] | h | Object handle value

## ◆ operator=() [2/2]

template<class T , const T INVAL>

handle< handle_type, INVAL > & winstd::handle< T, INVAL >::operator= | ( | _Inout_ handle< handle_type, INVAL > && | h | ) |
| inline noexcept

Move assignment.

Parameters

  [in,out] | h | A rvalue reference of another object

## ◆ operator==()

template<class T , const T INVAL>

bool winstd::handle< T, INVAL >::operator== | ( | _In_opt_ handle_type | h | ) | const
| inline

Is handle equal to?

Parameters

  [in] | h | Object handle to compare against

Returns
  - Non zero when object handle is equal to h;
  - Zero otherwise.

## ◆ operator>()

template<class T , const T INVAL>

bool winstd::handle< T, INVAL >::operator> | ( | _In_opt_ handle_type | h | ) | const
| inline

Is handle greater than?

Parameters

  [in] | h | Object handle to compare against

Returns
  - Non zero when object handle is greater than h;
  - Zero otherwise.

## ◆ operator>=()

template<class T , const T INVAL>

bool winstd::handle< T, INVAL >::operator>= | ( | _In_opt_ handle_type | h | ) | const
| inline

Is handle greater than or equal to?

Parameters

  [in] | h | Object handle to compare against

Returns
  - Non zero when object handle is greater than or equal to h;
  - Zero otherwise.

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

- include/WinStd/Common.h