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