]> git.lyx.org Git - lyx.git/blob - src/mathed/math_mathmlstream.h
enable insertion of spaces in all \textxxx modes.
[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 NormalStream & operator<<(NormalStream &, int);
98
99
100
101
102 //
103 // Maple
104 //
105
106
107 class MapleStream {
108 public:
109         ///
110         explicit MapleStream(std::ostream & os) : os_(os) {}
111         ///
112         std::ostream & os() { return os_; }
113 private:
114         ///
115         std::ostream & os_;
116 };
117
118
119 ///
120 MapleStream & operator<<(MapleStream &, MathInset const *);
121 ///
122 MapleStream & operator<<(MapleStream &, MathArray const &);
123 ///
124 MapleStream & operator<<(MapleStream &, char const *);
125 ///
126 MapleStream & operator<<(MapleStream &, char);
127 ///
128 MapleStream & operator<<(MapleStream &, int);
129
130
131 //
132 // Mathematica
133 //
134
135
136 class MathematicaStream {
137 public:
138         ///
139         explicit MathematicaStream(std::ostream & os) : os_(os) {}
140         ///
141         std::ostream & os() { return os_; }
142 private:
143         ///
144         std::ostream & os_;
145 };
146
147
148 ///
149 MathematicaStream & operator<<(MathematicaStream &, MathInset const *);
150 ///
151 MathematicaStream & operator<<(MathematicaStream &, MathArray const &);
152 ///
153 MathematicaStream & operator<<(MathematicaStream &, char const *);
154 ///
155 MathematicaStream & operator<<(MathematicaStream &, char);
156 ///
157 MathematicaStream & operator<<(MathematicaStream &, int);
158
159
160 //
161 // Octave
162 //
163
164
165 class OctaveStream {
166 public:
167         ///
168         explicit OctaveStream(std::ostream & os) : os_(os) {}
169         ///
170         std::ostream & os() { return os_; }
171 private:
172         ///
173         std::ostream & os_;
174 };
175
176 ///
177 OctaveStream & operator<<(OctaveStream &, MathInset const *);
178 ///
179 OctaveStream & operator<<(OctaveStream &, MathArray const &);
180 ///
181 OctaveStream & operator<<(OctaveStream &, char const *);
182 ///
183 OctaveStream & operator<<(OctaveStream &, char);
184 ///
185 OctaveStream & operator<<(OctaveStream &, int);
186
187
188
189 //
190 // LaTeX/LyX
191 //
192
193 class WriteStream {
194 public:
195         ///
196         WriteStream(std::ostream & os, bool fragile, bool latex);
197         ///
198         explicit WriteStream(std::ostream & os_);
199         ///
200         int line() const { return line_; }
201         ///
202         bool fragile() const { return fragile_; }
203         ///
204         bool latex() const { return latex_; }
205         ///
206         std::ostream & os() { return os_; }
207         ///
208         bool & firstitem() { return firstitem_; }
209         ///
210         void addlines(unsigned int);
211 private:
212         ///
213         std::ostream & os_;
214         ///
215         bool fragile_;
216         /// are we writing to .tex?
217         int latex_;
218         /// are we at the beginning of an MathArray?
219         bool firstitem_;
220         ///
221         int line_;
222 };
223
224 ///
225 WriteStream & operator<<(WriteStream &, MathInset const *);
226 ///
227 WriteStream & operator<<(WriteStream &, MathArray const &);
228 ///
229 WriteStream & operator<<(WriteStream &, char const *);
230 ///
231 WriteStream & operator<<(WriteStream &, char);
232 ///
233 WriteStream & operator<<(WriteStream &, int);
234 ///
235 WriteStream & operator<<(WriteStream &, unsigned int);
236
237 #endif