]> git.lyx.org Git - lyx.git/blob - src/mathed/math_mathmlstream.C
remove hard-wired association LaTeX macro <-> mathed inset
[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/lyxalgo.h"
8
9
10 using std::ostream;
11 using std::strlen;
12
13
14 MathMLStream::MathMLStream(ostream & os)
15         : os_(os), tab_(0), line_(0), lastchar_(0)
16 {}
17
18
19 MathMLStream & operator<<(MathMLStream & ms, MathInset const * p)
20 {
21         if (p)
22                 p->mathmlize(ms);
23         else
24                 lyxerr << "operator<<(MathMLStream, NULL) called\n";
25         return ms;
26 }
27
28
29 MathMLStream & operator<<(MathMLStream & ms, MathArray const & ar)
30 {
31         mathmlize(ar, ms);
32         return ms;
33 }
34
35
36 MathMLStream & operator<<(MathMLStream & ms, char const * s)
37 {
38         ms.os() << s;
39         return ms;
40 }
41
42
43 MathMLStream & operator<<(MathMLStream & ms, char c)
44 {
45         ms.os() << c;
46         return ms;
47 }
48
49
50 MathMLStream & operator<<(MathMLStream & ms, MTag const & t)
51 {
52         ++ms.tab();
53         ms.cr();
54         ms.os() << '<' << t.tag_ << '>';
55         return ms;
56 }
57
58
59 MathMLStream & operator<<(MathMLStream & ms, ETag const & t)
60 {
61         ms.cr();
62         if (ms.tab() > 0)
63                 --ms.tab();
64         ms.os() << "</" << t.tag_ << '>';
65         return ms;
66 }
67
68
69 void MathMLStream::cr()
70 {
71         os() << '\n';
72         for (int i = 0; i < tab(); ++i)
73                 os() << ' ';
74 }
75
76
77
78 //////////////////////////////////////////////////////////////////////
79
80
81 MapleStream & operator<<(MapleStream & ms, MathInset const * p)
82 {
83         if (p)
84                 p->maplize(ms);
85         else
86                 lyxerr << "operator<<(MapleStream, NULL) called\n";
87         return ms;
88 }
89
90
91 MapleStream & operator<<(MapleStream & ms, MathArray const & ar)
92 {
93         maplize(ar, ms);
94         return ms;
95 }
96
97
98 MapleStream & operator<<(MapleStream & ms, char const * s)
99 {
100         ms.os() << s;
101         return ms;
102 }
103
104
105 MapleStream & operator<<(MapleStream & ms, char c)
106 {
107         ms.os() << c;
108         return ms;
109 }
110
111
112 MapleStream & operator<<(MapleStream & ms, int i)
113 {
114         ms.os() << i;
115         return ms;
116 }
117
118
119 //////////////////////////////////////////////////////////////////////
120
121
122 MathematicaStream & operator<<(MathematicaStream & ms, MathInset const * p)
123 {
124         if (p)
125                 p->mathematicize(ms);
126         else
127                 lyxerr << "operator<<(MathematicaStream, NULL) called\n";
128         return ms;
129 }
130
131
132 MathematicaStream & operator<<(MathematicaStream & ms, MathArray const & ar)
133 {
134         mathematicize(ar, ms);
135         return ms;
136 }
137
138
139 MathematicaStream & operator<<(MathematicaStream & ms, char const * s)
140 {
141         ms.os() << s;
142         return ms;
143 }
144
145
146 MathematicaStream & operator<<(MathematicaStream & ms, char c)
147 {
148         ms.os() << c;
149         return ms;
150 }
151
152
153 MathematicaStream & operator<<(MathematicaStream & ms, int i)
154 {
155         ms.os() << i;
156         return ms;
157 }
158
159
160
161 //////////////////////////////////////////////////////////////////////
162
163
164 OctaveStream & operator<<(OctaveStream & ns, MathInset const * p)
165 {
166         if (p)
167                 p->octavize(ns);
168         else
169                 lyxerr << "operator<<(OctaveStream, NULL) called\n";
170         return ns;
171 }
172
173
174 OctaveStream & operator<<(OctaveStream & ns, MathArray const & ar)
175 {
176         octavize(ar, ns);
177         return ns;
178 }
179
180
181 OctaveStream & operator<<(OctaveStream & ns, char const * s)
182 {
183         ns.os() << s;
184         return ns;
185 }
186
187
188 OctaveStream & operator<<(OctaveStream & ns, char c)
189 {
190         ns.os() << c;
191         return ns;
192 }
193
194
195 OctaveStream & operator<<(OctaveStream & ns, int i)
196 {
197         ns.os() << i;
198         return ns;
199 }
200
201
202 //////////////////////////////////////////////////////////////////////
203
204
205 NormalStream & operator<<(NormalStream & ns, MathInset const * p)
206 {
207         if (p)
208                 p->normalize(ns);
209         else
210                 lyxerr << "operator<<(NormalStream, NULL) called\n";
211         return ns;
212 }
213
214
215 NormalStream & operator<<(NormalStream & ns, MathArray const & ar)
216 {
217         normalize(ar, ns);
218         return ns;
219 }
220
221
222 NormalStream & operator<<(NormalStream & ns, char const * s)
223 {
224         ns.os() << s;
225         return ns;
226 }
227
228
229 NormalStream & operator<<(NormalStream & ns, char c)
230 {
231         ns.os() << c;
232         return ns;
233 }
234
235
236 NormalStream & operator<<(NormalStream & ns, int i)
237 {
238         ns.os() << i;
239         return ns;
240 }
241
242
243
244 //////////////////////////////////////////////////////////////////////
245
246
247 WriteStream::WriteStream(ostream & os, bool fragile, bool latex)
248         : os_(os), fragile_(fragile), latex_(latex), firstitem_(false), line_(0)
249 {}
250
251
252 WriteStream::WriteStream(ostream & os)
253         : os_(os), fragile_(false), latex_(false), firstitem_(false), line_(0)
254 {}
255
256
257 void WriteStream::addlines(unsigned int n)
258 {
259         line_ += n;
260 }
261
262
263 WriteStream & operator<<(WriteStream & ws, MathInset const * p)
264 {
265         if (p)
266                 p->write(ws);
267         else
268                 lyxerr << "operator<<(WriteStream, NULL) called\n";
269         return ws;
270 }
271
272
273 WriteStream & operator<<(WriteStream & ws, MathArray const & ar)
274 {
275         write(ar, ws);
276         return ws;
277 }
278
279
280 WriteStream & operator<<(WriteStream & ws, char const * s)
281 {
282         ws.os() << s;
283         ws.addlines(int(lyx::count(s, s+strlen(s), '\n')));
284         return ws;
285 }
286
287
288 WriteStream & operator<<(WriteStream & ws, char c)
289 {
290         ws.os() << c;
291         if (c == '\n')
292                 ws.addlines(1);
293         return ws;
294 }
295
296
297 WriteStream & operator<<(WriteStream & ws, int i)
298 {
299         ws.os() << i;
300         return ws;
301 }
302
303
304 WriteStream & operator<<(WriteStream & ws, unsigned int i)
305 {
306         ws.os() << i;
307         return ws;
308 }