]> git.lyx.org Git - lyx.git/blob - src/support/strfwd.h
Always forward declare string as it is not guaranteed that the
[lyx.git] / src / support / strfwd.h
1 // -*- C++ -*-
2 /**
3  * \file strfwd.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author André Pönitz
8  * \author Enrico Forestieri
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef STRFWD_H
14 #define STRFWD_H
15
16 #ifdef USE_WCHAR_T
17
18 // Prefer this if possible because GNU libstdc++ has usable
19 // std::ctype<wchar_t> locale facets but not
20 // std::ctype<boost::uint32_t>. gcc older than 3.4 is also missing
21 // usable std::char_traits<boost::uint32_t>.
22 namespace lyx { typedef wchar_t char_type; }
23
24 #else
25
26 #include <boost/cstdint.hpp>
27 namespace lyx { typedef boost::uint32_t char_type; }
28
29 #endif
30
31 #include <iosfwd>
32
33 // We have to forward declare the string type as not all compilers
34 // do that in the iosfwd header.
35 namespace std
36 {
37
38 template<typename Char, typename Traits, typename Alloc> class basic_string;
39 typedef basic_string<char, char_traits<char>, allocator<char> > string;
40
41 }
42
43 namespace lyx {
44
45 /// String type for storing the main text in UCS4 encoding
46 typedef std::basic_string<char_type, std::char_traits<char_type>,
47         std::allocator<char_type> > docstring;
48
49 /// Base class for UCS4 input streams
50 typedef std::basic_istream<char_type> idocstream;
51
52 /// Base class for UCS4 output streams
53 typedef std::basic_ostream<char_type> odocstream;
54
55 #if ! defined(USE_WCHAR_T)
56 extern odocstream & operator<<(odocstream &, char);
57 #endif
58
59 } // namespace lyx
60
61 #endif