* Copyright (C) 1995 Matthias Ettrich
* Copyright (C) 1995-1999 The LyX Team.
*
- *======================================================*/
+ * ====================================================== */
// This one is heavily based on the string class in The C++
// Programming Language by Bjarne Stroustrup
#pragma interface
#endif
-#ifdef HAVE_CONFIG_H
-#include <config.h> // needed at least for compilers that do not
-#endif // understand `explicit' (JMarc)
-
#include "LOstream.h"
#include "LIstream.h"
/// lyxstring(5, 'n') -> "nnnnn"
lyxstring(size_type n, value_type c);
+#if 1
///
- lyxstring(iterator first, iterator last);
-
+ lyxstring(const_iterator first, const_iterator last);
+#else
+ ///
+ template<class InputIterator>
+ lyxstring::lyxstring(InputIterator begin, InputIterator end) {
+ while (begin != end) {
+ push_back((*begin));
+ ++begin;
+ }
+ }
+#endif
///
~lyxstring();
///
lyxstring & assign(size_type n, value_type c);
+#if 1
///
- lyxstring & assign(iterator first, iterator last);
-
+ lyxstring & assign(const_iterator first, const_iterator last);
+#else
+ ///
+ template<class InputIterator>
+ lyxstring & assign(InputIterator begin, InputIterator end) {
+ clear;
+ while (begin != end) {
+ push_back((*begin));
+ ++begin;
+ }
+ }
+#endif
//@}
/**@name Element Access. Since lyxstring does not use exceptions,
///
lyxstring & append(size_type n, value_type);
+#if 1
///
lyxstring & append(iterator first, iterator last);
-
+#else
+ ///
+ template<class InputIterator>
+ lyxstring & append(InputIterator begin, InputIterator end) {
+ while (begin != end) {
+ push_back((*begin));
+ ++begin;
+ }
+ return *this;
+ }
+#endif
// insert characters before (*this)[pos]:
///
///
void insert(iterator p, size_type n , value_type c);
+#if 1
///
void insert(iterator p, iterator first, iterator last);
+#else
+ ///
+ template<class InputIterator>
+ void insert(iterator p, InputIterator begin, InputIterator end) {
+ iterator it;
+ while (begin != end) {
+ it = insert(p, (*begin));
+ ++begin;
+ }
+ }
+#endif
//@}
// replace [(*this)[i], (*this)[i+n]] with other characters:
///
- lyxstring & replace(size_type i,size_type n, lyxstring const & str);
+ lyxstring & replace(size_type i, size_type n, lyxstring const & str);
///
- lyxstring & replace(size_type i,size_type n, lyxstring const & s,
+ lyxstring & replace(size_type i, size_type n, lyxstring const & s,
size_type i2, size_type n2);
///
- lyxstring & replace(size_type i,size_type n, value_type const * p,
+ lyxstring & replace(size_type i, size_type n, value_type const * p,
size_type n2);
///
- lyxstring & replace(size_type i,size_type n, value_type const * p);
+ lyxstring & replace(size_type i, size_type n, value_type const * p);
///
lyxstring & replace(size_type i, size_type n,
///
lyxstring & replace(iterator i, iterator i2,
size_type n , value_type c);
-
+
///
lyxstring & replace(iterator i, iterator i2, iterator j, iterator j2);
+ ///
+ void swap(lyxstring & str);
+
/// Erase n chars from position i.
lyxstring & erase(size_type i = 0, size_type n = npos);
private:
// These three operators can be used to discover erronous use of
// ints and strings. However a conforming C++ compiler will flag
- // a lot of char operations as abmbigous when they are compiled
+ // a lot of char operations as ambigous when they are compiled
// in. Use them for debugging only (or perhaps not even then.)
// Lgb.
//
//lyxstring & operator=(int);
//
//lyxstring & operator+=(int);
-
+
+ /// Compare this with s. works with embedded '\0' chars also.
+ int internal_compare(size_type pos, size_type n,
+ value_type const * s,
+ size_type slen, size_type n2) const;
+
/// Forward declaration of the string representation
struct Srep;
+ // DEC cxx requires this.
+ friend struct Srep;
/// A string is a pointer to it's representation
Srep * rep;
lyxstring operator+(lyxstring const & a, lyxstring::value_type const * b);
lyxstring operator+(lyxstring const & a, lyxstring::value_type b);
+void swap(lyxstring & s1, lyxstring & s2);
+
istream & operator>>(istream &, lyxstring &);
ostream & operator<<(ostream &, lyxstring const &);
istream & getline(istream &, lyxstring &, lyxstring::value_type delim = '\n');