]> git.lyx.org Git - lyx.git/blob - src/mathed/math_mathmlstream.h
9f1ac9fed24646523888050a6b6349a8d51cedaa
[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         int line() const { return line_; }
29         ///
30         bool fragile() const { return fragile_; }
31         ///
32         bool latex() const { return latex_; }
33         ///
34         std::ostream & os() { return os_; }
35         ///
36         bool & firstitem() { return firstitem_; }
37         ///
38         void addlines(unsigned int);
39         /// writes space if next thing is isalpha()
40         void pendingSpace(bool how) { pendingspace_ = how; }
41         /// writes space if next thing is isalpha()
42         bool pendingSpace() const { return pendingspace_; }
43 private:
44         ///
45         std::ostream & os_;
46         /// do we have to write \\protect sometimes
47         bool fragile_;
48         /// are we at the beginning of an MathArray?
49         bool firstitem_;
50         /// are we writing to .tex?
51         int latex_;
52         /// do we have a space pending?
53         bool pendingspace_;
54         ///
55         int line_;
56 };
57
58 ///
59 WriteStream & operator<<(WriteStream &, MathAtom const &);
60 ///
61 WriteStream & operator<<(WriteStream &, MathArray const &);
62 ///
63 WriteStream & operator<<(WriteStream &, char const *);
64 ///
65 WriteStream & operator<<(WriteStream &, char);
66 ///
67 WriteStream & operator<<(WriteStream &, int);
68 ///
69 WriteStream & operator<<(WriteStream &, unsigned int);
70
71
72
73 //
74 //  MathML
75 //
76
77 struct MTag {
78         ///
79         MTag(char const * const tag) : tag_(tag) {}
80         ///
81         char const * const tag_;
82 };
83
84 struct ETag {
85         ///
86         ETag(char const * const tag) : tag_(tag) {}
87         ///
88         char const * const tag_;
89 };
90
91 class MathMLStream {
92 public:
93         ///
94         explicit MathMLStream(std::ostream & os);
95         ///
96         void cr();
97         ///
98         std::ostream & os() { return os_; }
99         ///
100         int line() const { return line_; }
101         ///
102         int & tab() { return tab_; }
103         ///
104         friend MathMLStream & operator<<(MathMLStream &, char const *);
105 private:
106         ///
107         std::ostream & os_;
108         ///
109         int tab_;
110         ///
111         int line_;
112         ///
113         char lastchar_;
114 };
115
116 ///
117 MathMLStream & operator<<(MathMLStream &, MathAtom const &);
118 ///
119 MathMLStream & operator<<(MathMLStream &, MathArray const &);
120 ///
121 MathMLStream & operator<<(MathMLStream &, char const *);
122 ///
123 MathMLStream & operator<<(MathMLStream &, char);
124 ///
125 MathMLStream & operator<<(MathMLStream &, MTag const &);
126 ///
127 MathMLStream & operator<<(MathMLStream &, ETag const &);
128
129
130
131 //
132 // Debugging
133 //
134
135 class NormalStream {
136 public:
137         ///
138         explicit NormalStream(std::ostream & os) : os_(os) {}
139         ///
140         std::ostream & os() { return os_; }
141 private:
142         ///
143         std::ostream & os_;
144 };
145
146 ///
147 NormalStream & operator<<(NormalStream &, MathAtom const &);
148 ///
149 NormalStream & operator<<(NormalStream &, MathArray const &);
150 ///
151 NormalStream & operator<<(NormalStream &, char const *);
152 ///
153 NormalStream & operator<<(NormalStream &, char);
154 ///
155 NormalStream & operator<<(NormalStream &, int);
156
157
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 // Mathematica
191 //
192
193
194 class MathematicaStream {
195 public:
196         ///
197         explicit MathematicaStream(std::ostream & os) : os_(os) {}
198         ///
199         std::ostream & os() { return os_; }
200 private:
201         ///
202         std::ostream & os_;
203 };
204
205
206 ///
207 MathematicaStream & operator<<(MathematicaStream &, MathAtom const &);
208 ///
209 MathematicaStream & operator<<(MathematicaStream &, MathArray const &);
210 ///
211 MathematicaStream & operator<<(MathematicaStream &, char const *);
212 ///
213 MathematicaStream & operator<<(MathematicaStream &, char);
214 ///
215 MathematicaStream & operator<<(MathematicaStream &, int);
216
217
218 //
219 // Octave
220 //
221
222
223 class OctaveStream {
224 public:
225         ///
226         explicit OctaveStream(std::ostream & os) : os_(os) {}
227         ///
228         std::ostream & os() { return os_; }
229 private:
230         ///
231         std::ostream & os_;
232 };
233
234 ///
235 OctaveStream & operator<<(OctaveStream &, MathAtom const &);
236 ///
237 OctaveStream & operator<<(OctaveStream &, MathArray const &);
238 ///
239 OctaveStream & operator<<(OctaveStream &, char const *);
240 ///
241 OctaveStream & operator<<(OctaveStream &, char);
242 ///
243 OctaveStream & operator<<(OctaveStream &, int);
244
245
246
247 #endif