diff --git a/include/WinStd/Common.h b/include/WinStd/Common.h index 336205fa..78cce066 100644 --- a/include/WinStd/Common.h +++ b/include/WinStd/Common.h @@ -114,6 +114,60 @@ inline int vsprintf(_Out_ std::basic_string<_Elem, _Traits, _Ax> &str, _In_z_ _P #pragma warning(pop) +/// +/// Formats and sends a string to the debugger for display. +/// +/// \sa [OutputDebugString function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363362.aspx) +/// +inline VOID OutputDebugStrV(_In_ LPCSTR lpOutputString, _In_ va_list arg) +{ + std::string str; + vsprintf(str, lpOutputString, arg); + OutputDebugStringA(str.c_str()); +} + + +/// +/// Formats and sends a string to the debugger for display. +/// +/// \sa [OutputDebugString function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363362.aspx) +/// +inline VOID OutputDebugStrV(_In_ LPCWSTR lpOutputString, _In_ va_list arg) +{ + std::wstring str; + vsprintf(str, lpOutputString, arg); + OutputDebugStringW(str.c_str()); +} + + +/// +/// Formats and sends a string to the debugger for display. +/// +/// \sa [OutputDebugString function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363362.aspx) +/// +inline VOID OutputDebugStr(_In_ LPCSTR lpOutputString, ...) +{ + va_list arg; + va_start(arg, lpOutputString); + OutputDebugStrV(lpOutputString, arg); + va_end(arg); +} + + +/// +/// Formats and sends a string to the debugger for display. +/// +/// \sa [OutputDebugString function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363362.aspx) +/// +inline VOID OutputDebugStr(_In_ LPCWSTR lpOutputString, ...) +{ + va_list arg; + va_start(arg, lpOutputString); + OutputDebugStrV(lpOutputString, arg); + va_end(arg); +} + + /// /// Formats string using `printf()`. /// @@ -525,6 +579,13 @@ namespace winstd typedef basic_string_printf, std::allocator> wstring_printf; +#ifdef _UNICODE + typedef wstring_printf tstring_printf; +#else + typedef string_printf tstring_printf; +#endif + + /// /// Base template class to support string formatting using `FormatMessage()` style templates /// @@ -591,16 +652,26 @@ namespace winstd /// @} }; + /// /// Single-byte character implementation of a class to support string formatting using `FormatMessage()` style templates /// typedef basic_string_msg, std::allocator > string_msg; + /// /// Wide character implementation of a class to support string formatting using `FormatMessage()` style templates /// typedef basic_string_msg, std::allocator > wstring_msg; + +#ifdef _UNICODE + typedef wstring_msg tstring_msg; +#else + typedef string_msg tstring_msg; +#endif + + /// @} /// \defgroup WinStdMemSanitize Auto-sanitize Memory Management