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