]> git.lyx.org Git - lyx.git/blob - src/mathed/math_data.C
translate '\int_0^1 e^x dx' to 'int(e^(x),x=0..1)'
[lyx.git] / src / mathed / math_data.C
1 #ifdef __GNUG__
2 #pragma implementation
3 #endif
4
5 #include "math_inset.h"
6 #include "math_deliminset.h"
7 #include "math_charinset.h"
8 #include "math_scriptinset.h"
9 #include "math_stringinset.h"
10 #include "math_matrixinset.h"
11 #include "math_mathmlstream.h"
12 #include "math_support.h"
13 #include "math_data.h"
14 #include "debug.h"
15 #include "support/LAssert.h"
16
17
18 MathArray::MathArray()
19 {}
20
21
22 MathArray::MathArray(MathArray const & ar, size_type from, size_type to)
23         : bf_(ar.begin() + from, ar.begin() + to)
24 {}
25
26
27 MathArray::MathArray(iterator from, iterator to)
28         : bf_(from, to)
29 {}
30
31
32 void MathArray::substitute(MathMacro const & m)
33 {
34         for (iterator it = begin(); it != end(); ++it)
35                 it->nucleus()->substitute(m);
36 }
37
38
39 MathAtom & MathArray::at(size_type pos)
40 {
41         lyx::Assert(pos < size());
42         return bf_[pos];
43 }
44
45
46 MathAtom const & MathArray::at(size_type pos) const
47 {
48         lyx::Assert(pos < size());
49         return bf_[pos];
50 }
51
52
53 void MathArray::insert(size_type pos, MathAtom const & t)
54 {
55         bf_.insert(begin() + pos, t);
56 }
57
58
59 void MathArray::insert(size_type pos, MathArray const & ar)
60 {
61         bf_.insert(begin() + pos, ar.begin(), ar.end());
62 }
63
64
65 void MathArray::push_back(MathAtom const & t)
66 {       
67         bf_.push_back(t);
68 }
69
70
71 void MathArray::push_back(MathArray const & ar)
72 {
73         insert(size(), ar);
74 }
75
76
77 void MathArray::clear()
78 {
79         erase();
80 }
81
82
83 void MathArray::swap(MathArray & ar)
84 {
85         if (this != &ar) 
86                 bf_.swap(ar.bf_);
87 }
88
89
90 bool MathArray::empty() const
91 {
92         return bf_.empty();
93 }
94
95
96 MathArray::size_type MathArray::size() const
97 {
98         return bf_.size();
99 }
100
101
102 void MathArray::erase()
103 {
104         bf_.erase(begin(), end());
105 }
106
107
108 void MathArray::erase(size_type pos)
109 {
110         if (pos < size())
111                 erase(pos, pos + 1);
112 }
113
114
115 void MathArray::erase(iterator pos1, iterator pos2)
116 {
117         bf_.erase(pos1, pos2);
118 }
119
120
121 void MathArray::erase(iterator pos)
122 {
123         bf_.erase(pos);
124 }
125
126
127 void MathArray::erase(size_type pos1, size_type pos2)
128 {
129         bf_.erase(begin() + pos1, begin() + pos2);
130 }
131
132
133 MathAtom & MathArray::back()
134 {
135         return bf_.back();
136 }
137
138
139 MathAtom & MathArray::front()
140 {
141         return bf_.front();
142 }
143
144
145 MathAtom const & MathArray::front() const
146 {
147         return bf_.front();
148 }
149
150
151 void MathArray::dump2() const
152 {
153         NormalStream ns(lyxerr);
154         for (const_iterator it = begin(); it != end(); ++it)
155                 ns << it->nucleus() << ' ';
156 }
157
158
159 void MathArray::dump() const
160 {
161         NormalStream ns(lyxerr);
162         for (const_iterator it = begin(); it != end(); ++it)
163                 ns << "<" << it->nucleus() << ">";
164 }
165
166
167 void MathArray::validate(LaTeXFeatures & features) const
168 {
169         for (const_iterator it = begin(); it != end(); ++it)
170                 if (it->nucleus())
171                         it->nucleus()->validate(features);
172 }
173
174
175 void MathArray::pop_back()
176 {       
177         if (!size()) {
178                 lyxerr << "pop_back from empty array!\n";
179                 return;
180         }
181         bf_.pop_back();
182 }
183
184
185 MathArray::const_iterator MathArray::begin() const
186 {
187         return bf_.begin();
188 }
189
190
191 MathArray::const_iterator MathArray::end() const
192 {
193         return bf_.end();
194 }
195
196
197 MathArray::iterator MathArray::begin()
198 {
199         return bf_.begin();
200 }
201
202
203 MathArray::iterator MathArray::end()
204 {
205         return bf_.end();
206 }