]> git.lyx.org Git - lyx.git/blob - src/support/strfwd.h
30e1c092f07675fe9104586c5adb09cacd0f1658
[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 #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 // Forward definitions do not work with libc++
32 // For gcc5 with the new std::string ABI forward declarations would work in
33 // principle, but I am not sure whether we want non-standard
34 // "namespace __cxx11" in our sources.
35 #if defined(USE_LLVM_LIBCPP) || defined(USE_GLIBCXX_CXX11_ABI)
36 #include <string>
37 #else
38
39 namespace std {
40
41 template<typename Alloc> class allocator;
42
43 template<typename Char> struct char_traits;
44 template<> struct char_traits<char>;
45 #ifdef USE_WCHAR_T
46 template<> struct char_traits<wchar_t>;
47 #endif
48
49 template<typename Char, typename Traits, typename Alloc> class basic_string;
50 typedef basic_string<char, char_traits<char>, allocator<char> > string;
51
52 template<class Char, class Traits> class basic_istream;
53 template<class Char, class Traits> class basic_ostream;
54 template<class Char, class Traits, class Allocator> class basic_ostringstream;
55
56 typedef basic_istream<char, char_traits<char> > istream;
57 typedef basic_ostream<char, char_traits<char> > ostream;
58 typedef basic_ostringstream<char, char_traits<char>, allocator<char> > ostringstream;
59
60 } // namepace std
61
62 #endif
63
64
65 // Ugly workaround for MSVC10 STL bug:
66 // std::numpunct has a hardcoded dllimport in definition, but we wanna it with 32 bit 
67 // so we can't import it and must define it but then the compiler complains.
68 #if defined(_MSC_VER) && (_MSC_VER >= 1600) 
69 #include "support/numpunct_lyx_char_type.h"
70 #endif
71
72
73 namespace lyx {
74
75 /**
76  * String type for storing the main text in UCS4 encoding.
77  * Use std::string only in cases 7-bit ASCII is to be manipulated
78  * within the variable.
79  */
80 typedef std::basic_string<char_type, std::char_traits<char_type>,
81         std::allocator<char_type> > docstring;
82
83 /// Base class for UCS4 input streams
84 typedef std::basic_istream<char_type, std::char_traits<char_type> > idocstream;
85
86 /// Base class for UCS4 output streams
87 typedef std::basic_ostream<char_type, std::char_traits<char_type> > odocstream;
88
89 /// UCS4 output stringstream
90 typedef std::basic_ostringstream<char_type, std::char_traits<char_type>, std::allocator<char_type> > odocstringstream;
91
92 #if ! defined(USE_WCHAR_T)
93 extern odocstream & operator<<(odocstream &, char);
94 #endif
95
96 // defined in lstrings.cpp
97 docstring const & empty_docstring();
98 std::string const & empty_string();
99 // defined in docstring.cpp
100 bool operator==(docstring const &, char const *);
101
102 #ifdef STD_STRING_USES_COW
103 template<typename Char> class trivial_string;
104 typedef trivial_string<char> trivstring;
105 typedef trivial_string<char_type> trivdocstring;
106 #else
107 typedef std::string trivstring;
108 typedef docstring trivdocstring;
109 #endif
110
111 } // namespace lyx
112
113 #endif