WinStd
Windows Win32 API using Standard C++
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Functions
String Formatting

Classes

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...
 

Macros

#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.
 
#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.
 

Typedefs

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)
 

Functions

template<class _Traits , class _Ax >
static int vsprintf (std::basic_string< char, _Traits, _Ax > &str, const char *format, va_list arg)
 Formats string using printf().
 
template<class _Traits , class _Ax >
static int vsprintf (std::basic_string< wchar_t, _Traits, _Ax > &str, const wchar_t *format, va_list arg)
 Formats string using printf().
 
template<class _Elem , class _Traits , class _Ax >
static int sprintf (std::basic_string< _Elem, _Traits, _Ax > &str, const _Elem *format,...)
 Formats string using printf().
 
template<class _Traits , class _Ax >
static int WideCharToMultiByte (UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int cchWideChar, std::basic_string< char, _Traits, _Ax > &sMultiByteStr, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar) noexcept
 Maps a UTF-16 (wide character) string to a std::string. The new character string is not necessarily from a multibyte character set.
 
template<class _Ax >
static int WideCharToMultiByte (UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int cchWideChar, std::vector< char, _Ax > &sMultiByteStr, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar) noexcept
 Maps a UTF-16 (wide character) string to a std::vector. The new character vector is not necessarily from a multibyte character set.
 
template<class _Traits1 , class _Ax1 , class _Traits2 , class _Ax2 >
static int WideCharToMultiByte (UINT CodePage, DWORD dwFlags, std::basic_string< wchar_t, _Traits1, _Ax1 > sWideCharStr, std::basic_string< char, _Traits2, _Ax2 > &sMultiByteStr, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar) noexcept
 Maps a UTF-16 (wide character) string to a std::string. The new character string is not necessarily from a multibyte character set.
 
template<class _Traits , class _Ax >
static int SecureWideCharToMultiByte (UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int cchWideChar, std::basic_string< char, _Traits, _Ax > &sMultiByteStr, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar) noexcept
 Maps a UTF-16 (wide character) string to a std::string. The new character string is not necessarily from a multibyte character set.
 
template<class _Ax >
static int SecureWideCharToMultiByte (UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int cchWideChar, std::vector< char, _Ax > &sMultiByteStr, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar) noexcept
 Maps a UTF-16 (wide character) string to a std::vector. The new character vector is not necessarily from a multibyte character set.
 
template<class _Traits1 , class _Ax1 , class _Traits2 , class _Ax2 >
static int SecureWideCharToMultiByte (UINT CodePage, DWORD dwFlags, std::basic_string< wchar_t, _Traits1, _Ax1 > sWideCharStr, std::basic_string< char, _Traits2, _Ax2 > &sMultiByteStr, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar) noexcept
 Maps a UTF-16 (wide character) string to a std::string. The new character string is not necessarily from a multibyte character set.
 
template<class _Traits , class _Ax >
static int MultiByteToWideChar (UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr, int cbMultiByte, std::basic_string< wchar_t, _Traits, _Ax > &sWideCharStr) noexcept
 Maps a character string to a UTF-16 (wide character) std::wstring. The character string is not necessarily from a multibyte character set.
 
template<class _Ax >
static int MultiByteToWideChar (UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr, int cbMultiByte, std::vector< wchar_t, _Ax > &sWideCharStr) noexcept
 Maps a character string to a UTF-16 (wide character) std::vector. The character vector is not necessarily from a multibyte character set.
 
template<class _Traits1 , class _Ax1 , class _Traits2 , class _Ax2 >
static int MultiByteToWideChar (UINT CodePage, DWORD dwFlags, const std::basic_string< char, _Traits1, _Ax1 > &sMultiByteStr, std::basic_string< wchar_t, _Traits2, _Ax2 > &sWideCharStr) noexcept
 Maps a character string to a UTF-16 (wide character) std::wstring. The character string is not necessarily from a multibyte character set.
 
template<class _Traits , class _Ax >
static int SecureMultiByteToWideChar (UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr, int cbMultiByte, std::basic_string< wchar_t, _Traits, _Ax > &sWideCharStr) noexcept
 Maps a character string to a UTF-16 (wide character) std::wstring. The character string is not necessarily from a multibyte character set.
 
template<class _Ax >
static int SecureMultiByteToWideChar (UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr, int cbMultiByte, std::vector< wchar_t, _Ax > &sWideCharStr) noexcept
 Maps a character string to a UTF-16 (wide character) std::vector. The character vector is not necessarily from a multibyte character set.
 
template<class _Traits1 , class _Ax1 , class _Traits2 , class _Ax2 >
static int SecureMultiByteToWideChar (UINT CodePage, DWORD dwFlags, const std::basic_string< char, _Traits1, _Ax1 > &sMultiByteStr, std::basic_string< wchar_t, _Traits2, _Ax2 > &sWideCharStr) noexcept
 Maps a character string to a UTF-16 (wide character) std::wstring. The character string is not necessarily from a multibyte character set.
 
template<class _Traits , class _Ax >
static DWORD FormatMessageA (DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, std::basic_string< char, _Traits, _Ax > &str, va_list *Arguments)
 Formats a message string.
 
template<class _Traits , class _Ax >
static DWORD FormatMessageW (DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, std::basic_string< wchar_t, _Traits, _Ax > &str, va_list *Arguments)
 Formats a message string.
 

Detailed Description

Example
// Please note the PCSTR typecasting invokes an operator to return
// pointer to formatted buffer rather than class reference itself.
cout << (PCSTR)(winstd::string_printf("%i is less than %i.\n", 1, 5));
Helper class for returning pointers to std::unique_ptr.
Definition Common.h:863

Macro Definition Documentation

◆ _tcin

#define _tcin   (std::cin )

Standard input stream for TCHAR strings.

Standard input stream for TCHAR strings

Function Documentation

◆ FormatMessageA()

template<class _Traits , class _Ax >
static DWORD FormatMessageA ( DWORD dwFlags,
LPCVOID lpSource,
DWORD dwMessageId,
DWORD dwLanguageId,
std::basic_string< char, _Traits, _Ax > & str,
va_list * Arguments )
static

Formats a message string.

See also
FormatMessage function

◆ FormatMessageW()

template<class _Traits , class _Ax >
static DWORD FormatMessageW ( DWORD dwFlags,
LPCVOID lpSource,
DWORD dwMessageId,
DWORD dwLanguageId,
std::basic_string< wchar_t, _Traits, _Ax > & str,
va_list * Arguments )
static

Formats a message string.

See also
FormatMessage function

◆ MultiByteToWideChar() [1/3]

template<class _Traits1 , class _Ax1 , class _Traits2 , class _Ax2 >
static int MultiByteToWideChar ( UINT CodePage,
DWORD dwFlags,
const std::basic_string< char, _Traits1, _Ax1 > & sMultiByteStr,
std::basic_string< wchar_t, _Traits2, _Ax2 > & sWideCharStr )
staticnoexcept

Maps a character string to a UTF-16 (wide character) std::wstring. The character string is not necessarily from a multibyte character set.

See also
MultiByteToWideChar function

◆ MultiByteToWideChar() [2/3]

template<class _Traits , class _Ax >
static int MultiByteToWideChar ( UINT CodePage,
DWORD dwFlags,
LPCSTR lpMultiByteStr,
int cbMultiByte,
std::basic_string< wchar_t, _Traits, _Ax > & sWideCharStr )
staticnoexcept

Maps a character string to a UTF-16 (wide character) std::wstring. The character string is not necessarily from a multibyte character set.

See also
MultiByteToWideChar function

◆ MultiByteToWideChar() [3/3]

template<class _Ax >
static int MultiByteToWideChar ( UINT CodePage,
DWORD dwFlags,
LPCSTR lpMultiByteStr,
int cbMultiByte,
std::vector< wchar_t, _Ax > & sWideCharStr )
staticnoexcept

Maps a character string to a UTF-16 (wide character) std::vector. The character vector is not necessarily from a multibyte character set.

See also
MultiByteToWideChar function

◆ SecureMultiByteToWideChar() [1/3]

template<class _Traits1 , class _Ax1 , class _Traits2 , class _Ax2 >
static int SecureMultiByteToWideChar ( UINT CodePage,
DWORD dwFlags,
const std::basic_string< char, _Traits1, _Ax1 > & sMultiByteStr,
std::basic_string< wchar_t, _Traits2, _Ax2 > & sWideCharStr )
staticnoexcept

Maps a character string to a UTF-16 (wide character) std::wstring. The character string is not necessarily from a multibyte character set.

Note
This function cleans all internal buffers using SecureZeroMemory() before returning.
See also
MultiByteToWideChar function

◆ SecureMultiByteToWideChar() [2/3]

template<class _Traits , class _Ax >
static int SecureMultiByteToWideChar ( UINT CodePage,
DWORD dwFlags,
LPCSTR lpMultiByteStr,
int cbMultiByte,
std::basic_string< wchar_t, _Traits, _Ax > & sWideCharStr )
staticnoexcept

Maps a character string to a UTF-16 (wide character) std::wstring. The character string is not necessarily from a multibyte character set.

Note
This function cleans all internal buffers using SecureZeroMemory() before returning.
See also
MultiByteToWideChar function

◆ SecureMultiByteToWideChar() [3/3]

template<class _Ax >
static int SecureMultiByteToWideChar ( UINT CodePage,
DWORD dwFlags,
LPCSTR lpMultiByteStr,
int cbMultiByte,
std::vector< wchar_t, _Ax > & sWideCharStr )
staticnoexcept

Maps a character string to a UTF-16 (wide character) std::vector. The character vector is not necessarily from a multibyte character set.

Note
This function cleans all internal buffers using SecureZeroMemory() before returning.
See also
MultiByteToWideChar function

◆ SecureWideCharToMultiByte() [1/3]

template<class _Traits , class _Ax >
static int SecureWideCharToMultiByte ( UINT CodePage,
DWORD dwFlags,
LPCWSTR lpWideCharStr,
int cchWideChar,
std::basic_string< char, _Traits, _Ax > & sMultiByteStr,
LPCSTR lpDefaultChar,
LPBOOL lpUsedDefaultChar )
staticnoexcept

Maps a UTF-16 (wide character) string to a std::string. The new character string is not necessarily from a multibyte character set.

Note
This function cleans all internal buffers using SecureZeroMemory() before returning.
See also
WideCharToMultiByte function

◆ SecureWideCharToMultiByte() [2/3]

template<class _Ax >
static int SecureWideCharToMultiByte ( UINT CodePage,
DWORD dwFlags,
LPCWSTR lpWideCharStr,
int cchWideChar,
std::vector< char, _Ax > & sMultiByteStr,
LPCSTR lpDefaultChar,
LPBOOL lpUsedDefaultChar )
staticnoexcept

Maps a UTF-16 (wide character) string to a std::vector. The new character vector is not necessarily from a multibyte character set.

Note
This function cleans all internal buffers using SecureZeroMemory() before returning.
See also
WideCharToMultiByte function

◆ SecureWideCharToMultiByte() [3/3]

template<class _Traits1 , class _Ax1 , class _Traits2 , class _Ax2 >
static int SecureWideCharToMultiByte ( UINT CodePage,
DWORD dwFlags,
std::basic_string< wchar_t, _Traits1, _Ax1 > sWideCharStr,
std::basic_string< char, _Traits2, _Ax2 > & sMultiByteStr,
LPCSTR lpDefaultChar,
LPBOOL lpUsedDefaultChar )
staticnoexcept

Maps a UTF-16 (wide character) string to a std::string. The new character string is not necessarily from a multibyte character set.

Note
This function cleans all internal buffers using SecureZeroMemory() before returning.
See also
WideCharToMultiByte function

◆ sprintf()

template<class _Elem , class _Traits , class _Ax >
static int sprintf ( std::basic_string< _Elem, _Traits, _Ax > & str,
const _Elem * format,
... )
static

Formats string using printf().

Parameters
[out]strFormatted string
[in]formatString template using printf() style
Returns
Number of characters in result.

◆ vsprintf() [1/2]

template<class _Traits , class _Ax >
static int vsprintf ( std::basic_string< char, _Traits, _Ax > & str,
const char * format,
va_list arg )
static

Formats string using printf().

Parameters
[out]strFormatted string
[in]formatString template using printf() style
[in]argArguments to format
Returns
Number of characters in result.

◆ vsprintf() [2/2]

template<class _Traits , class _Ax >
static int vsprintf ( std::basic_string< wchar_t, _Traits, _Ax > & str,
const wchar_t * format,
va_list arg )
static

Formats string using printf().

Parameters
[out]strFormatted string
[in]formatString template using printf() style
[in]argArguments to format
Returns
Number of characters in result.

◆ WideCharToMultiByte() [1/3]

template<class _Traits , class _Ax >
static int WideCharToMultiByte ( UINT CodePage,
DWORD dwFlags,
LPCWSTR lpWideCharStr,
int cchWideChar,
std::basic_string< char, _Traits, _Ax > & sMultiByteStr,
LPCSTR lpDefaultChar,
LPBOOL lpUsedDefaultChar )
staticnoexcept

Maps a UTF-16 (wide character) string to a std::string. The new character string is not necessarily from a multibyte character set.

See also
WideCharToMultiByte function

◆ WideCharToMultiByte() [2/3]

template<class _Ax >
static int WideCharToMultiByte ( UINT CodePage,
DWORD dwFlags,
LPCWSTR lpWideCharStr,
int cchWideChar,
std::vector< char, _Ax > & sMultiByteStr,
LPCSTR lpDefaultChar,
LPBOOL lpUsedDefaultChar )
staticnoexcept

Maps a UTF-16 (wide character) string to a std::vector. The new character vector is not necessarily from a multibyte character set.

See also
WideCharToMultiByte function

◆ WideCharToMultiByte() [3/3]

template<class _Traits1 , class _Ax1 , class _Traits2 , class _Ax2 >
static int WideCharToMultiByte ( UINT CodePage,
DWORD dwFlags,
std::basic_string< wchar_t, _Traits1, _Ax1 > sWideCharStr,
std::basic_string< char, _Traits2, _Ax2 > & sMultiByteStr,
LPCSTR lpDefaultChar,
LPBOOL lpUsedDefaultChar )
staticnoexcept

Maps a UTF-16 (wide character) string to a std::string. The new character string is not necessarily from a multibyte character set.

See also
WideCharToMultiByte function