]> git.lyx.org Git - lyx.git/blob - src/mathed/math_mathmlstream.h
Add In nsetOld * argument to updateInset to rebreak the correct par.
[lyx.git] / src / mathed / math_mathmlstream.h
1 // -*- C++ -*-
2 /**
3  * \file math_mathmlstream.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author André Pönitz
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef MATH_MATHMLSTREAM_H
13 #define MATH_MATHMLSTREAM_H
14
15
16 // Please keep all four streams in one file until the interface has
17 // settled.
18
19
20 #include "metricsinfo.h"
21
22 #include <iosfwd>
23
24 class MathArray;
25 class MathInset;
26 class MathAtom;
27
28 //
29 // LaTeX/LyX
30 //
31
32 class WriteStream {
33 public:
34         ///
35         WriteStream(std::ostream & os, bool fragile, bool latex);
36         ///
37         explicit WriteStream(std::ostream & os_);
38         ///
39         ~WriteStream();
40         ///
41         int line() const { return line_; }
42         ///
43         bool fragile() const { return fragile_; }
44         ///
45         bool latex() const { return latex_; }
46         ///
47         std::ostream & os() { return os_; }
48         ///
49         bool & firstitem() { return firstitem_; }
50         ///
51         void addlines(unsigned int);
52         /// writes space if next thing is isalpha()
53         void pendingSpace(bool how);
54         /// writes space if next thing is isalpha()
55         bool pendingSpace() const { return pendingspace_; }
56 private:
57         ///
58         std::ostream & os_;
59         /// do we have to write \\protect sometimes
60         bool fragile_;
61         /// are we at the beginning of an MathArray?
62         bool firstitem_;
63         /// are we writing to .tex?
64         int latex_;
65         /// do we have a space pending?
66         bool pendingspace_;
67         ///
68         int line_;
69 };
70
71 ///
72 WriteStream & operator<<(WriteStream &, MathAtom const &);
73 ///
74 WriteStream & operator<<(WriteStream &, MathArray const &);
75 ///
76 WriteStream & operator<<(WriteStream &, char const *);
77 ///
78 WriteStream & operator<<(WriteStream &, char);
79 ///
80 WriteStream & operator<<(WriteStream &, int);
81 ///
82 WriteStream & operator<<(WriteStream &, unsigned int);
83
84
85
86 //
87 //  MathML
88 //
89
90 struct MTag {
91         ///
92         MTag(char const * const tag) : tag_(tag) {}
93         ///
94         char const * const tag_;
95 };
96
97 struct ETag {
98         ///
99         ETag(char const * const tag) : tag_(tag) {}
100         ///
101         char const * const tag_;
102 };
103
104 class MathMLStream {
105 public:
106         ///
107         explicit MathMLStream(std::ostream & os);
108         ///
109         void cr();
110         ///
111         std::ostream & os() { return os_; }
112         ///
113         int line() const { return line_; }
114         ///
115         int & tab() { return tab_; }
116         ///
117         friend MathMLStream & operator<<(MathMLStream &, char const *);
118 private:
119         ///
120         std::ostream & os_;
121         ///
122         int tab_;
123         ///
124         int line_;
125         ///
126         char lastchar_;
127 };
128
129 ///
130 MathMLStream & operator<<(MathMLStream &, MathAtom const &);
131 ///
132 MathMLStream & operator<<(MathMLStream &, MathArray const &);
133 ///
134 MathMLStream & operator<<(MathMLStream &, char const *);
135 ///
136 MathMLStream & operator<<(MathMLStream &, char);
137 ///
138 MathMLStream & operator<<(MathMLStream &, MTag const &);
139 ///
140 MathMLStream & operator<<(MathMLStream &, ETag const &);
141
142
143
144 //
145 // Debugging
146 //
147
148 class NormalStream {
149 public:
150         ///
151         explicit NormalStream(std::ostream & os) : os_(os) {}
152         ///
153         std::ostream & os() { return os_; }
154 private:
155         ///
156         std::ostream & os_;
157 };
158
159 ///
160 NormalStream & operator<<(NormalStream &, MathAtom const &);
161 ///
162 NormalStream & operator<<(NormalStream &, MathArray const &);
163 ///
164 NormalStream & operator<<(NormalStream &, char const *);
165 ///
166 NormalStream & operator<<(NormalStream &, char);
167 ///
168 NormalStream & operator<<(NormalStream &, int);
169
170
171 //
172 // Maple
173 //
174
175
176 class MapleStream {
177 public:
178         ///
179         explicit MapleStream(std::ostream & os) : os_(os) {}
180         ///
181         std::ostream & os() { return os_; }
182 private:
183         ///
184         std::ostream & os_;
185 };
186
187
188 ///
189 MapleStream & operator<<(MapleStream &, MathAtom const &);
190 ///
191 MapleStream & operator<<(MapleStream &, MathArray const &);
192 ///
193 MapleStream & operator<<(MapleStream &, char const *);
194 ///
195 MapleStream & operator<<(MapleStream &, char);
196 ///
197 MapleStream & operator<<(MapleStream &, int);
198
199
200 //
201 // Maxima
202 //
203
204
205 class MaximaStream {
206 public:
207         ///
208         explicit MaximaStream(std::ostream & os) : os_(os) {}
209         ///
210         std::ostream & os() { return os_; }
211 private:
212         ///
213         std::ostream & os_;
214 };
215
216
217 ///
218 MaximaStream & operator<<(MaximaStream &, MathAtom const &);
219 ///
220 MaximaStream & operator<<(MaximaStream &, MathArray const &);
221 ///
222 MaximaStream & operator<<(MaximaStream &, char const *);
223 ///
224 MaximaStream & operator<<(MaximaStream &, char);
225 ///
226 MaximaStream & operator<<(MaximaStream &, int);
227
228
229 //
230 // Mathematica
231 //
232
233
234 class MathematicaStream {
235 public:
236         ///
237         explicit MathematicaStream(std::ostream & os) : os_(os) {}
238         ///
239         std::ostream & os() { return os_; }
240 private:
241         ///
242         std::ostream & os_;
243 };
244
245
246 ///
247 MathematicaStream & operator<<(MathematicaStream &, MathAtom const &);
248 ///
249 MathematicaStream & operator<<(MathematicaStream &, MathArray const &);
250 ///
251 MathematicaStream & operator<<(MathematicaStream &, char const *);
252 ///
253 MathematicaStream & operator<<(MathematicaStream &, char);
254 ///
255 MathematicaStream & operator<<(MathematicaStream &, int);
256
257
258 //
259 // Octave
260 //
261
262
263 class OctaveStream {
264 public:
265         ///
266         explicit OctaveStream(std::ostream & os) : os_(os) {}
267         ///
268         std::ostream & os() { return os_; }
269 private:
270         ///
271         std::ostream & os_;
272 };
273
274 ///
275 OctaveStream & operator<<(OctaveStream &, MathAtom const &);
276 ///
277 OctaveStream & operator<<(OctaveStream &, MathArray const &);
278 ///
279 OctaveStream & operator<<(OctaveStream &, char const *);
280 ///
281 OctaveStream & operator<<(OctaveStream &, char);
282 ///
283 OctaveStream & operator<<(OctaveStream &, int);
284
285
286
287 #endif