6 #include "math_inset.h"
7 #include "math_deliminset.h"
8 #include "math_charinset.h"
9 #include "math_scriptinset.h"
10 #include "math_stringinset.h"
11 #include "math_matrixinset.h"
12 #include "math_mathmlstream.h"
13 #include "math_support.h"
14 #include "math_replace.h"
16 #include "support/LAssert.h"
19 MathArray::MathArray()
23 MathArray::MathArray(MathArray const & ar, size_type from, size_type to)
24 : bf_(ar.begin() + from, ar.begin() + to)
28 MathArray::MathArray(iterator from, iterator to)
33 void MathArray::substitute(MathMacro const & m)
35 for (iterator it = begin(); it != end(); ++it)
36 it->nucleus()->substitute(m);
40 MathAtom & MathArray::at(size_type pos)
42 lyx::Assert(pos < size());
47 MathAtom const & MathArray::at(size_type pos) const
49 lyx::Assert(pos < size());
54 void MathArray::insert(size_type pos, MathAtom const & t)
56 bf_.insert(begin() + pos, t);
60 void MathArray::insert(size_type pos, MathArray const & ar)
62 bf_.insert(begin() + pos, ar.begin(), ar.end());
66 void MathArray::push_back(MathAtom const & t)
72 void MathArray::push_back(MathArray const & ar)
78 void MathArray::clear()
84 void MathArray::swap(MathArray & ar)
91 bool MathArray::empty() const
97 MathArray::size_type MathArray::size() const
103 void MathArray::erase()
105 bf_.erase(begin(), end());
109 void MathArray::erase(size_type pos)
116 void MathArray::erase(iterator pos1, iterator pos2)
118 bf_.erase(pos1, pos2);
122 void MathArray::erase(iterator pos)
128 void MathArray::erase(size_type pos1, size_type pos2)
130 bf_.erase(begin() + pos1, begin() + pos2);
134 MathAtom & MathArray::back()
140 MathAtom & MathArray::front()
146 MathAtom const & MathArray::front() const
152 void MathArray::dump2() const
154 NormalStream ns(lyxerr);
155 for (const_iterator it = begin(); it != end(); ++it)
156 ns << it->nucleus() << ' ';
160 void MathArray::dump() const
162 NormalStream ns(lyxerr);
163 for (const_iterator it = begin(); it != end(); ++it)
164 ns << "<" << it->nucleus() << ">";
168 void MathArray::validate(LaTeXFeatures & features) const
170 for (const_iterator it = begin(); it != end(); ++it)
172 it->nucleus()->validate(features);
176 void MathArray::pop_back()
179 lyxerr << "pop_back from empty array!\n";
186 MathArray::const_iterator MathArray::begin() const
192 MathArray::const_iterator MathArray::end() const
198 MathArray::iterator MathArray::begin()
204 MathArray::iterator MathArray::end()
210 bool MathArray::match(MathArray const & ar) const
212 if (size() != ar.size())
214 for (const_iterator it = begin(), jt = ar.begin(); it != end(); ++it, ++jt)
215 if (!it->nucleus()->match(jt->nucleus()))
221 void MathArray::replace(ReplaceData & rep)
223 for (size_type i = 0; i < size(); ++i) {
224 iterator it = begin() + i;
225 const_iterator rt = rep.from.begin();
226 const_iterator et = rep.from.end();
227 for (const_iterator jt = it; jt != end() && rt != et; ++jt, ++rt)
228 if (!jt->nucleus()->match(rt->nucleus()))
232 lyxerr << "match found!\n";
233 erase(it, it + rep.from.size());
238 for (const_iterator it = begin(); it != end(); ++it)
239 it->nucleus()->replace(rep);