1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-2000 The LyX Team.
9 * ====================================================== */
16 #pragma implementation
19 #include "LSubstring.h"
22 LSubstring::LSubstring(string & s, size_type i, size_type l)
23 : ps(&s), pos(i), n(l)
28 LSubstring::LSubstring(string & s, string const & s2)
29 : ps(&s), n(s2.length())
35 LSubstring::LSubstring(string & s, string::value_type const * p)
43 LSubstring::LSubstring(string & s, LRegex const & r)
46 LRegex::MatchPair res = r.first_match(s);
47 if (res.first != string::npos) {
57 LSubstring & LSubstring::operator=(string const & s)
59 ps->replace(pos, n, s); // write through to *ps
64 LSubstring & LSubstring::operator=(LSubstring const & s)
66 ps->replace(pos, n, s);
71 LSubstring & LSubstring::operator=(char const * p)
73 ps->replace(pos, n, p);
78 LSubstring & LSubstring::operator=(char c)
80 ps->replace(pos, n, 1, c);
85 LSubstring::operator string() const
87 return string(*ps, pos, n); // copy from *ps