WinStd
Additional templates and function helpers for Microsoft Windows using Standard C++ classes
Classes | Macros | Typedefs | Functions
Common.h File Reference

General API. More...

#include <Windows.h>
#include <assert.h>
#include <stdarg.h>
#include <tchar.h>
#include <iostream>
#include <memory>
#include <stdexcept>
#include <string>
#include <vector>

Go to the source code of this file.

Classes

struct  winstd::LocalFree_delete< _Ty >
 Deleter for unique_ptr using LocalFree. More...
 
struct  winstd::LocalFree_delete< _Ty[]>
 Deleter for unique_ptr to array of unknown size using LocalFree. More...
 
class  winstd::ref_unique_ptr< _Ty, _Dx >
 Helper class for returning pointers to std::unique_ptr. More...
 
class  winstd::ref_unique_ptr< _Ty[], _Dx >
 Helper class for returning pointers to std::unique_ptr (specialization for arrays) More...
 
class  winstd::handle< T, INVAL >
 Base abstract template class to support generic object handle keeping. More...
 
class  winstd::dplhandle< T, INVAL >
 Base abstract template class to support object handle keeping for objects that support trivial handle duplication. More...
 
class  winstd::num_runtime_error< _Tn >
 Numerical runtime error. More...
 
class  winstd::win_runtime_error
 Windows runtime error. More...
 
class  winstd::basic_string_printf< _Elem, _Traits, _Ax >
 Base template class to support string formatting using printf() style templates. More...
 
class  winstd::basic_string_msg< _Elem, _Traits, _Ax >
 Base template class to support string formatting using FormatMessage() style templates. More...
 
class  winstd::basic_string_guid< _Elem, _Traits, _Ax >
 Base template class to support converting GUID to string. More...
 
class  winstd::string_guid
 Single-byte character implementation of a class to support converting GUID to string. More...
 
class  winstd::wstring_guid
 Wide character implementation of a class to support converting GUID to string. More...
 
class  winstd::sanitizing_allocator< _Ty >
 An allocator template that sanitizes each memory block before it is destroyed or reallocated. More...
 
struct  winstd::sanitizing_allocator< _Ty >::rebind< _Other >
 Convert this type to sanitizing_allocator<_Other> More...
 
class  winstd::sanitizing_blob< N >
 Sanitizing BLOB. More...
 

Macros

#define __L(x)   L ## x
 "L" stringizing macro
 
#define _L(x)   __L(x)
 Makes string Unicode.
 
#define WINSTD_STRING_IMPL(x)   #x
 Stringizing macro helper.
 
#define WINSTD_STRING(x)   WINSTD_STRING_IMPL(x)
 Stringizing macro.
 
#define WINSTD_NONCOPYABLE(C)
 Declares a class as non-copyable. More...
 
#define WINSTD_NONMOVABLE(C)
 Declares a class as non-movable. More...
 
#define WINSTD_STACK_BUFFER_BYTES   1024
 Size of the stack buffer in bytes used for initial system function call. More...
 
#define PRINTF_LPTSTR   "s"
 LPTSTR printf/scanf format specifier.
 
#define PRINTF_LPOLESTR   "ls"
 LPOLESTR printf/scanf format specifier.
 
#define _tcin   (std::cin )
 Standard input stream for TCHAR strings. More...
 
#define _tcout   (std::cout)
 Standard output stream for TCHAR strings.
 
#define _tcerr   (std::cerr)
 Standard error stream for TCHAR strings.
 
#define _tclog   (std::clog)
 Standard logging stream for TCHAR strings.
 
#define WINSTD_HANDLE_IMPL(C, INVAL)
 Implements default constructors and operators to prevent their auto-generation by compiler. More...
 
#define WINSTD_DPLHANDLE_IMPL(C, INVAL)
 Implements default constructors and operators to prevent their auto-generation by compiler. More...
 

Typedefs

typedef std::string winstd::tstring
 Multi-byte / Wide-character string (according to _UNICODE)
 
typedef basic_string_printf< char, std::char_traits< char >, std::allocator< char > > winstd::string_printf
 Single-byte character implementation of a class to support string formatting using printf() style templates.
 
typedef basic_string_printf< wchar_t, std::char_traits< wchar_t >, std::allocator< wchar_t > > winstd::wstring_printf
 Wide character implementation of a class to support string formatting using printf() style templates.
 
typedef string_printf winstd::tstring_printf
 Multi-byte / Wide-character formatted string (according to _UNICODE)
 
typedef basic_string_msg< char, std::char_traits< char >, std::allocator< char > > winstd::string_msg
 Single-byte character implementation of a class to support string formatting using FormatMessage() style templates.
 
typedef basic_string_msg< wchar_t, std::char_traits< wchar_t >, std::allocator< wchar_t > > winstd::wstring_msg
 Wide character implementation of a class to support string formatting using FormatMessage() style templates.
 
typedef string_msg winstd::tstring_msg
 Multi-byte / Wide-character formatted string (according to _UNICODE)
 
typedef string_guid winstd::tstring_guid
 Multi-byte / Wide-character string GUID (according to _UNICODE)
 
typedef std::basic_string< char, std::char_traits< char >, sanitizing_allocator< char > > winstd::sanitizing_string
 A sanitizing variant of std::string. More...
 
typedef std::basic_string< wchar_t, std::char_traits< wchar_t >, sanitizing_allocator< wchar_t > > winstd::sanitizing_wstring
 A sanitizing variant of std::wstring. More...
 
typedef sanitizing_string winstd::sanitizing_tstring
 Multi-byte / Wide-character sanitizing string (according to _UNICODE)
 

Functions

static int vsnprintf (char *str, size_t capacity, const char *format, va_list arg)
 Formats string using printf(). More...
 
static int vsnprintf (wchar_t *str, size_t capacity, const wchar_t *format, va_list arg) noexcept
 Formats string using printf(). More...
 
template<class _Elem , class _Traits , class _Ax >
static int vsprintf (std::basic_string< _Elem, _Traits, _Ax > &str, const _Elem *format, va_list arg)
 Formats string using printf(). More...
 
template<class _Elem , class _Traits , class _Ax >
static int sprintf (std::basic_string< _Elem, _Traits, _Ax > &str, const _Elem *format,...)
 Formats string using printf(). More...
 
template<class _Traits , class _Ax >
static DWORD FormatMessage (DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, std::basic_string< char, _Traits, _Ax > &str, va_list *Arguments)
 Formats a message string. More...
 
template<class _Traits , class _Ax >
static DWORD FormatMessage (DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, std::basic_string< wchar_t, _Traits, _Ax > &str, va_list *Arguments)
 Formats a message string. More...
 
template<class _Ty , class _Dx >
ref_unique_ptr< _Ty, _Dx > winstd::get_ptr (std::unique_ptr< _Ty, _Dx > &owner) noexcept
 Helper function template for returning pointers to std::unique_ptr. More...
 
template<class _Ty , class _Dx >
ref_unique_ptr< _Ty[], _Dx > winstd::get_ptr (std::unique_ptr< _Ty[], _Dx > &owner) noexcept
 Helper function template for returning pointers to std::unique_ptr (specialization for arrays) More...
 

Detailed Description

General API.