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