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