]> git.lyx.org Git - lyx.git/blobdiff - src/support/lyxstring.h
the freespacing patch from Kayvan, draw the math empty delim with onoffdash, asure...
[lyx.git] / src / support / lyxstring.h
index ec09b96a9feebc358d7899a05cc0257ab1f53dc2..4d3339e95edc7b4795e3af400705e3298fdaa09d 100644 (file)
@@ -4,10 +4,10 @@
  * 
  *           LyX, The Document Processor
  *      
- *         Copyright (C) 1995 Matthias Ettrich
- *          Copyright (C) 1995-1999 The LyX Team.
+ *         Copyright 1995 Matthias Ettrich
+ *          Copyright 1995-1999 The LyX Team.
  *
- *======================================================*/
+ * ====================================================== */
 
 // This one is heavily based on the string class in The C++
 // Programming Language by Bjarne Stroustrup
@@ -169,9 +169,19 @@ public:
        /// 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();
 
@@ -185,7 +195,7 @@ public:
        size_type size() const;
 
        /// largest possible string
-       size_type max_size() const { return npos -1; }
+       size_type max_size() const { return npos - 1; }
 
        ///
        size_type length() const { return size(); }
@@ -234,9 +244,20 @@ public:
        ///
        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,
@@ -288,9 +309,20 @@ public:
        ///
        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]:
 
        ///
@@ -318,8 +350,20 @@ public:
        ///
        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
        
        //@}
 
@@ -415,18 +459,18 @@ public:
        // 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,
@@ -445,10 +489,13 @@ public:
        ///
        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);
 
@@ -552,7 +599,7 @@ private:
            empty_reps.
        */
 
-#ifdef DEVEL_VERSION
+#ifdef ENABLE_ASSERTIONS
        /// lyxstringInvariant is used to test the lyxstring Invariant
        friend class lyxstringInvariant;
 #endif
@@ -599,6 +646,8 @@ lyxstring operator+(lyxstring::value_type a, lyxstring const & b);
 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');