]> git.lyx.org Git - lyx.git/blob - src/mathed/math_mathmlstream.C
fixes/cleanup to dispatch/getStatus stuff; fixes the bug where unwanted function...
[lyx.git] / src / mathed / math_mathmlstream.C
1 #include <config.h>
2
3 #include "math_mathmlstream.h"
4 #include "math_inset.h"
5 #include "math_extern.h"
6 #include "debug.h"
7 #include "support/lstrings.h"
8
9 #include <algorithm>
10
11
12 MathMLStream::MathMLStream(std::ostream & os)
13         : os_(os), tab_(0), line_(0), lastchar_(0)
14 {}
15
16
17 MathMLStream & operator<<(MathMLStream & ms, MathInset const * p)
18 {
19         if (p)
20                 p->mathmlize(ms);
21         else
22                 lyxerr << "operator<<(MathMLStream, NULL) called\n";
23         return ms;
24 }
25
26
27 MathMLStream & operator<<(MathMLStream & ms, MathArray const & ar)
28 {
29         mathmlize(ar, ms);
30         return ms;
31 }
32
33
34 MathMLStream & operator<<(MathMLStream & ms, char const * s)
35 {
36         ms.os() << s;
37         return ms;
38 }
39
40
41 MathMLStream & operator<<(MathMLStream & ms, char c)
42 {
43         ms.os() << c;
44         return ms;
45 }
46
47
48 MathMLStream & operator<<(MathMLStream & ms, MTag const & t)
49 {
50         ++ms.tab();
51         ms.cr();
52         ms.os() << '<' << t.tag_ << '>';
53         return ms;
54 }
55
56
57 MathMLStream & operator<<(MathMLStream & ms, ETag const & t)
58 {
59         ms.cr();
60         if (ms.tab() > 0)
61                 --ms.tab();
62         ms.os() << "</" << t.tag_ << '>';
63         return ms;
64 }
65
66
67 void MathMLStream::cr()
68 {
69         os() << '\n';
70         for (int i = 0; i < tab(); ++i)
71                 os() << ' ';
72 }
73
74
75
76 //////////////////////////////////////////////////////////////////////
77
78
79 MapleStream & operator<<(MapleStream & ms, MathInset const * p)
80 {
81         if (p)
82                 p->maplize(ms);
83         else
84                 lyxerr << "operator<<(MapleStream, NULL) called\n";
85         return ms;
86 }
87
88
89 MapleStream & operator<<(MapleStream & ms, MathArray const & ar)
90 {
91         maplize(ar, ms);
92         return ms;
93 }
94
95
96 MapleStream & operator<<(MapleStream & ms, char const * s)
97 {
98         ms.os() << s;
99         return ms;
100 }
101
102
103 MapleStream & operator<<(MapleStream & ms, char c)
104 {
105         ms.os() << c;
106         return ms;
107 }
108
109
110 MapleStream & operator<<(MapleStream & ms, int i)
111 {
112         ms.os() << i;
113         return ms;
114 }
115
116
117 //////////////////////////////////////////////////////////////////////
118
119
120 OctaveStream & operator<<(OctaveStream & ns, MathInset const * p)
121 {
122         if (p)
123                 p->octavize(ns);
124         else
125                 lyxerr << "operator<<(OctaveStream, NULL) called\n";
126         return ns;
127 }
128
129
130 OctaveStream & operator<<(OctaveStream & ns, MathArray const & ar)
131 {
132         octavize(ar, ns);
133         return ns;
134 }
135
136
137 OctaveStream & operator<<(OctaveStream & ns, char const * s)
138 {
139         ns.os() << s;
140         return ns;
141 }
142
143
144 OctaveStream & operator<<(OctaveStream & ns, char c)
145 {
146         ns.os() << c;
147         return ns;
148 }
149
150
151 //////////////////////////////////////////////////////////////////////
152
153
154 NormalStream & operator<<(NormalStream & ns, MathInset const * p)
155 {
156         if (p)
157                 p->normalize(ns);
158         else
159                 lyxerr << "operator<<(NormalStream, NULL) called\n";
160         return ns;
161 }
162
163
164 NormalStream & operator<<(NormalStream & ns, MathArray const & ar)
165 {
166         normalize(ar, ns);
167         return ns;
168 }
169
170
171 NormalStream & operator<<(NormalStream & ns, char const * s)
172 {
173         ns.os() << s;
174         return ns;
175 }
176
177
178 NormalStream & operator<<(NormalStream & ns, char c)
179 {
180         ns.os() << c;
181         return ns;
182 }
183
184
185
186 //////////////////////////////////////////////////////////////////////
187
188
189 WriteStream::WriteStream(std::ostream & os, bool fragile)
190         : os_(os), fragile_(fragile), firstitem_(false), line_(0)
191 {}
192
193
194 WriteStream::WriteStream(std::ostream & os)
195         : os_(os), fragile_(false), firstitem_(false), line_(0)
196 {}
197
198
199 void WriteStream::addlines(unsigned int n)
200 {
201         line_ += n;
202 }
203
204
205 WriteStream & operator<<(WriteStream & ws, MathInset const * p)
206 {
207         if (p)
208                 p->write(ws);
209         else
210                 lyxerr << "operator<<(WriteStream, NULL) called\n";
211         return ws;
212 }
213
214
215 WriteStream & operator<<(WriteStream & ws, MathArray const & ar)
216 {
217         write(ar, ws);
218         return ws;
219 }
220
221
222 WriteStream & operator<<(WriteStream & ws, char const * s)
223 {
224         ws.os() << s;
225         ws.addlines(int(countChar(s, '\n')));
226         return ws;
227 }
228
229
230 WriteStream & operator<<(WriteStream & ws, char c)
231 {
232         ws.os() << c;
233         if (c == '\n')
234                 ws.addlines(1);
235         return ws;
236 }
237
238
239 WriteStream & operator<<(WriteStream & ws, int i)
240 {
241         ws.os() << i;
242         return ws;
243 }
244
245
246 WriteStream & operator<<(WriteStream & ws, unsigned int i)
247 {
248         ws.os() << i;
249         return ws;
250 }