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