*
* 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.
*
* ====================================================== */
#pragma implementation "lyxstring.h"
#endif
-//#include "LString.h"
#include "lyxstring.h"
#include <cstdlib>
#include <cctype>
// Lgb.
-#if 0
-// I have no clue why this function is needed at all, it is static and
-// confined to this filescope. How can any other file/fuction/module
-// get access to it at all?? Perhaps the forward declaration in LString.h
-// is enough. ARRae, any clues? Lgb.
-
-#ifdef HAVE_STL_STRING_FWD_H
-// SGI's STL > 3.13 expects string to provide __get_c_string.
-// Due to a clash with SGI's forward declaration of string we have
-// to provide this ourselves and block their string declarations
-// as best we can. ARRae.
-
-static char const * __get_c_string(string const & s)
-{
- return s.c_str();
-}
-#endif
-#endif
-
-
///////////////////////////////////////
// The internal string representation
///////////////////////////////////////
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;
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;
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 {
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
#define TestlyxstringInvariant(s) lyxstringInvariant lyxstring_invariant(s);
#else
#define TestlyxstringInvariant(s)
-#endif //DEVEL_VERSION
+#endif /* ENABLE_ASSERTIONS */
///////////////////////////////////////
lyxstring::iterator lyxstring::begin()
{
+ rep = rep->get_own_copy();
return rep->s;
}
lyxstring::iterator lyxstring::end()
{
+ rep = rep->get_own_copy();
return rep->s + rep->sz;
}
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);
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;
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);