4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
12 #ifndef LYX_DOCSTREAM_H
13 #define LYX_DOCSTREAM_H
15 #include "support/docstring.h"
22 class iconv_codecvt_facet_exception : public std::exception {
24 virtual ~iconv_codecvt_facet_exception() throw() {}
25 virtual const char * what() const throw();
28 /// Base class for UCS4 input streams
29 typedef std::basic_istream<char_type> idocstream;
31 /** Base class for UCS4 output streams.
32 If you want to output a single UCS4 character, use \code
36 \endcode . The latter will not output the character, but the code point
37 as number. This is because we can't overload operator<< (our character
38 type is not a real type but a typedef). Narrow characters of type char
39 can be output as usual.
41 typedef std::basic_ostream<char_type> odocstream;
43 /// File stream for reading UTF8-encoded files with automatic conversion to
45 class idocfstream : public std::basic_ifstream<char_type> {
46 typedef std::basic_ifstream<char_type> base;
49 explicit idocfstream(const char* s,
50 std::ios_base::openmode mode = std::ios_base::in);
54 /// File stream for writing files in 8bit encoding \p encoding with automatic
55 /// conversion from UCS4.
56 class odocfstream : public std::basic_ofstream<char_type> {
57 typedef std::basic_ofstream<char_type> base;
59 odocfstream(std::string const & encoding = "UTF-8");
60 explicit odocfstream(const char* s,
61 std::ios_base::openmode mode = std::ios_base::out|std::ios_base::trunc,
62 std::string const & encoding = "UTF-8");
66 /// UCS4 input stringstream
67 typedef std::basic_istringstream<char_type> idocstringstream;
69 /// UCS4 output stringstream
70 typedef std::basic_ostringstream<char_type> odocstringstream;
73 odocstream & operator<<(odocstream & os, char c)