1999-11-15 Lars Gullik Bjønnes <larsbj@lyx.org>
+ * src/support/LSubstring.[Ch]: made the second arg of most of the
+ constructors be a const reference.
+
+ * src/mathed/math_parser.C (LexInitCodes): small bug introduced by
+ me fixed.
+
+ * src/support/lyxstring.[Ch] (swap): added missing member function
+ and specialization of swap(str, str);
+
* src/menus.C (ShowBufferMenu): to use the new BufferStorage
* src/bufferlist.[Ch]: use the new BufferStorage class and remove all
lexcode['%'] = LexComment;
lexcode['#'] = LexArgument;
lexcode['+'] = lexcode['-'] = lexcode['*'] = lexcode['/'] =
- lexcode['<'] = lexcode['>'] = lexcode['= '] = LexBOP;
+ lexcode['<'] = lexcode['>'] = lexcode['='] = LexBOP;
lexcode['!'] = lexcode[','] = lexcode[':'] = lexcode[';'] = LexMathSpace;
lexcode['('] = lexcode[')'] = lexcode['|'] = lexcode['.'] = lexcode['?'] = LexOther;
}
-LSubstring::LSubstring(string & s, string & s2)
+LSubstring::LSubstring(string & s, string const & s2)
: ps(&s), n(s2.length())
{
pos = s.find(s2);
}
-LSubstring::LSubstring(string & s, char * p)
+LSubstring::LSubstring(string & s, string::value_type const * p)
: ps(&s)
{
n = strlen(p);
}
-LSubstring::LSubstring(string & s, LRegex & r)
+LSubstring::LSubstring(string & s, LRegex const & r)
: ps(&s)
{
LRegex::MatchPair res = r.first_match(s);
{
return string(*ps, pos, n); // copy from *ps
}
-
-
-#if 0
-LSubstring::operator char const * () const
-{
- static string tr;
- tr.assign(*ps, pos, n);
- return tr.c_str();
-}
-#endif
///
LSubstring(string & s, size_type i, size_type n);
///
- LSubstring(string & s, string & s2);
+ LSubstring(string & s, string const & s2);
///
- LSubstring(string & s, string::value_type * p);
+ LSubstring(string & s, string::value_type const * p);
///
- LSubstring(string & s, LRegex & r);
+ LSubstring(string & s, LRegex const & r);
///
LSubstring & operator=(string const &);
///
LSubstring & operator=(string::value_type);
///
operator string() const;
-#if 0
- ///
- operator char const * () const;
-#endif
private:
///
string * ps;
}
+void lyxstring::swap(lyxstring & str)
+{
+ if (rep == str.rep) return;
+ Srep * tmp = str.rep;
+ str.rep = rep;
+ rep = tmp;
+}
+
+
lyxstring & lyxstring::erase(size_type i, size_type n)
{
Assert(i <= rep->sz); // STD!
return tmp;
}
+
+void swap(lyxstring & str1, lyxstring & str2)
+{
+ str1.swap(str2);
+}
+
+
#include <iostream>
istream & operator>>(istream & is, lyxstring & s)
///
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);
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');