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