3 // Heavily inspired by /usr/include/c++/4.1/bits
5 // Copyright (C) 2001, 2002 Free Software Foundation, Inc.
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)
18 template<typename Char> struct char_traits;
19 template<> struct char_traits<char>;
20 template<> struct char_traits<wchar_t>;
22 template<typename Alloc> class allocator;
24 template<typename Char, typename Traits, typename Alloc> class basic_string;
26 typedef basic_string<char, char_traits<char>, allocator<char> > string;
33 // Prefer this if possible because GNU libstdc++ has usable
34 // std::ctype<wchar_t> locale facets but not
35 // std::ctype<boost::uint32_t>. gcc older than 3.4 is also missing
36 // usable std::char_traits<boost::uint32_t>.
37 namespace lyx { typedef wchar_t char_type; }
41 #include <boost/cstdint.hpp>
42 namepace lyx { typedef boost::uint32_t char_type; }
49 typedef std::basic_string<char_type, std::char_traits<char_type>,
50 std::allocator<char_type> > docstring;
52 /// Creates a docstring from a C string of ASCII characters
53 docstring const from_ascii(char const *);
55 /// Creates a docstring from a std::string of ASCII characters
56 docstring const from_ascii(std::string const &);
58 /// Creates a std::string of ASCII characters from a docstring
59 std::string const to_ascii(docstring const &);
61 /// Creates a docstring from a UTF8 string. This should go eventually.
62 docstring const from_utf8(std::string const &);
64 /// Creates a UTF8 string from a docstring. This should go eventually.
65 std::string const to_utf8(docstring const &);
67 /// convert \p s from the encoding of the locale to ucs4.
68 docstring const from_local8bit(std::string const & s);
71 * Convert \p s from ucs4 to the encoding of the locale.
72 * This may fail and throw an exception, the caller is expected to act
75 std::string const to_local8bit(docstring const & s);
77 /// convert \p s from the encoding of the file system to ucs4.
78 docstring const from_filesystem8bit(std::string const & s);
80 /// convert \p s from ucs4 to the encoding of the file system.
81 std::string const to_filesystem8bit(docstring const & s);
83 /// normalize \p s to precomposed form c
84 docstring const normalize_c(docstring const & s);
86 /// Compare a docstring with a C string of ASCII characters
87 bool operator==(docstring const &, char const *);
89 /// Compare a C string of ASCII characters with a docstring
90 inline bool operator==(char const * l, docstring const & r) { return r == l; }
92 /// Compare a docstring with a C string of ASCII characters
93 inline bool operator!=(docstring const & l, char const * r) { return !(l == r); }
95 /// Compare a C string of ASCII characters with a docstring
96 inline bool operator!=(char const * l, docstring const & r) { return !(r == l); }
98 /// Concatenate a docstring and a C string of ASCII characters
99 docstring operator+(docstring const &, char const *);
101 /// Concatenate a C string of ASCII characters and a docstring
102 docstring operator+(char const *, docstring const &);
104 /// Concatenate a docstring and a single ASCII character
105 docstring operator+(docstring const & l, char r);
107 /// Concatenate a single ASCII character and a docstring
108 docstring operator+(char l, docstring const & r);
110 /// Append a C string of ASCII characters to a docstring
111 docstring & operator+=(docstring &, char const *);
113 /// Append a single ASCII character to a docstring
114 docstring & operator+=(docstring & l, char r);