]> git.lyx.org Git - features.git/commitdiff
Add operator+ for ASCII characters and ASCII C strings
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Mon, 11 Sep 2006 07:13:56 +0000 (07:13 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Mon, 11 Sep 2006 07:13:56 +0000 (07:13 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14969 a592a061-630c-0410-9148-cb99ea01b6c8

src/support/docstring.C
src/support/docstring.h

index fb3115ba9aacb4e5ca047336f27c50c88be4c0ad..382612071a2d5346cd9878348e5f19a60e081e58 100644 (file)
@@ -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<unsigned char>(*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<unsigned char>(*c) < 0x80);
+               s.push_back(*c);
+       }
+       s += r;
+       return s;
+}
+
+
+lyx::docstring operator+(lyx::docstring const & l, char r)
+{
+       BOOST_ASSERT(static_cast<unsigned char>(r) < 0x80);
+       return l + lyx::docstring::value_type(r);
+}
+
+
+lyx::docstring operator+(char l, lyx::docstring const & r)
+{
+       BOOST_ASSERT(static_cast<unsigned char>(l) < 0x80);
+       return lyx::docstring::value_type(l) + r;
+}
index 831289c1fcc3bd5a14bf64cdc3caa2e998e7559f..a17d4832d6ef64a85053fb6697894210f1e7481f 100644 (file)
@@ -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 {