winapi_common
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
winapi::Handle Class Reference

HANDLE wrapper. More...

Inheritance diagram for winapi::Handle:
winapi::File

Public Member Functions

 Handle (HANDLE)
 
HANDLE get () const
 
HANDLE ptr () const
 
 operator HANDLE () const
 
bool is_valid () const
 
void close ()
 
bool is_std () const
 
Buffer read () const
 
bool read_chunk (Buffer &read_chunk) const
 
void write (const void *data, std::size_t nb) const
 
void write (const Buffer &buffer) const
 
template<typename CharT >
void write (const std::basic_string< CharT > &src) const
 
void inherit (bool yes=true) const
 
void dont_inherit () const
 

Static Public Member Functions

static bool is_valid (HANDLE)
 
static Handle std_in ()
 
static Handle std_out ()
 
static Handle std_err ()
 

Static Public Attributes

static constexpr std::size_t max_chunk_size = 16 * 1024
 

Detailed Description

HANDLE wrapper.

This class wraps HANDLE, allowing for painless reads and writes from a random handle.

Definition at line 25 of file handle.hpp.

Member Function Documentation

◆ close()

void winapi::Handle::close ( )

Close this handle.

Definition at line 47 of file handle.cpp.

◆ is_std()

bool winapi::Handle::is_std ( ) const

Check if this is a standard console handle.

Definition at line 51 of file handle.cpp.

◆ std_in()

Handle winapi::Handle::std_in ( )
static

Check if this is the stdin handle.

Definition at line 55 of file handle.cpp.

◆ std_out()

Handle winapi::Handle::std_out ( )
static

Check if this is the stdout handle.

Definition at line 59 of file handle.cpp.

◆ std_err()

Handle winapi::Handle::std_err ( )
static

Check if this is the stderr handle.

Definition at line 63 of file handle.cpp.

◆ read()

Buffer winapi::Handle::read ( ) const

Read everything from this handle.

Definition at line 93 of file handle.cpp.

◆ read_chunk()

bool winapi::Handle::read_chunk ( Buffer read_chunk) const

Read a chunk from this handle.

Parameters
read_chunkReceives the data read.
Returns
true if there's more data, false otherwise.

Definition at line 67 of file handle.cpp.

◆ write() [1/3]

void winapi::Handle::write ( const void *  data,
std::size_t  nb 
) const

Write data to this handle.

Parameters
dataPointer to binary data.
nbData size.

Definition at line 109 of file handle.cpp.

◆ write() [2/3]

void winapi::Handle::write ( const Buffer buffer) const

Write data to this handle.

Parameters
bufferBinary data to write.

Definition at line 125 of file handle.cpp.

◆ write() [3/3]

template<typename CharT >
void winapi::Handle::write ( const std::basic_string< CharT > &  src) const
inline

Write data to this handle.

Parameters
srcBinary data to write.

Definition at line 78 of file handle.hpp.


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