X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2Fmath_mathmlstream.h;h=744156946ea6270481ab58796b55cc58b54549be;hb=4bc59f21015e9151841eea3733b97d25cd616fdc;hp=245d6dc0848d8dcf6321b176eef57cad1e5941a3;hpb=4da1f8e66fb8b9edb6200c3eaae0177a5de4a2ef;p=lyx.git diff --git a/src/mathed/math_mathmlstream.h b/src/mathed/math_mathmlstream.h index 245d6dc084..744156946e 100644 --- a/src/mathed/math_mathmlstream.h +++ b/src/mathed/math_mathmlstream.h @@ -1,12 +1,20 @@ #ifndef MATH_MATHMLSTREAM_H #define MATH_MATHMLSTREAM_H + +// Please keep all four streams in one file until the interface has +// settled. + + #include -#include "support/LOstream.h" -struct MathArray; -struct MathInset; -struct Buffer; +class MathArray; +class MathInset; + + +// +// MathML +// struct MTag { /// @@ -22,24 +30,21 @@ struct ETag { char const * const tag_; }; -struct MathMLStream { +class MathMLStream { +public: /// explicit MathMLStream(std::ostream & os); /// - MathMLStream & operator<<(MathInset const *); - /// - MathMLStream & operator<<(MathArray const &); - /// - MathMLStream & operator<<(char const *); + void cr(); /// - MathMLStream & operator<<(char); + std::ostream & os() { return os_; } /// - MathMLStream & operator<<(MTag const &); + int line() const { return line_; } /// - MathMLStream & operator<<(ETag const &); + int & tab() { return tab_; } /// - void cr(); - + friend MathMLStream & operator<<(MathMLStream &, char const *); +private: /// std::ostream & os_; /// @@ -50,79 +55,152 @@ struct MathMLStream { char lastchar_; }; +/// +MathMLStream & operator<<(MathMLStream &, MathInset const *); +/// +MathMLStream & operator<<(MathMLStream &, MathArray const &); +/// +MathMLStream & operator<<(MathMLStream &, char const *); +/// +MathMLStream & operator<<(MathMLStream &, char); +/// +MathMLStream & operator<<(MathMLStream &, MTag const &); +/// +MathMLStream & operator<<(MathMLStream &, ETag const &); + + -struct NormalStream { +// +// Debugging +// + +class NormalStream { +public: /// explicit NormalStream(std::ostream & os) : os_(os) {} /// - std::ostream & os_; - /// - NormalStream & operator<<(MathInset const *); + std::ostream & os() { return os_; } +private: /// - NormalStream & operator<<(MathArray const &); - /// - NormalStream & operator<<(char const *); - /// - NormalStream & operator<<(char); + std::ostream & os_; }; +/// +NormalStream & operator<<(NormalStream &, MathInset const *); +/// +NormalStream & operator<<(NormalStream &, MathArray const &); +/// +NormalStream & operator<<(NormalStream &, char const *); +/// +NormalStream & operator<<(NormalStream &, char); -struct MapleStream { + + + +// +// Maple +// + + +class MapleStream { +public: /// explicit MapleStream(std::ostream & os) : os_(os) {} /// - std::ostream & os_; + std::ostream & os() { return os_; } +private: /// - MapleStream & operator<<(MathInset const *); - /// - MapleStream & operator<<(MathArray const &); - /// - MapleStream & operator<<(char const *); - /// - MapleStream & operator<<(char); - /// - MapleStream & operator<<(int); + std::ostream & os_; }; -struct OctaveStream { +/// +MapleStream & operator<<(MapleStream &, MathInset const *); +/// +MapleStream & operator<<(MapleStream &, MathArray const &); +/// +MapleStream & operator<<(MapleStream &, char const *); +/// +MapleStream & operator<<(MapleStream &, char); +/// +MapleStream & operator<<(MapleStream &, int); + + +// +// Octave +// + + +class OctaveStream { +public: /// explicit OctaveStream(std::ostream & os) : os_(os) {} /// - std::ostream & os_; - /// - OctaveStream & operator<<(MathInset const *); - /// - OctaveStream & operator<<(MathArray const &); + std::ostream & os() { return os_; } +private: /// - OctaveStream & operator<<(char const *); - /// - OctaveStream & operator<<(char); + std::ostream & os_; }; +/// +OctaveStream & operator<<(OctaveStream &, MathInset const *); +/// +OctaveStream & operator<<(OctaveStream &, MathArray const &); +/// +OctaveStream & operator<<(OctaveStream &, char const *); +/// +OctaveStream & operator<<(OctaveStream &, char); +/// +OctaveStream & operator<<(OctaveStream &, int); + -struct WriteStream { + +// +// LaTeX/LyX +// + +class WriteStream { +public: /// - WriteStream(Buffer const * buffer_, std::ostream & os_, bool fragile_); + WriteStream(std::ostream & os, bool fragile, bool latex); /// explicit WriteStream(std::ostream & os_); - /// - WriteStream & operator<<(MathInset const *); + int line() const { return line_; } /// - WriteStream & operator<<(MathArray const &); + bool fragile() const { return fragile_; } /// - WriteStream & operator<<(char const *); + bool latex() const { return latex_; } /// - WriteStream & operator<<(char); - + std::ostream & os() { return os_; } + /// + bool & firstitem() { return firstitem_; } /// - Buffer const * buffer; + void addlines(unsigned int); +private: /// - std::ostream & os; + std::ostream & os_; /// - bool fragile; + bool fragile_; + /// are we writing to .tex? + int latex_; + /// are we at the beginning of an MathArray? + bool firstitem_; + /// + int line_; }; +/// +WriteStream & operator<<(WriteStream &, MathInset const *); +/// +WriteStream & operator<<(WriteStream &, MathArray const &); +/// +WriteStream & operator<<(WriteStream &, char const *); +/// +WriteStream & operator<<(WriteStream &, char); +/// +WriteStream & operator<<(WriteStream &, int); +/// +WriteStream & operator<<(WriteStream &, unsigned int); #endif