4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
10 * Full author contact details are available in file CREDITS.
13 #ifndef LYX_DOCSTRING_H
14 #define LYX_DOCSTRING_H
16 #include "support/strfwd.h"
22 /// String type for storing the main text in UCS4 encoding
23 typedef std::basic_string<char_type> docstring;
28 #if ! defined(USE_WCHAR_T) && defined(__GNUC__) && defined(__GNUC_MINOR__) && __GNUC__ == 3 && __GNUC_MINOR__ < 4
29 // Missing char_traits methods in gcc 3.3 and older. Taken from gcc 4.2svn.
32 template<typename T> void
33 char_traits<T>::assign(char_type & c1, char_type const & c2)
39 template<typename T> bool
40 char_traits<T>::eq(char_type const & c1, char_type const & c2)
46 template<typename T> bool
47 char_traits<T>::lt(char_type const & c1, char_type const & c2)
53 template<typename T> int
54 char_traits<T>::compare(char_type const * s1, char_type const * s2, std::size_t n)
56 for (std::size_t i = 0; i < n; ++i)
59 else if (lt(s2[i], s1[i]))
65 template<typename T> std::size_t
66 char_traits<T>::length(char_type const * p)
69 while (!eq(p[i], char_type()))
75 template<typename T> typename char_traits<T>::char_type const *
76 char_traits<T>::find(char_type const * s, size_t n, char_type const & a)
78 for (std::size_t i = 0; i < n; ++i)
85 template<typename T> typename char_traits<T>::char_type *
86 char_traits<T>::move(char_type * s1, char_type const * s2, std::size_t n)
88 return static_cast<T *>(std::memmove(s1, s2, n * sizeof(char_type)));
92 template<typename T> typename char_traits<T>::char_type *
93 char_traits<T>::copy(char_type * s1, char_type const * s2, std::size_t n)
95 std::copy(s2, s2 + n, s1);
100 template<typename T> typename char_traits<T>::char_type *
101 char_traits<T>::assign(char_type * s, std::size_t n, char_type a)
103 std::fill_n(s, n, a);
108 template<typename T> typename char_traits<T>::char_type
109 char_traits<T>::to_char_type(int_type const & c)
111 return static_cast<char_type>(c);
115 template<typename T> typename char_traits<T>::int_type
116 char_traits<T>::to_int_type(char_type const & c)
118 return static_cast<int_type>(c);
122 template<typename T> bool
123 char_traits<T>::eq_int_type(int_type const & c1, int_type const & c2)
129 template<typename T> typename char_traits<T>::int_type
130 char_traits<T>::eof()
132 return static_cast<int_type>(EOF);
136 template<typename T> typename char_traits<T>::int_type
137 char_traits<T>::not_eof(int_type const & c)
139 return !eq_int_type(c, eof()) ? c : to_int_type(char_type());