some other things

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@317 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 1999-11-15 14:45:17 +00:00
parent e8022b10a1
commit 35df50f78c
6 changed files with 37 additions and 21 deletions

View File

@ -1,5 +1,14 @@
1999-11-15 Lars Gullik Bjønnes <larsbj@lyx.org> 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/menus.C (ShowBufferMenu): to use the new BufferStorage
* src/bufferlist.[Ch]: use the new BufferStorage class and remove all * src/bufferlist.[Ch]: use the new BufferStorage class and remove all

View File

@ -119,7 +119,7 @@ static void LexInitCodes()
lexcode['%'] = LexComment; lexcode['%'] = LexComment;
lexcode['#'] = LexArgument; lexcode['#'] = LexArgument;
lexcode['+'] = lexcode['-'] = lexcode['*'] = lexcode['/'] = lexcode['+'] = lexcode['-'] = lexcode['*'] = lexcode['/'] =
lexcode['<'] = lexcode['>'] = lexcode['= '] = LexBOP; lexcode['<'] = lexcode['>'] = lexcode['='] = LexBOP;
lexcode['!'] = lexcode[','] = lexcode[':'] = lexcode[';'] = LexMathSpace; lexcode['!'] = lexcode[','] = lexcode[':'] = lexcode[';'] = LexMathSpace;
lexcode['('] = lexcode[')'] = lexcode['|'] = lexcode['.'] = lexcode['?'] = LexOther; lexcode['('] = lexcode[')'] = lexcode['|'] = lexcode['.'] = lexcode['?'] = LexOther;

View File

@ -21,14 +21,14 @@ LSubstring::LSubstring(string & s, size_type i, size_type l)
} }
LSubstring::LSubstring(string & s, string & s2) LSubstring::LSubstring(string & s, string const & s2)
: ps(&s), n(s2.length()) : ps(&s), n(s2.length())
{ {
pos = s.find(s2); pos = s.find(s2);
} }
LSubstring::LSubstring(string & s, char * p) LSubstring::LSubstring(string & s, string::value_type const * p)
: ps(&s) : ps(&s)
{ {
n = strlen(p); n = strlen(p);
@ -36,7 +36,7 @@ LSubstring::LSubstring(string & s, char * p)
} }
LSubstring::LSubstring(string & s, LRegex & r) LSubstring::LSubstring(string & s, LRegex const & r)
: ps(&s) : ps(&s)
{ {
LRegex::MatchPair res = r.first_match(s); LRegex::MatchPair res = r.first_match(s);
@ -82,13 +82,3 @@ LSubstring::operator string() const
{ {
return string(*ps, pos, n); // copy from *ps 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

View File

@ -31,11 +31,11 @@ public:
/// ///
LSubstring(string & s, size_type i, size_type n); 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 const &);
/// ///
@ -46,10 +46,6 @@ public:
LSubstring & operator=(string::value_type); LSubstring & operator=(string::value_type);
/// ///
operator string() const; operator string() const;
#if 0
///
operator char const * () const;
#endif
private: private:
/// ///
string * ps; string * ps;

View File

@ -1345,6 +1345,15 @@ lyxstring & lyxstring::replace(iterator i, iterator i2,
} }
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) lyxstring & lyxstring::erase(size_type i, size_type n)
{ {
Assert(i <= rep->sz); // STD! Assert(i <= rep->sz); // STD!
@ -1667,6 +1676,13 @@ lyxstring operator+(lyxstring const & a, lyxstring::value_type b)
return tmp; return tmp;
} }
void swap(lyxstring & str1, lyxstring & str2)
{
str1.swap(str2);
}
#include <iostream> #include <iostream>
istream & operator>>(istream & is, lyxstring & s) istream & operator>>(istream & is, lyxstring & s)

View File

@ -449,6 +449,9 @@ public:
/// ///
lyxstring & replace(iterator i, iterator i2, iterator j, iterator j2); lyxstring & replace(iterator i, iterator i2, iterator j, iterator j2);
///
void swap(lyxstring & str);
/// Erase n chars from position i. /// Erase n chars from position i.
lyxstring & erase(size_type i = 0, size_type n = npos); lyxstring & erase(size_type i = 0, size_type n = npos);
@ -599,6 +602,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 const * b);
lyxstring operator+(lyxstring const & a, lyxstring::value_type b); lyxstring operator+(lyxstring const & a, lyxstring::value_type b);
void swap(lyxstring & s1, lyxstring & s2);
istream & operator>>(istream &, lyxstring &); istream & operator>>(istream &, lyxstring &);
ostream & operator<<(ostream &, lyxstring const &); ostream & operator<<(ostream &, lyxstring const &);
istream & getline(istream &, lyxstring &, lyxstring::value_type delim = '\n'); istream & getline(istream &, lyxstring &, lyxstring::value_type delim = '\n');