4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * Provide a set of typedefs for commonly used things like sizes and
8 * indices wile trying to stay compatible with types used
9 * by the standard containers.
11 * \author André Pönitz
13 * Full author contact details are available in file CREDITS.
16 #ifndef LYX_DOCSTRING_H
17 #define LYX_DOCSTRING_H
19 #include <boost/cstdint.hpp>
24 typedef std::basic_string<boost::uint32_t> docstring;
29 #if defined(__GNUC__) && defined(__GNUC_MINOR__) && __GNUC__ == 3 && __GNUC_MINOR__ < 4
30 // Missing char_traits methods in gcc 3.3 and older. Taken from gcc 4.2svn.
33 template<typename T> void
34 char_traits<T>::assign(char_type & c1, char_type const & c2)
40 template<typename T> bool
41 char_traits<T>::eq(char_type const & c1, char_type const & c2)
47 template<typename T> bool
48 char_traits<T>::lt(char_type const & c1, char_type const & c2)
54 template<typename T> int
55 char_traits<T>::compare(char_type const * s1, char_type const * s2, std::size_t n)
57 for (std::size_t i = 0; i < n; ++i)
60 else if (lt(s2[i], s1[i]))
66 template<typename T> std::size_t
67 char_traits<T>::length(char_type const * p)
70 while (!eq(p[i], char_type()))
76 template<typename T> typename char_traits<T>::char_type const *
77 char_traits<T>::find(char_type const * s, size_t n, char_type const & a)
79 for (std::size_t i = 0; i < n; ++i)
86 template<typename T> typename char_traits<T>::char_type *
87 char_traits<T>::move(char_type * s1, char_type const * s2, std::size_t n)
89 return static_cast<T *>(std::memmove(s1, s2, n * sizeof(char_type)));
93 template<typename T> typename char_traits<T>::char_type *
94 char_traits<T>::copy(char_type * s1, char_type const * s2, std::size_t n)
96 std::copy(s2, s2 + n, s1);
101 template<typename T> typename char_traits<T>::char_type *
102 char_traits<T>::assign(char_type * s, std::size_t n, char_type a)
104 std::fill_n(s, n, a);
109 template<typename T> typename char_traits<T>::char_type
110 char_traits<T>::to_char_type(int_type const & c)
112 return static_cast<char_type>(c);
116 template<typename T> typename char_traits<T>::int_type
117 char_traits<T>::to_int_type(char_type const & c)
119 return static_cast<int_type>(c);
123 template<typename T> bool
124 char_traits<T>::eq_int_type(int_type const & c1, int_type const & c2)
130 template<typename T> typename char_traits<T>::int_type
131 char_traits<T>::eof()
133 return static_cast<int_type>(EOF);
137 template<typename T> typename char_traits<T>::int_type
138 char_traits<T>::not_eof(int_type const & c)
140 return !eq_int_type(c, eof()) ? c : to_int_type(char_type());