]> git.lyx.org Git - lyx.git/blob - src/mathed/math_data.C
some support for matrix operations with maple ('M-x math-extern maple evalm')
[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 void MathArray::substitute(MathMacro const & m)
28 {
29         for (iterator it = begin(); it != end(); ++it)
30                 it->nucleus()->substitute(m);
31 }
32
33
34 MathAtom & MathArray::at(size_type pos)
35 {
36         lyx::Assert(pos < size());
37         return bf_[pos];
38 }
39
40
41 MathAtom const & MathArray::at(size_type pos) const
42 {
43         lyx::Assert(pos < size());
44         return bf_[pos];
45 }
46
47
48 void MathArray::insert(size_type pos, MathAtom const & t)
49 {
50         bf_.insert(begin() + pos, t);
51 }
52
53
54 void MathArray::insert(size_type pos, MathArray const & ar)
55 {
56         bf_.insert(begin() + pos, ar.begin(), ar.end());
57 }
58
59
60 void MathArray::push_back(MathAtom const & t)
61 {       
62         bf_.push_back(t);
63 }
64
65
66 void MathArray::push_back(MathArray const & ar)
67 {
68         insert(size(), ar);
69 }
70
71
72 void MathArray::clear()
73 {
74         erase();
75 }
76
77
78 void MathArray::swap(MathArray & ar)
79 {
80         if (this != &ar) 
81                 bf_.swap(ar.bf_);
82 }
83
84
85 bool MathArray::empty() const
86 {
87         return bf_.empty();
88 }
89
90
91 MathArray::size_type MathArray::size() const
92 {
93         return bf_.size();
94 }
95
96
97 void MathArray::erase()
98 {
99         erase(0, size());
100 }
101
102
103 void MathArray::erase(size_type pos)
104 {
105         if (pos < size())
106                 erase(pos, pos + 1);
107 }
108
109
110 void MathArray::erase(size_type pos1, size_type pos2)
111 {
112         bf_.erase(begin() + pos1, begin() + pos2);
113 }
114
115
116 MathAtom & MathArray::back()
117 {
118         return bf_.back();
119 }
120
121
122 void MathArray::dump2() const
123 {
124         NormalStream ns(lyxerr);
125         for (const_iterator it = begin(); it != end(); ++it)
126                 ns << it->nucleus() << ' ';
127 }
128
129
130 void MathArray::dump() const
131 {
132         NormalStream ns(lyxerr);
133         for (const_iterator it = begin(); it != end(); ++it)
134                 ns << "<" << it->nucleus() << ">";
135 }
136
137
138 void MathArray::validate(LaTeXFeatures & features) const
139 {
140         for (const_iterator it = begin(); it != end(); ++it)
141                 if (it->nucleus())
142                         it->nucleus()->validate(features);
143 }
144
145
146 void MathArray::pop_back()
147 {       
148         if (!size()) {
149                 lyxerr << "pop_back from empty array!\n";
150                 return;
151         }
152         bf_.pop_back();
153 }
154
155
156 MathArray::const_iterator MathArray::begin() const
157 {
158         return bf_.begin();
159 }
160
161
162 MathArray::const_iterator MathArray::end() const
163 {
164         return bf_.end();
165 }
166
167
168 MathArray::iterator MathArray::begin()
169 {
170         return bf_.begin();
171 }
172
173
174 MathArray::iterator MathArray::end()
175 {
176         return bf_.end();
177 }