1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-2001 The LyX Team.
9 * ====================================================== */
16 #pragma implementation
19 #include "LSubstring.h"
21 #ifndef CXX_GLOBAL_CSTD
27 LSubstring::LSubstring(string & s, size_type i, size_type l)
28 : ps(&s), pos(i), n(l)
33 LSubstring::LSubstring(string & s, string const & s2)
34 : ps(&s), n(s2.length())
40 LSubstring::LSubstring(string & s, string::value_type const * p)
48 LSubstring::LSubstring(string & s, LRegex const & r)
51 LRegex::MatchPair const res = r.first_match(s);
52 if (res.first != string::npos) {
62 LSubstring & LSubstring::operator=(string const & s)
64 ps->replace(pos, n, s); // write through to *ps
69 LSubstring & LSubstring::operator=(LSubstring const & s)
71 ps->replace(pos, n, s);
76 LSubstring & LSubstring::operator=(string::value_type const * p)
78 ps->replace(pos, n, p);
83 LSubstring & LSubstring::operator=(string::value_type c)
85 ps->replace(pos, n, 1, c);
90 LSubstring::operator string() const
92 return string(*ps, pos, n); // copy from *ps