mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-14 06:57:01 +00:00
07ea5f51f0
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2079 a592a061-630c-0410-9148-cb99ea01b6c8
94 lines
1.5 KiB
C
94 lines
1.5 KiB
C
/* This file is part of
|
|
* ======================================================
|
|
*
|
|
* LyX, The Document Processor
|
|
*
|
|
* Copyright 1995 Matthias Ettrich
|
|
* Copyright 1995-2001 The LyX Team.
|
|
*
|
|
* ====================================================== */
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
#include <config.h>
|
|
#endif
|
|
|
|
#ifdef __GNUG__
|
|
#pragma implementation
|
|
#endif
|
|
|
|
#include "LSubstring.h"
|
|
|
|
#ifndef CXX_GLOBAL_CSTD
|
|
using std::strlen;
|
|
#endif
|
|
|
|
|
|
|
|
LSubstring::LSubstring(string & s, size_type i, size_type l)
|
|
: ps(&s), pos(i), n(l)
|
|
{
|
|
}
|
|
|
|
|
|
LSubstring::LSubstring(string & s, string const & s2)
|
|
: ps(&s), n(s2.length())
|
|
{
|
|
pos = s.find(s2);
|
|
}
|
|
|
|
|
|
LSubstring::LSubstring(string & s, string::value_type const * p)
|
|
: ps(&s)
|
|
{
|
|
n = strlen(p);
|
|
pos = s.find(p);
|
|
}
|
|
|
|
|
|
LSubstring::LSubstring(string & s, LRegex const & r)
|
|
: ps(&s)
|
|
{
|
|
LRegex::MatchPair const res = r.first_match(s);
|
|
if (res.first != string::npos) {
|
|
n = res.second;
|
|
pos = res.first;
|
|
} else {
|
|
n = 0;
|
|
pos = string::npos;
|
|
}
|
|
}
|
|
|
|
|
|
LSubstring & LSubstring::operator=(string const & s)
|
|
{
|
|
ps->replace(pos, n, s); // write through to *ps
|
|
return *this;
|
|
}
|
|
|
|
|
|
LSubstring & LSubstring::operator=(LSubstring const & s)
|
|
{
|
|
ps->replace(pos, n, s);
|
|
return *this;
|
|
}
|
|
|
|
|
|
LSubstring & LSubstring::operator=(string::value_type const * p)
|
|
{
|
|
ps->replace(pos, n, p);
|
|
return *this;
|
|
}
|
|
|
|
|
|
LSubstring & LSubstring::operator=(string::value_type c)
|
|
{
|
|
ps->replace(pos, n, 1, c);
|
|
return *this;
|
|
}
|
|
|
|
|
|
LSubstring::operator string() const
|
|
{
|
|
return string(*ps, pos, n); // copy from *ps
|
|
}
|