2 * Copyright (C) 2003-2006 Gabest
3 * http://www.gabest.org
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GNU Make; see the file COPYING. If not, write to
17 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 * http://www.gnu.org/copyleft/gpl.html
24 #include "Exception.h"
32 enum encoding_t
{none
, unknown
, utf8
, utf16le
, utf16be
, wchar
};
36 encoding_t m_encoding
;
42 static bool IsWhiteSpace(int c
, LPCWSTR morechars
= NULL
);
44 void ThrowError(LPCTSTR fmt
, ...);
47 class InputStream
: public Stream
49 CAtlList
<int> m_queue
;
50 int PushChar(), PopChar();
55 virtual int NextByte() = 0;
61 int PeekChar(), GetChar();
63 int SkipWhiteSpace(LPCWSTR morechars
= NULL
);
66 class FileInputStream
: public InputStream
74 FileInputStream(const TCHAR
* fn
);
78 class MemoryInputStream
: public InputStream
88 MemoryInputStream(BYTE
* pBytes
, int len
, bool fCopy
, bool fFree
);
92 class WCharInputStream
: public InputStream
101 WCharInputStream(CStringW str
);
104 class OutputStream
: public Stream
109 virtual void NextByte(int b
) = 0;
112 OutputStream(encoding_t e
);
113 virtual ~OutputStream();
115 void PutChar(WCHAR c
);
116 void PutString(LPCWSTR fmt
, ...);
119 class WCharOutputStream
: public OutputStream
124 void NextByte(int b
);
129 const CStringW
& GetString() {return m_str
;}
132 class DebugOutputStream
: public OutputStream
137 void NextByte(int b
);
141 ~DebugOutputStream();