5 #include "math_inset.h"
6 #include "math_charinset.h"
9 #include "math_scriptinset.h"
10 #include "mathed/support.h"
15 MathArray::MathArray()
19 MathArray::~MathArray()
25 MathArray::MathArray(MathArray const & array)
32 MathArray::MathArray(MathArray const & array, int from, int to)
33 : bf_(array.bf_.begin() + from, array.bf_.begin() + to)
39 void MathArray::deep_copy(int pos1, int pos2)
41 for (int pos = pos1; pos < pos2; ++pos) {
42 MathInset * p = bf_[pos]->clone();
43 //lyxerr << "cloning: '" << bf_[pos] << " to " << p << "'\n";
49 int MathArray::last() const
55 void MathArray::substitute(MathMacro const & m)
58 for (int pos = 0; pos < size(); ++pos)
59 bf_[pos]->substitute(tmp, m);
64 MathArray & MathArray::operator=(MathArray const & array)
72 MathInset * MathArray::nextInset(int pos)
74 return (pos == size()) ? 0 : bf_[pos];
78 MathInset const * MathArray::nextInset(int pos) const
80 return (pos == size()) ? 0 : bf_[pos];
84 unsigned char MathArray::getChar(int pos) const
86 return (pos == size()) ? 0 : (bf_[pos]->getChar());
90 MathTextCodes MathArray::getCode(int pos) const
92 return pos < size() ? (bf_[pos]->code()) : LM_TC_MIN;
96 void MathArray::setCode(int pos, MathTextCodes t)
102 void MathArray::insert(int pos, MathInset * p)
104 bf_.insert(bf_.begin() + pos, p);
108 void MathArray::insert(int pos, unsigned char b, MathTextCodes t)
110 bf_.insert(bf_.begin() + pos, new MathCharInset(b, t));
114 void MathArray::insert(int pos, MathArray const & array)
116 bf_.insert(bf_.begin() + pos, array.bf_.begin(), array.bf_.end());
117 deep_copy(pos, pos + array.size());
121 void MathArray::push_back(MathInset * p)
127 void MathArray::push_back(unsigned char b, MathTextCodes c)
129 insert(size(), b, c);
133 void MathArray::push_back(MathArray const & array)
135 insert(size(), array);
139 void MathArray::clear()
145 void MathArray::swap(MathArray & array)
152 bool MathArray::empty() const
158 int MathArray::size() const
164 void MathArray::erase()
170 void MathArray::erase(int pos)
177 void MathArray::erase(int pos1, int pos2)
179 for (int pos = pos1; pos < pos2; ++pos)
181 bf_.erase(bf_.begin() + pos1, bf_.begin() + pos2);
185 MathInset * MathArray::back() const
187 return size() ? bf_.back() : 0;
191 void MathArray::dump2(ostream & os) const
193 for (buffer_type::const_iterator it = bf_.begin(); it != bf_.end(); ++it)
198 void MathArray::dump(ostream & os) const
200 for (int pos = 0; pos < size(); ++pos)
201 os << "<" << nextInset(pos) << ">";
205 std::ostream & operator<<(std::ostream & os, MathArray const & ar)
212 void MathArray::write(ostream & os, bool fragile) const
214 for (int pos = 0; pos < size(); ++pos)
215 nextInset(pos)->write(os, fragile);
219 void MathArray::writeNormal(ostream & os) const
230 void MathArray::validate(LaTeXFeatures & features) const
232 for (int pos = 0; pos < size(); ++pos)
233 nextInset(pos)->validate(features);
237 void MathArray::pop_back()
240 lyxerr << "pop_back from empty array!\n";