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 /// Creates a docstring from a C string of ASCII characters
23 docstring const from_ascii(char const *);
25 /// Creates a docstring from a std::string of ASCII characters
26 docstring const from_ascii(std::string const &);
28 /// Creates a std::string of ASCII characters from a docstring
29 std::string const to_ascii(docstring const &);
31 /// Creates a docstring from a UTF8 string. This should go eventually.
32 docstring const from_utf8(std::string const &);
34 /// Creates a UTF8 string from a docstring. This should go eventually.
35 std::string const to_utf8(docstring const &);
37 /// convert \p s from the encoding of the locale to ucs4.
38 docstring const from_local8bit(std::string const & s);
41 * Convert \p s from ucs4 to the encoding of the locale.
42 * This may fail and throw an exception, the caller is expected to act
45 std::string const to_local8bit(docstring const & s);
47 /// convert \p s from the encoding of the file system to ucs4.
48 docstring const from_filesystem8bit(std::string const & s);
50 /// convert \p s from ucs4 to the encoding of the file system.
51 std::string const to_filesystem8bit(docstring const & s);
53 /// convert \p s from ucs4 to the \p encoding.
54 std::string const to_iconv_encoding(docstring const & s,
55 std::string const & encoding);
57 /// convert \p s from \p encoding to ucs4.
58 docstring const from_iconv_encoding(std::string const & s,
59 std::string const & encoding);
61 /// normalize \p s to precomposed form c
62 docstring const normalize_c(docstring const & s);
64 /// Compare a docstring with a C string of ASCII characters
65 bool operator==(docstring const &, char const *);
67 /// Compare a C string of ASCII characters with a docstring
68 inline bool operator==(char const * l, docstring const & r) { return r == l; }
70 /// Compare a docstring with a C string of ASCII characters
71 inline bool operator!=(docstring const & l, char const * r) { return !(l == r); }
73 /// Compare a C string of ASCII characters with a docstring
74 inline bool operator!=(char const * l, docstring const & r) { return !(r == l); }
76 /// Concatenate a docstring and a C string of ASCII characters
77 docstring operator+(docstring const &, char const *);
79 /// Concatenate a C string of ASCII characters and a docstring
80 docstring operator+(char const *, docstring const &);
82 /// Concatenate a docstring and a single ASCII character
83 docstring operator+(docstring const & l, char r);
85 /// Concatenate a single ASCII character and a docstring
86 docstring operator+(char l, docstring const & r);
88 /// Append a C string of ASCII characters to a docstring
89 docstring & operator+=(docstring &, char const *);
91 /// Append a single ASCII character to a docstring
92 docstring & operator+=(docstring & l, char r);