]> git.lyx.org Git - lyx.git/blob - src/mathed/math_mathmlstream.h
some (yet unfinished) up/down work
[lyx.git] / src / mathed / math_mathmlstream.h
1 // -*- C++ -*-
2 /**
3  * \file math_mathmlstream.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author André Pönitz
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef MATH_MATHMLSTREAM_H
13 #define MATH_MATHMLSTREAM_H
14
15
16 // Please keep all four streams in one file until the interface has
17 // settled.
18
19
20 #include "metricsinfo.h"
21
22 #include <iosfwd>
23
24 class MathArray;
25 class MathInset;
26 class MathAtom;
27
28 //
29 // LaTeX/LyX
30 //
31
32 class WriteStream {
33 public:
34         ///
35         WriteStream(std::ostream & os, bool fragile, bool latex);
36         ///
37         explicit WriteStream(std::ostream & os);
38         ///
39         ~WriteStream();
40         ///
41         int line() const { return line_; }
42         ///
43         bool fragile() const { return fragile_; }
44         ///
45         bool latex() const { return latex_; }
46         ///
47         std::ostream & os() { return os_; }
48         ///
49         bool & firstitem() { return firstitem_; }
50         ///
51         void addlines(unsigned int);
52         /// writes space if next thing is isalpha()
53         void pendingSpace(bool how);
54         /// writes space if next thing is isalpha()
55         bool pendingSpace() const { return pendingspace_; }
56 private:
57         ///
58         std::ostream & os_;
59         /// do we have to write \\protect sometimes
60         bool fragile_;
61         /// are we at the beginning of an MathArray?
62         bool firstitem_;
63         /// are we writing to .tex?
64         int latex_;
65         /// do we have a space pending?
66         bool pendingspace_;
67         ///
68         int line_;
69 };
70
71 ///
72 WriteStream & operator<<(WriteStream &, MathAtom const &);
73 ///
74 WriteStream & operator<<(WriteStream &, MathArray const &);
75 ///
76 WriteStream & operator<<(WriteStream &, char const *);
77 ///
78 WriteStream & operator<<(WriteStream &, char);
79 ///
80 WriteStream & operator<<(WriteStream &, int);
81 ///
82 WriteStream & operator<<(WriteStream &, unsigned int);
83
84
85
86 //
87 //  MathML
88 //
89
90 class MTag {
91 public:
92         ///
93         MTag(char const * const tag) : tag_(tag) {}
94         ///
95         char const * const tag_;
96 };
97
98 class ETag {
99 public:
100         ///
101         ETag(char const * const tag) : tag_(tag) {}
102         ///
103         char const * const tag_;
104 };
105
106 class MathMLStream {
107 public:
108         ///
109         explicit MathMLStream(std::ostream & os);
110         ///
111         void cr();
112         ///
113         std::ostream & os() { return os_; }
114         ///
115         int line() const { return line_; }
116         ///
117         int & tab() { return tab_; }
118         ///
119         friend MathMLStream & operator<<(MathMLStream &, char const *);
120 private:
121         ///
122         std::ostream & os_;
123         ///
124         int tab_;
125         ///
126         int line_;
127         ///
128         char lastchar_;
129 };
130
131 ///
132 MathMLStream & operator<<(MathMLStream &, MathAtom const &);
133 ///
134 MathMLStream & operator<<(MathMLStream &, MathArray const &);
135 ///
136 MathMLStream & operator<<(MathMLStream &, char const *);
137 ///
138 MathMLStream & operator<<(MathMLStream &, char);
139 ///
140 MathMLStream & operator<<(MathMLStream &, MTag const &);
141 ///
142 MathMLStream & operator<<(MathMLStream &, ETag const &);
143
144
145
146 //
147 // Debugging
148 //
149
150 class NormalStream {
151 public:
152         ///
153         explicit NormalStream(std::ostream & os) : os_(os) {}
154         ///
155         std::ostream & os() { return os_; }
156 private:
157         ///
158         std::ostream & os_;
159 };
160
161 ///
162 NormalStream & operator<<(NormalStream &, MathAtom const &);
163 ///
164 NormalStream & operator<<(NormalStream &, MathArray const &);
165 ///
166 NormalStream & operator<<(NormalStream &, char const *);
167 ///
168 NormalStream & operator<<(NormalStream &, char);
169 ///
170 NormalStream & operator<<(NormalStream &, int);
171
172
173 //
174 // Maple
175 //
176
177
178 class MapleStream {
179 public:
180         ///
181         explicit MapleStream(std::ostream & os) : os_(os) {}
182         ///
183         std::ostream & os() { return os_; }
184 private:
185         ///
186         std::ostream & os_;
187 };
188
189
190 ///
191 MapleStream & operator<<(MapleStream &, MathAtom const &);
192 ///
193 MapleStream & operator<<(MapleStream &, MathArray const &);
194 ///
195 MapleStream & operator<<(MapleStream &, char const *);
196 ///
197 MapleStream & operator<<(MapleStream &, char);
198 ///
199 MapleStream & operator<<(MapleStream &, int);
200
201
202 //
203 // Maxima
204 //
205
206
207 class MaximaStream {
208 public:
209         ///
210         explicit MaximaStream(std::ostream & os) : os_(os) {}
211         ///
212         std::ostream & os() { return os_; }
213 private:
214         ///
215         std::ostream & os_;
216 };
217
218
219 ///
220 MaximaStream & operator<<(MaximaStream &, MathAtom const &);
221 ///
222 MaximaStream & operator<<(MaximaStream &, MathArray const &);
223 ///
224 MaximaStream & operator<<(MaximaStream &, char const *);
225 ///
226 MaximaStream & operator<<(MaximaStream &, char);
227 ///
228 MaximaStream & operator<<(MaximaStream &, int);
229
230
231 //
232 // Mathematica
233 //
234
235
236 class MathematicaStream {
237 public:
238         ///
239         explicit MathematicaStream(std::ostream & os) : os_(os) {}
240         ///
241         std::ostream & os() { return os_; }
242 private:
243         ///
244         std::ostream & os_;
245 };
246
247
248 ///
249 MathematicaStream & operator<<(MathematicaStream &, MathAtom const &);
250 ///
251 MathematicaStream & operator<<(MathematicaStream &, MathArray const &);
252 ///
253 MathematicaStream & operator<<(MathematicaStream &, char const *);
254 ///
255 MathematicaStream & operator<<(MathematicaStream &, char);
256 ///
257 MathematicaStream & operator<<(MathematicaStream &, int);
258
259
260 //
261 // Octave
262 //
263
264
265 class OctaveStream {
266 public:
267         ///
268         explicit OctaveStream(std::ostream & os) : os_(os) {}
269         ///
270         std::ostream & os() { return os_; }
271 private:
272         ///
273         std::ostream & os_;
274 };
275
276 ///
277 OctaveStream & operator<<(OctaveStream &, MathAtom const &);
278 ///
279 OctaveStream & operator<<(OctaveStream &, MathArray const &);
280 ///
281 OctaveStream & operator<<(OctaveStream &, char const *);
282 ///
283 OctaveStream & operator<<(OctaveStream &, char);
284 ///
285 OctaveStream & operator<<(OctaveStream &, int);
286
287
288
289 #endif