File: outputdebugstream.hpp

package info (click to toggle)
consensuscore 1.1.1%2Bdfsg-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,492 kB
  • sloc: cpp: 38,945; python: 2,083; ansic: 543; sh: 184; makefile: 91; cs: 10
file content (49 lines) | stat: -rw-r--r-- 1,102 bytes parent folder | download | duplicates (6)
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
49
#pragma once
#ifndef _OUTPUT_DEBUG_STREAM_H
#define _OUTPUT_DEBUG_STREAM_H

#define NOMINMAX
#include <windows.h>
#undef DELETE

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