1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright (C) 1995 Matthias Ettrich
7 * Copyright (C) 1995-1998 The LyX Team.
9 * ====================================================== */
15 #include "LSubstring.h"
18 LSubstring::LSubstring(string & s, size_type i, size_type l)
19 : ps(&s), pos(i), n(l)
24 LSubstring::LSubstring(string & s, string & s2)
25 : ps(&s), n(s2.length())
31 LSubstring::LSubstring(string & s, char * p)
39 LSubstring::LSubstring(string & s, LRegex & r)
42 LRegex::MatchPair res = r.first_match(s);
43 if (res.first != string::npos) {
53 LSubstring & LSubstring::operator=(string const & s)
55 ps->replace(pos, n, s); // write through to *ps
60 LSubstring & LSubstring::operator=(LSubstring const & s)
62 ps->replace(pos, n, string(s, 0, string::npos));
67 LSubstring & LSubstring::operator=(char const * p)
69 ps->replace(pos, n, p);
74 LSubstring & LSubstring::operator=(char c)
76 ps->replace(pos, n, 1, c);
81 LSubstring::operator string() const
83 return string(*ps, pos, n); // copy from *ps
88 LSubstring::operator char const * () const
91 tr.assign(*ps, pos, n);