]> git.lyx.org Git - lyx.git/blob - src/mathed/math_mathmlstream.h
temporary reversal of the 'don't write spaces' stuff as this was buggy...
[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
162 //
163 // Maple
164 //
165
166
167 class MapleStream {
168 public:
169         ///
170         explicit MapleStream(std::ostream & os) : os_(os) {}
171         ///
172         std::ostream & os() { return os_; }
173 private:
174         ///
175         std::ostream & os_;
176 };
177
178
179 ///
180 MapleStream & operator<<(MapleStream &, MathAtom const &);
181 ///
182 MapleStream & operator<<(MapleStream &, MathArray const &);
183 ///
184 MapleStream & operator<<(MapleStream &, char const *);
185 ///
186 MapleStream & operator<<(MapleStream &, char);
187 ///
188 MapleStream & operator<<(MapleStream &, int);
189
190
191 //
192 // Mathematica
193 //
194
195
196 class MathematicaStream {
197 public:
198         ///
199         explicit MathematicaStream(std::ostream & os) : os_(os) {}
200         ///
201         std::ostream & os() { return os_; }
202 private:
203         ///
204         std::ostream & os_;
205 };
206
207
208 ///
209 MathematicaStream & operator<<(MathematicaStream &, MathAtom const &);
210 ///
211 MathematicaStream & operator<<(MathematicaStream &, MathArray const &);
212 ///
213 MathematicaStream & operator<<(MathematicaStream &, char const *);
214 ///
215 MathematicaStream & operator<<(MathematicaStream &, char);
216 ///
217 MathematicaStream & operator<<(MathematicaStream &, int);
218
219
220 //
221 // Octave
222 //
223
224
225 class OctaveStream {
226 public:
227         ///
228         explicit OctaveStream(std::ostream & os) : os_(os) {}
229         ///
230         std::ostream & os() { return os_; }
231 private:
232         ///
233         std::ostream & os_;
234 };
235
236 ///
237 OctaveStream & operator<<(OctaveStream &, MathAtom const &);
238 ///
239 OctaveStream & operator<<(OctaveStream &, MathArray const &);
240 ///
241 OctaveStream & operator<<(OctaveStream &, char const *);
242 ///
243 OctaveStream & operator<<(OctaveStream &, char);
244 ///
245 OctaveStream & operator<<(OctaveStream &, int);
246
247
248
249 #endif