*
* LyX, The Document Processor
*
- * Copyright (C) 1995 Matthias Ettrich
- * Copyright (C) 1995-1999 The LyX Team.
+ * Copyright 1995 Matthias Ettrich
+ * Copyright 1995-2000 The LyX Team.
*
* ====================================================== */
// Lgb.
+
///////////////////////////////////////
// The internal string representation
///////////////////////////////////////
};
-inline
lyxstring::Srep::Srep(lyxstring::size_type nsz, const value_type * p)
{
-// can be called with p == 0 by lyxstring::assign(const value_type *, size_type)
+ // can be called with p == 0 by
+ // lyxstring::assign(const value_type *, size_type)
sz = nsz;
ref = 1;
}
-inline
lyxstring::Srep::Srep(lyxstring::size_type nsz, value_type ch)
{
sz = nsz;
}
-inline
void lyxstring::Srep::assign(lyxstring::size_type nsz, const value_type * p)
{
-// can be called with p == 0 by lyxstring::assign(const value_type *, size_type)
+ // can be called with p == 0
+ // by lyxstring::assign(const value_type *, size_type)
if (res < nsz) {
delete[] s;
}
-inline
void lyxstring::Srep::assign(lyxstring::size_type nsz, value_type ch)
{
sz = nsz;
}
-inline
void lyxstring::Srep::append(lyxstring::size_type asz, const value_type * p)
{
register unsigned int const len = sz + asz;
}
-inline
void lyxstring::Srep::push_back(value_type c)
{
s[sz] = c; // it is always room to put a value_type at the end
}
-inline
void lyxstring::Srep::insert(lyxstring::size_type pos, const value_type * p,
- lyxstring::size_type n)
+ lyxstring::size_type n)
{
if (res < n + sz) {
do {
}
-inline
void lyxstring::Srep::resize(size_type n, value_type c)
{
// This resets sz to res_arg
}
-inline
void lyxstring::Srep::reserve(lyxstring::size_type res_arg)
{
// This keeps the old sz, but
}
-inline
void lyxstring::Srep::replace(lyxstring::size_type i, lyxstring::size_type n,
- value_type const * p, size_type n2)
+ value_type const * p, size_type n2)
{
// can be called with p= 0 and n2= 0
n = min(sz - i, n);
///////////////////////////////////////
// The lyxstring Invariant tester
///////////////////////////////////////
-#ifdef DEVEL_VERSION
+#ifdef ENABLE_ASSERTIONS
/** Testing of the lyxstring invariant
* By creating an object that tests the lyxstring invariant during its
// NOTE: The easiest way to catch this snippet of the output is to wait for
// the splash screen to disappear and then open and close Help->Credits
//
-inline
lyxstringInvariant::lyxstringInvariant(lyxstring const * ls) : object(ls)
{
// printf("lyxstringInvariant constructor\n");
}
-inline
lyxstringInvariant::~lyxstringInvariant()
{
helper();
}
-inline
void lyxstringInvariant::helper() const
{
// Some of these tests might look pointless but they are
#define TestlyxstringInvariant(s) lyxstringInvariant lyxstring_invariant(s);
#else
#define TestlyxstringInvariant(s)
-#endif //DEVEL_VERSION
+#endif /* ENABLE_ASSERTIONS */
///////////////////////////////////////
static_cast<lyxstring::size_type>(-1);
-inline
lyxstring::lyxstring()
{
static Srep empty_rep(0, "");
}
-inline
lyxstring::lyxstring(lyxstring const & x, size_type pos, size_type n)
{
Assert(pos <= x.rep->sz); // STD!
}
-inline
lyxstring::lyxstring(value_type const * s, size_type n)
{
Assert(s && n < npos); // STD!
}
-inline
lyxstring::lyxstring(value_type const * s)
{
Assert(s); // STD!
}
-inline
lyxstring::lyxstring(size_type n, value_type c)
{
Assert(n < npos); // STD!
}
-inline
lyxstring::lyxstring(const_iterator first, const_iterator last)
{
rep = new Srep(last - first, first);
}
-inline
lyxstring::~lyxstring()
{
if (--rep->ref == 0) delete rep;
// Iterators
///////////////////////
-inline
lyxstring::iterator lyxstring::begin()
{
+ rep = rep->get_own_copy();
return rep->s;
}
-inline
lyxstring::const_iterator lyxstring::begin() const
{
return rep->s;
}
-inline
lyxstring::iterator lyxstring::end()
{
+ rep = rep->get_own_copy();
return rep->s + rep->sz;
}
-inline
lyxstring::const_iterator lyxstring::end() const
{
return rep->s + rep->sz;
}
#if 0
-inline
reverse_iterator lyxstring::rbegin()
{
return reverse_iterator( end() );
}
-inline
const_reverse_iterator lyxstring::rbegin() const
{
return const_reverse_iterator( end() );
}
-inline
reverse_iterator lyxstring::rend()
{
return reverse_iterator( begin() );
}
-inline
const_reverse_iterator lyxstring::rend() const
{
return const_reverse_iterator( begin() );
// Size and Capacity
///////////////////////
-inline
lyxstring::size_type lyxstring::size() const
{
return rep->sz;
}
-inline
void lyxstring::resize(size_type n, value_type c)
{
Assert(n <= npos); // STD!
}
-inline
lyxstring::size_type lyxstring::capacity() const
{
return rep->res;
}
-inline
void lyxstring::reserve(size_type res_arg)
{
TestlyxstringInvariant(this);
// Assignment
////////////////
-inline
lyxstring & lyxstring::operator= (lyxstring const & x)
{
TestlyxstringInvariant(this);
}
-inline
lyxstring & lyxstring::operator= (value_type const * s)
{
Assert(s); // OURS!
}
-inline
lyxstring & lyxstring::operator=(value_type c)
{
TestlyxstringInvariant(this);
}
-inline
lyxstring & lyxstring::assign(lyxstring const & x)
{
TestlyxstringInvariant(this);
}
-inline
lyxstring & lyxstring::assign(lyxstring const & x, size_type pos, size_type n)
{
Assert(pos <= x.rep->sz); // STD!
}
-inline
lyxstring & lyxstring::assign(value_type const * s, size_type n)
{
Assert(s); // OURS!
}
-inline
lyxstring & lyxstring::assign(value_type const * s)
{
Assert(s); // OURS!
}
-inline
lyxstring & lyxstring::assign(size_type n, value_type ch)
{
TestlyxstringInvariant(this);
}
-inline
lyxstring & lyxstring::assign(const_iterator first, const_iterator last)
{
TestlyxstringInvariant(this);
// Element Access
////////////////////
-inline
lyxstring::const_reference lyxstring::operator[](size_type pos) const
{
Assert(pos <= rep->sz); // OURS!
}
-inline
lyxstring::reference lyxstring::operator[](size_type pos)
{
Assert(pos < rep->sz); // OURS!
}
-inline
lyxstring::const_reference lyxstring::at(size_type n) const
{
Assert(n < rep->sz); // STD!
}
-inline
lyxstring::reference lyxstring::at(size_type n)
{
Assert(n < rep->sz); // STD!
// Insert
/////////////
-inline
lyxstring & lyxstring::operator+=(lyxstring const & x)
{
TestlyxstringInvariant(this);
}
-inline
lyxstring & lyxstring::operator+=(value_type const * x)
{
Assert(x); // OURS!
}
-inline
lyxstring & lyxstring::operator+=(value_type c)
{
TestlyxstringInvariant(this);
}
-inline
void lyxstring::push_back(value_type c)
{
TestlyxstringInvariant(this);
}
-inline
lyxstring & lyxstring::append(lyxstring const & x)
{
TestlyxstringInvariant(this);
}
-inline
lyxstring & lyxstring::append(lyxstring const & x, size_type pos, size_type n)
{
Assert(pos <= x.rep->sz); // STD!
}
-inline
lyxstring & lyxstring::append(value_type const * p, size_type n)
{
Assert(p); // OURS!
}
-inline
lyxstring & lyxstring::append(value_type const * p)
{
Assert(p); // OURS!
}
-inline
lyxstring & lyxstring::append(size_type n, value_type c)
{
TestlyxstringInvariant(this);
}
-inline
lyxstring & lyxstring::append(iterator first, iterator last)
{
TestlyxstringInvariant(this);
// insert value_typeacters before (*this)[pos]
-inline
lyxstring & lyxstring::insert(size_type pos, lyxstring const & x)
{
TestlyxstringInvariant(this);
}
-inline
lyxstring & lyxstring::insert(size_type pos, lyxstring const & x,
- size_type pos2, size_type n)
+ size_type pos2, size_type n)
{
Assert(pos <= rep->sz && pos2 <= x.rep->sz); // STD!
TestlyxstringInvariant(this);
}
-inline
lyxstring & lyxstring::insert(size_type pos, value_type const * p, size_type n)
{
Assert(p); // OURS!
}
-inline
lyxstring & lyxstring::insert(size_type pos, value_type const * p)
{
Assert(p); // OURS!
}
-inline
lyxstring & lyxstring::insert(size_type pos, size_type n, value_type c)
{
TestlyxstringInvariant(this);
}
-inline
lyxstring::iterator lyxstring::insert(iterator p, value_type c)
{
TestlyxstringInvariant(this);
}
-inline
void lyxstring::insert(iterator p, size_type n , value_type c)
{
TestlyxstringInvariant(this);
}
-inline
void lyxstring::insert(iterator p, iterator first, iterator last)
{
TestlyxstringInvariant(this);
// some of the parameters wrong, also some of the funcs can surely
// be written more effectively.
-inline
lyxstring::size_type lyxstring::find(lyxstring const & a, size_type i) const
{
if (!rep->sz || i >= rep->sz) return npos;
}
-inline
lyxstring::size_type lyxstring::find(value_type const * ptr, size_type i,
- size_type n) const
+ size_type n) const
{
Assert(ptr); // OURS!
if (!rep->sz || !*ptr || i >= rep->sz) return npos;
}
-inline
lyxstring::size_type lyxstring::find(value_type const * s, size_type i) const
{
Assert(s); // OURS!
}
-inline
lyxstring::size_type lyxstring::find(value_type c, size_type i) const
{
if (!rep->sz || i >= rep->sz) return npos;
}
-inline
lyxstring::size_type lyxstring::rfind(lyxstring const & a, size_type i) const
{
TestlyxstringInvariant(this);
}
-inline
lyxstring::size_type lyxstring::rfind(value_type const * ptr, size_type i,
- size_type n) const
+ size_type n) const
{
Assert(ptr); // OURS!
TestlyxstringInvariant(this);
}
-inline
lyxstring::size_type lyxstring::rfind(value_type const * ptr,
size_type i) const
{
}
-inline
lyxstring::size_type lyxstring::rfind(value_type c, size_type i) const
{
TestlyxstringInvariant(this);
}
-inline
lyxstring::size_type lyxstring::find_first_of(lyxstring const & a,
size_type i) const
{
}
-inline
lyxstring::size_type lyxstring::find_first_of(value_type const * ptr,
size_type i,
size_type n) const
}
-inline
lyxstring::size_type lyxstring::find_first_of(value_type const * ptr,
size_type i) const
{
}
-inline
lyxstring::size_type lyxstring::find_first_of(value_type c, size_type i) const
{
Assert(i < rep->sz); // OURS!
}
-inline
lyxstring::size_type lyxstring::find_last_of(lyxstring const & a,
size_type i) const
{
}
-inline
lyxstring::size_type lyxstring::find_last_of(value_type const * ptr,
size_type i,
size_type n) const
}
-inline
lyxstring::size_type lyxstring::find_last_of(value_type const * ptr,
size_type i) const
{
}
-inline
lyxstring::size_type lyxstring::find_last_of(value_type c, size_type i) const
{
TestlyxstringInvariant(this);
}
-inline
lyxstring::size_type lyxstring::find_first_not_of(lyxstring const & a,
size_type i) const
{
}
-inline
lyxstring::size_type lyxstring::find_first_not_of(value_type const * ptr,
size_type i,
size_type n) const
}
-inline
lyxstring::size_type lyxstring::find_first_not_of(value_type const * ptr,
size_type i) const
{
}
-inline
lyxstring::size_type lyxstring::find_first_not_of(value_type c,
size_type i) const
{
}
-inline
lyxstring::size_type lyxstring::find_last_not_of(lyxstring const & a,
size_type i) const
{
}
-inline
lyxstring::size_type lyxstring::find_last_not_of(value_type const * ptr,
size_type i,
size_type n) const
}
-inline
lyxstring::size_type lyxstring::find_last_not_of(value_type const * ptr,
size_type i) const
{
}
-inline
lyxstring::size_type lyxstring::find_last_not_of(value_type c,
size_type i) const
{
// Replace
/////////////////
-inline
lyxstring & lyxstring::replace(size_type i, size_type n, lyxstring const & x)
{
Assert(i <= rep->sz); // OURS!
}
-inline
lyxstring & lyxstring::replace(size_type i, size_type n, lyxstring const & x,
size_type i2, size_type n2)
{
}
-inline
lyxstring & lyxstring::replace(size_type i, size_type n,
value_type const * p, size_type n2)
{
}
-inline
lyxstring & lyxstring::replace(size_type i, size_type n, value_type const * p)
{
Assert(p && i < rep->sz); // OURS!
}
-inline
lyxstring & lyxstring::replace(size_type i, size_type n,
size_type n2, value_type c)
{
}
-inline
lyxstring & lyxstring::replace(iterator i, iterator i2, const lyxstring & str)
{
TestlyxstringInvariant(this);
}
-inline
lyxstring & lyxstring::replace(iterator i, iterator i2,
value_type const * p, size_type n)
{
}
-inline
lyxstring & lyxstring::replace(iterator i, iterator i2, value_type const * p)
{
Assert(p); // OURS!
}
-inline
lyxstring & lyxstring::replace(iterator i, iterator i2,
size_type n , value_type c)
{
}
-inline
lyxstring & lyxstring::replace(iterator i, iterator i2,
iterator j, iterator j2)
{
}
-inline
void lyxstring::swap(lyxstring & str)
{
if (rep == str.rep) return;
}
-inline
lyxstring & lyxstring::erase(size_type i, size_type n)
{
Assert(i <= rep->sz); // STD!
}
-inline
lyxstring::iterator lyxstring::erase(iterator i)
{
TestlyxstringInvariant(this);
}
-inline
lyxstring::iterator lyxstring::erase(iterator first, iterator last)
{
TestlyxstringInvariant(this);
// Conversion to C-style Strings
/////////////////////////////////////
-inline
lyxstring::value_type const * lyxstring::c_str() const
{
rep->s[length()] = '\0';
}
-inline
lyxstring::value_type const * lyxstring::data() const
{
return rep->s;
}
-inline
lyxstring::size_type lyxstring::copy(value_type * buf, size_type len,
size_type pos) const
{
// Compare funcs should be verified.
-inline
int lyxstring::internal_compare(size_type pos, size_type n,
value_type const * s,
size_type slen, size_type n2) const
}
-inline
int lyxstring::compare(lyxstring const & str) const
{
TestlyxstringInvariant(this);
}
-inline
int lyxstring::compare(value_type const * s) const
{
Assert(s); //OURS!
}
-inline
int lyxstring::compare(size_type pos, size_type n,
lyxstring const & str) const
{
}
-inline
int lyxstring::compare(size_type pos, size_type n, lyxstring const & str,
size_type pos2, size_type n2) const
{
}
-inline
int lyxstring::compare(size_type pos, size_type n, value_type const * s,
size_type n2) const
{
/////////////////
// i = index, n = length
-inline
lyxstring lyxstring::substr(size_type i, size_type n) const
{
Assert(i <= rep->sz); // STD!