diff --git a/src/support/docstring.C b/src/support/docstring.C index fb3115ba9a..382612071a 100644 --- a/src/support/docstring.C +++ b/src/support/docstring.C @@ -68,3 +68,40 @@ bool operator==(lyx::docstring const & l, char const * r) } return r[len] == '\0'; } + + +lyx::docstring operator+(lyx::docstring const & l, char const * r) +{ + lyx::docstring s(l); + for (char const * c = r; *c; ++c) { + BOOST_ASSERT(static_cast(*c) < 0x80); + s.push_back(*c); + } + return s; +} + + +lyx::docstring operator+(char const * l, lyx::docstring const & r) +{ + lyx::docstring s; + for (char const * c = l; *c; ++c) { + BOOST_ASSERT(static_cast(*c) < 0x80); + s.push_back(*c); + } + s += r; + return s; +} + + +lyx::docstring operator+(lyx::docstring const & l, char r) +{ + BOOST_ASSERT(static_cast(r) < 0x80); + return l + lyx::docstring::value_type(r); +} + + +lyx::docstring operator+(char l, lyx::docstring const & r) +{ + BOOST_ASSERT(static_cast(l) < 0x80); + return lyx::docstring::value_type(l) + r; +} diff --git a/src/support/docstring.h b/src/support/docstring.h index 831289c1fc..a17d4832d6 100644 --- a/src/support/docstring.h +++ b/src/support/docstring.h @@ -47,6 +47,19 @@ inline bool operator!=(lyx::docstring const & l, char const * r) { return !(l == /// Compare a C string of ASCII characters with a docstring inline bool operator!=(char const * l, lyx::docstring const & r) { return !(r == l); } +/// Concatenate a docstring and a C string of ASCII characters +lyx::docstring operator+(lyx::docstring const &, char const *); + +/// Concatenate a C string of ASCII characters and a docstring +lyx::docstring operator+(char const *, lyx::docstring const &); + +/// Concatenate a docstring and a single ASCII character +lyx::docstring operator+(lyx::docstring const & l, char r); + +/// Concatenate a single ASCII character and a docstring +lyx::docstring operator+(char l, lyx::docstring const & r); + + #if defined(__GNUC__) && defined(__GNUC_MINOR__) && __GNUC__ == 3 && __GNUC_MINOR__ < 4 // Missing char_traits methods in gcc 3.3 and older. Taken from gcc 4.2svn. namespace std {