OSDN Git Service

キャプチャ部分のバグ修正。
[winaudioj/wasapi2.git] / wasapi2 / dout.h
1 #pragma once\r
2 \r
3 /* http://vision.kuee.kyoto-u.ac.jp/~nob/doc/win32/win32.html#doc1_42 \r
4         \82æ\82è\94q\8eØ\r
5 */\r
6 \r
7 \r
8 #ifndef STDX_DSTREAM_H\r
9 \r
10 #define STDX_DSTREAM_H\r
11 \r
12 namespace sf\r
13 {\r
14 \r
15 #ifdef _DEBUG\r
16   \r
17 // VC++ \82Å STLport \82¾\82Æ using std::char_traits; \82Ý\82½\82¢\82È\82Ì\82ª\95K\97v\82©\82à\r
18 template <typename Ch_T, typename Tr_T = std::char_traits<Ch_T> >\r
19 class basic_dbg_streambuf: public std::basic_stringbuf<Ch_T, Tr_T>\r
20 {\r
21 public:\r
22   basic_dbg_streambuf()\r
23     {\r
24 #ifndef STDX_DSTREAM_BUFFERING\r
25       setbuf(0,0);\r
26 #endif\r
27     }\r
28 \r
29   virtual ~basic_dbg_streambuf()\r
30     {\r
31       sync();\r
32     }\r
33 \r
34 protected:\r
35   int sync(void)\r
36     {\r
37       dbg_out(str().c_str());\r
38       pbump(static_cast<int>(pbase() - pptr()));\r
39       return 0;\r
40     }\r
41 \r
42   void dbg_out(const Ch_T*);\r
43 };\r
44 \r
45 template <>\r
46 inline void basic_dbg_streambuf<char>::dbg_out(const char *str)\r
47 {\r
48   ::OutputDebugStringA(str);\r
49 }\r
50 \r
51 template <>\r
52 inline void basic_dbg_streambuf<wchar_t>::dbg_out(const wchar_t *str)\r
53 {\r
54   ::OutputDebugStringW(str);\r
55 }\r
56 \r
57 template <typename Ch_T, typename Tr_T = std::char_traits<Ch_T> >\r
58 class basic_dbg_ostream: public std::basic_ostream<Ch_T, Tr_T>\r
59 {\r
60 public:\r
61   basic_dbg_ostream() : std::basic_ostream<Ch_T, Tr_T>(new basic_dbg_streambuf<Ch_T, Tr_T>())\r
62     {\r
63     }\r
64 \r
65   virtual ~basic_dbg_ostream()\r
66     {\r
67       // flush(); // \95s\97v\82ç\82µ\82¢\81Dhttp://www.tietew.jp/cppll/archive/607\r
68       delete rdbuf();\r
69     }\r
70 };\r
71 \r
72 typedef basic_dbg_streambuf<wchar_t>  wdbg_streambuf;\r
73 typedef basic_dbg_ostream<wchar_t> wdstream;\r
74 \r
75 // \82±\82ê\82ð\92è\8b`\82µ\82Ä\82¨\82­\82Æ\81C dout \82Ì\90é\8c¾\82ª\82¢\82ç\82È\82­\82È\82é\81D\r
76 \r
77 static wdstream wdout;\r
78 #define DOUT(x) wdout << x \r
79 }\r
80 #else\r
81 #define DOUT(x) \r
82 #define wdout //\r
83 //  struct dummy_wdout {\r
84 //    //template <typename R>\r
85 //    //inline dummy_wdout& operator<<(const R v) {return *this;};\r
86 //\r
87 //    //template <typename R>\r
88 //    //inline dummy_wdout& operator<<(const R* v) {return *this;};\r
89 //\r
90 //    //template <typename R>\r
91 //    //inline dummy_wdout& operator<<(const R& v) {return *this;};\r
92 //\r
93 //    //template <typename R>\r
94 //    //inline dummy_wdout& operator<<(const R&& v) {return *this;};\r
95 //\r
96 //    ////template <typename R,int N>\r
97 //    ////inline dummy_wdout& operator<<(const R(&a)[N]) {return *this;};\r
98 //\r
99 //  };\r
100 //\r
101 //  static dummy_wdout wdout;\r
102 //}\r
103 //\r
104 //template <typename L>\r
105 //inline sf::dummy_wdout& operator<<(sf::dummy_wdout& p,const L v) {return p;};\r
106 //\r
107 //template <typename L>\r
108 //inline sf::dummy_wdout& operator<<(sf::dummy_wdout& p,const L& v) {return p;};\r
109 //\r
110 //template <typename L>\r
111 //inline sf::dummy_wdout& operator<<(sf::dummy_wdout& p,const L&& v) {return p;};\r
112 //\r
113 ////template <typename L>\r
114 ////inline sf::dummy_wdout& operator<<(sf::dummy_wdout& p,const L* v) {return p;};\r
115 //\r
116 //template <typename L,int N>\r
117 //inline sf::dummy_wdout& operator<<(sf::dummy_wdout& p,const L(&a)[N]) {return p;};\r
118 //\r
119 //template <typename L>\r
120 //inline L& operator<<(const L v,sf::dummy_wdout& p) {return v;};\r
121 //\r
122 //template <typename L>\r
123 //inline L& operator<<(sf::dummy_wdout& p,L v) {return v;};\r
124 //\r
125 //\r
126 //template <typename L>\r
127 //inline sf::dummy_wdout& operator<<(const L v,sf::dummy_wdout& p) {return p;};\r
128 //\r
129 //template <typename L>\r
130 //inline sf::dummy_wdout& operator<<(const L& v,sf::dummy_wdout& p) {return p;};\r
131 //\r
132 ////template <typename L>\r
133 ////inline sf::dummy_wdout& operator<<(const L* v,sf::dummy_wdout& p) {return p;};\r
134 //\r
135 //template <typename L>\r
136 //inline sf::dummy_wdout& operator<<(const L&& v,sf::dummy_wdout& p) {return p;};\r
137 //\r
138 //\r
139 //template <typename L,int N>\r
140 //inline sf::dummy_wdout& operator<<(const L(&a)[N],sf::dummy_wdout& p) {return p;};\r
141 ////\r
142 //template <typename L>\r
143 //inline sf::dummy_wdout& operator<<(sf::dummy_wdout& p , const L *v) {return p;};\r
144 \r
145 //\r
146 }\r
147 #endif\r
148 #endif // STDX_DSTREAM_