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