]> git.lyx.org Git - lyx.git/blob - src/support/strfwd.h
94f2136403c121d25bf09ebd94eeb199426a2322
[lyx.git] / src / support / strfwd.h
1 // -*- C++ -*-
2
3 // Heavily inspired by /usr/include/c++/4.1/bits
4 //
5 // Copyright (C) 2001, 2002 Free Software Foundation, Inc.
6 //
7 // This file is part of the GNU ISO C++ Library.  This library is free
8 // software; you can redistribute it and/or modify it under the
9 // terms of the GNU General Public License as published by the
10 // Free Software Foundation; either version 2, or (at your option)
11 // any later version.
12
13 #ifndef STRFWD_H
14 #define STRFWD_H
15
16 // This includes does nothing but defining _LIBCPP_VERSION
17 // if libc++ is used (rather than libstdc++) - we first
18 // check if we have at least a c++03 standard before
19 // including the file
20 #if (__cplusplus > 199711L)
21 #include <ciso646>
22 #endif
23
24 #ifdef USE_WCHAR_T
25
26 // Prefer this if possible because GNU libstdc++ has usable
27 // std::ctype<wchar_t> locale facets but not
28 // std::ctype<boost::uint32_t>. gcc older than 3.4 is also missing
29 // usable std::char_traits<boost::uint32_t>.
30 namespace lyx { typedef wchar_t char_type; }
31
32 #else
33
34 #include <boost/cstdint.hpp>
35 namespace lyx { typedef boost::uint32_t char_type; }
36
37 #endif
38
39 // Forward definitions do not work with libc++
40 #ifdef  _LIBCPP_VERSION
41 #include <string>
42 #else
43
44 namespace std {
45
46 template<typename Alloc> class allocator;
47
48 template<typename Char> struct char_traits;
49 template<> struct char_traits<char>;
50 #ifdef USE_WCHAR_T
51 template<> struct char_traits<wchar_t>;
52 #endif
53
54 template<typename Char, typename Traits, typename Alloc> class basic_string;
55 typedef basic_string<char, char_traits<char>, allocator<char> > string;
56
57 template<class Char, class Traits> class basic_istream;
58 template<class Char, class Traits> class basic_ostream;
59 template<class Char, class Traits, class Allocator> class basic_ostringstream;
60
61 typedef basic_istream<char, char_traits<char> > istream;
62 typedef basic_ostream<char, char_traits<char> > ostream;
63 typedef basic_ostringstream<char, char_traits<char>, allocator<char> > ostringstream;
64
65 } // namepace std
66
67 #endif
68
69 namespace lyx {
70
71 /**
72  * String type for storing the main text in UCS4 encoding.
73  * Use std::string only in cases 7-bit ASCII is to be manipulated
74  * within the variable.
75  */
76 typedef std::basic_string<char_type, std::char_traits<char_type>,
77         std::allocator<char_type> > docstring;
78
79 /// Base class for UCS4 input streams
80 typedef std::basic_istream<char_type, std::char_traits<char_type> > idocstream;
81
82 /// Base class for UCS4 output streams
83 typedef std::basic_ostream<char_type, std::char_traits<char_type> > odocstream;
84
85 /// UCS4 output stringstream
86 typedef std::basic_ostringstream<char_type, std::char_traits<char_type>, std::allocator<char_type> > odocstringstream;
87
88 #if ! defined(USE_WCHAR_T)
89 extern odocstream & operator<<(odocstream &, char);
90 #endif
91
92 // defined in lstrings.cpp
93 docstring const & empty_docstring();
94 std::string const & empty_string();
95 // defined in docstring.cpp
96 bool operator==(docstring const &, char const *);
97
98 #ifdef STD_STRING_USES_COW
99 template<typename Char> class trivial_string;
100 typedef trivial_string<char> trivstring;
101 typedef trivial_string<char_type> trivdocstring;
102 #else
103 typedef std::string trivstring;
104 typedef docstring trivdocstring;
105 #endif
106
107 } // namespace lyx
108
109 #endif