-
Notifications
You must be signed in to change notification settings - Fork 22
/
outputdebugstream.hpp
48 lines (39 loc) · 1.06 KB
/
outputdebugstream.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#pragma once
#ifndef _OUTPUT_DEBUG_STREAM_H
#define _OUTPUT_DEBUG_STREAM_H
#define NOMINMAX
#include <windows.h>
template <class _Elem>
class outputdebug_buf: public std::basic_stringbuf<_Elem>
{
private:
inline void output_debug_string(const _Elem* e);
public:
virtual int sync ( )
{
//outputdebug_buf<_Elem>::output_debug_string(std::basic_stringbuf<_Elem>::str().c_str());
this->output_debug_string(std::basic_stringbuf<_Elem>::str().c_str());
return 0;
}
};
template<>
inline void outputdebug_buf<char>::output_debug_string(const char* e)
{
::OutputDebugStringA(e);
}
template<>
inline void outputdebug_buf<wchar_t>::output_debug_string(const wchar_t* e)
{
::OutputDebugStringW(e);
}
template <class _Elem>
class outputdebug_stream: public std::basic_ostream<_Elem>
{
public:
outputdebug_stream() : std::basic_ostream<_Elem>(new outputdebug_buf<_Elem>())
{}
~outputdebug_stream(){ delete this->rdbuf(); }
};
typedef outputdebug_stream<char> dbgwin_stream;
typedef outputdebug_stream<wchar_t> wdbgwin_stream;
#endif