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