]> git.lyx.org Git - lyx.git/blob - src/mathed/math_mathmlstream.h
merge MathArray and MathXArray classes.
[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
16
17 //
18 //  MathML
19 //
20
21 struct MTag {
22         ///
23         MTag(char const * const tag) : tag_(tag) {}
24         ///
25         char const * const tag_;
26 };
27
28 struct ETag {
29         ///
30         ETag(char const * const tag) : tag_(tag) {}
31         ///
32         char const * const tag_;
33 };
34
35 class MathMLStream {
36 public:
37         ///
38         explicit MathMLStream(std::ostream & os);
39         ///
40         void cr();
41         ///
42         std::ostream & os() { return os_; }
43         ///
44         int line() const { return line_; }
45         ///
46         int & tab() { return tab_; }
47         ///
48         friend MathMLStream & operator<<(MathMLStream &, char const *);
49 private:
50         ///
51         std::ostream & os_;
52         ///
53         int tab_;
54         ///
55         int line_;
56         ///
57         char lastchar_;
58 };
59
60 ///
61 MathMLStream & operator<<(MathMLStream &, MathInset const *);
62 ///
63 MathMLStream & operator<<(MathMLStream &, MathArray const &);
64 ///
65 MathMLStream & operator<<(MathMLStream &, char const *);
66 ///
67 MathMLStream & operator<<(MathMLStream &, char);
68 ///
69 MathMLStream & operator<<(MathMLStream &, MTag const &);
70 ///
71 MathMLStream & operator<<(MathMLStream &, ETag const &);
72
73
74
75 //
76 // Debugging
77 //
78
79 class NormalStream {
80 public:
81         ///
82         explicit NormalStream(std::ostream & os) : os_(os) {}
83         ///
84         std::ostream & os() { return os_; }
85 private:
86         ///
87         std::ostream & os_;
88 };
89
90 ///
91 NormalStream & operator<<(NormalStream &, MathInset const *);
92 ///
93 NormalStream & operator<<(NormalStream &, MathArray const &);
94 ///
95 NormalStream & operator<<(NormalStream &, char const *);
96 ///
97 NormalStream & operator<<(NormalStream &, char);
98 ///
99 NormalStream & operator<<(NormalStream &, int);
100
101
102
103
104 //
105 // Maple
106 //
107
108
109 class MapleStream {
110 public:
111         ///
112         explicit MapleStream(std::ostream & os) : os_(os) {}
113         ///
114         std::ostream & os() { return os_; }
115 private:
116         ///
117         std::ostream & os_;
118 };
119
120
121 ///
122 MapleStream & operator<<(MapleStream &, MathInset const *);
123 ///
124 MapleStream & operator<<(MapleStream &, MathArray const &);
125 ///
126 MapleStream & operator<<(MapleStream &, char const *);
127 ///
128 MapleStream & operator<<(MapleStream &, char);
129 ///
130 MapleStream & operator<<(MapleStream &, int);
131
132
133 //
134 // Mathematica
135 //
136
137
138 class MathematicaStream {
139 public:
140         ///
141         explicit MathematicaStream(std::ostream & os) : os_(os) {}
142         ///
143         std::ostream & os() { return os_; }
144 private:
145         ///
146         std::ostream & os_;
147 };
148
149
150 ///
151 MathematicaStream & operator<<(MathematicaStream &, MathInset const *);
152 ///
153 MathematicaStream & operator<<(MathematicaStream &, MathArray const &);
154 ///
155 MathematicaStream & operator<<(MathematicaStream &, char const *);
156 ///
157 MathematicaStream & operator<<(MathematicaStream &, char);
158 ///
159 MathematicaStream & operator<<(MathematicaStream &, int);
160
161
162 //
163 // Octave
164 //
165
166
167 class OctaveStream {
168 public:
169         ///
170         explicit OctaveStream(std::ostream & os) : os_(os) {}
171         ///
172         std::ostream & os() { return os_; }
173 private:
174         ///
175         std::ostream & os_;
176 };
177
178 ///
179 OctaveStream & operator<<(OctaveStream &, MathInset const *);
180 ///
181 OctaveStream & operator<<(OctaveStream &, MathArray const &);
182 ///
183 OctaveStream & operator<<(OctaveStream &, char const *);
184 ///
185 OctaveStream & operator<<(OctaveStream &, char);
186 ///
187 OctaveStream & operator<<(OctaveStream &, int);
188
189
190
191 //
192 // LaTeX/LyX
193 //
194
195 class WriteStream {
196 public:
197         ///
198         WriteStream(std::ostream & os, bool fragile, bool latex);
199         ///
200         explicit WriteStream(std::ostream & os_);
201         ///
202         int line() const { return line_; }
203         ///
204         bool fragile() const { return fragile_; }
205         ///
206         bool latex() const { return latex_; }
207         ///
208         std::ostream & os() { return os_; }
209         ///
210         bool & firstitem() { return firstitem_; }
211         ///
212         void addlines(unsigned int);
213 private:
214         ///
215         std::ostream & os_;
216         ///
217         bool fragile_;
218         /// are we writing to .tex?
219         int latex_;
220         /// are we at the beginning of an MathArray?
221         bool firstitem_;
222         ///
223         int line_;
224 };
225
226 ///
227 WriteStream & operator<<(WriteStream &, MathInset const *);
228 ///
229 WriteStream & operator<<(WriteStream &, MathArray const &);
230 ///
231 WriteStream & operator<<(WriteStream &, char const *);
232 ///
233 WriteStream & operator<<(WriteStream &, char);
234 ///
235 WriteStream & operator<<(WriteStream &, int);
236 ///
237 WriteStream & operator<<(WriteStream &, unsigned int);
238
239 #endif