]> git.lyx.org Git - lyx.git/blob - src/support/LSubstring.C
remove commented HAVE_SSTREAM code
[lyx.git] / src / support / LSubstring.C
1 /* This file is part of
2  * ======================================================
3  * 
4  *           LyX, The Document Processor
5  *       
6  *           Copyright 1995 Matthias Ettrich
7  *           Copyright 1995-2000 The LyX Team.
8  *
9  * ====================================================== */
10
11 #ifdef HAVE_CONFIG_H
12 #include <config.h>
13 #endif
14
15 #ifdef __GNUG__
16 #pragma implementation
17 #endif
18
19 #include "LSubstring.h"
20
21
22 LSubstring::LSubstring(string & s, size_type i, size_type l)
23         : ps(&s), pos(i), n(l)
24 {
25 }
26
27
28 LSubstring::LSubstring(string & s, string const & s2)
29         : ps(&s), n(s2.length())
30 {
31         pos = s.find(s2);
32 }
33
34
35 LSubstring::LSubstring(string & s, string::value_type const * p)
36         : ps(&s)
37 {
38         n = strlen(p);
39         pos = s.find(p);
40 }
41
42
43 LSubstring::LSubstring(string & s, LRegex const & r)
44         : ps(&s)
45 {
46         LRegex::MatchPair res = r.first_match(s);
47         if (res.first != string::npos) {
48                 n = res.second;
49                 pos = res.first;
50         } else {
51                 n = 0;
52                 pos = string::npos;
53         }
54 }
55
56
57 LSubstring & LSubstring::operator=(string const & s)
58 {
59         ps->replace(pos, n, s); // write through to *ps
60         return *this;
61 }
62
63
64 LSubstring & LSubstring::operator=(LSubstring const & s)
65 {
66         ps->replace(pos, n, s);
67         return *this;
68 }
69
70
71 LSubstring & LSubstring::operator=(char const * p)
72 {
73         ps->replace(pos, n, p);
74         return *this;
75 }
76
77
78 LSubstring & LSubstring::operator=(char c)
79 {
80         ps->replace(pos, n, 1, c);
81         return *this;
82 }
83
84
85 LSubstring::operator string() const
86 {
87         return string(*ps, pos, n); // copy from *ps
88 }