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