# WinStd: String Formatting

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

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

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

## 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));
  winstd::basic_string_printf
  Base template class to support string formatting using printf() style templates.
  Definition: Common.h:1115

## Macro Definition Documentation

## _tcin

#define _tcin (std::cin )

Standard input stream for TCHAR strings.

Standard input stream for TCHAR strings

## Function Documentation

## FormatMessage() [1/2]

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

static

Formats a message string.

See also
  FormatMessage function

## FormatMessage() [2/2]

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

static

Formats a message string.

See also
  FormatMessage 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] | str | Formatted string
  [in] | format | String template using `printf()` style

Returns
  Number of characters in result.

## vsnprintf() [1/2]

static int vsnprintf | ( | char * | str,
|  | size_t | capacity,
|  | const char * | format,
|  | va_list | arg
| ) |  |

static

Formats string using `printf()`.

Parameters

  [out] | str | Buffer to receive string
  [in] | capacity | Size of `str` in characters
  [in] | format | String template using `printf()` style
  [in] | arg | Arguments to `format`

Returns
  Number of characters in result.

## vsnprintf() [2/2]

static int vsnprintf | ( | wchar_t * | str,
|  | size_t | capacity,
|  | const wchar_t * | format,
|  | va_list | arg
| ) |  |

staticnoexcept

Formats string using `printf()`.

Parameters

  [out] | str | Buffer to receive string
  [in] | capacity | Size of `str` in characters
  [in] | format | String template using `printf()` style
  [in] | arg | Arguments to `format`

Returns
  Number of characters in result.

## vsprintf()

template<class _Elem , class _Traits , class _Ax >

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

static

Formats string using `printf()`.

Parameters

  [out] | str | Formatted string
  [in] | format | String template using `printf()` style
  [in] | arg | Arguments to `format`

Returns
  Number of characters in result.