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