2003-08-19 13:00:56 +00:00
|
|
|
|
// -*- C++ -*-
|
|
|
|
|
/**
|
|
|
|
|
* \file math_mathmlstream.h
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
2001-11-08 12:06:56 +00:00
|
|
|
|
#ifndef MATH_MATHMLSTREAM_H
|
|
|
|
|
#define MATH_MATHMLSTREAM_H
|
2001-11-07 17:30:26 +00:00
|
|
|
|
|
2001-12-02 17:03:46 +00:00
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
|
// Please keep all four streams in one file until the interface has
|
|
|
|
|
// settled.
|
|
|
|
|
|
2001-11-07 17:30:26 +00:00
|
|
|
|
|
2003-03-21 14:20:48 +00:00
|
|
|
|
#include "metricsinfo.h"
|
2002-08-02 14:04:16 +00:00
|
|
|
|
|
2001-12-02 17:03:46 +00:00
|
|
|
|
#include <iosfwd>
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
|
class MathArray;
|
|
|
|
|
class MathInset;
|
2002-08-08 17:11:30 +00:00
|
|
|
|
class MathAtom;
|
2001-12-03 16:24:50 +00:00
|
|
|
|
|
2002-08-22 10:04:11 +00:00
|
|
|
|
//
|
|
|
|
|
// LaTeX/LyX
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
class WriteStream {
|
|
|
|
|
public:
|
|
|
|
|
///
|
|
|
|
|
WriteStream(std::ostream & os, bool fragile, bool latex);
|
|
|
|
|
///
|
2004-04-08 15:03:33 +00:00
|
|
|
|
explicit WriteStream(std::ostream & os);
|
2002-08-22 10:04:11 +00:00
|
|
|
|
///
|
2002-08-22 11:57:58 +00:00
|
|
|
|
~WriteStream();
|
|
|
|
|
///
|
2002-08-22 10:04:11 +00:00
|
|
|
|
int line() const { return line_; }
|
|
|
|
|
///
|
|
|
|
|
bool fragile() const { return fragile_; }
|
|
|
|
|
///
|
|
|
|
|
bool latex() const { return latex_; }
|
|
|
|
|
///
|
|
|
|
|
std::ostream & os() { return os_; }
|
|
|
|
|
///
|
|
|
|
|
bool & firstitem() { return firstitem_; }
|
|
|
|
|
///
|
|
|
|
|
void addlines(unsigned int);
|
|
|
|
|
/// writes space if next thing is isalpha()
|
2002-08-22 11:57:58 +00:00
|
|
|
|
void pendingSpace(bool how);
|
2002-08-22 10:04:11 +00:00
|
|
|
|
/// writes space if next thing is isalpha()
|
|
|
|
|
bool pendingSpace() const { return pendingspace_; }
|
|
|
|
|
private:
|
|
|
|
|
///
|
|
|
|
|
std::ostream & os_;
|
|
|
|
|
/// do we have to write \\protect sometimes
|
|
|
|
|
bool fragile_;
|
|
|
|
|
/// are we at the beginning of an MathArray?
|
|
|
|
|
bool firstitem_;
|
|
|
|
|
/// are we writing to .tex?
|
|
|
|
|
int latex_;
|
|
|
|
|
/// do we have a space pending?
|
|
|
|
|
bool pendingspace_;
|
|
|
|
|
///
|
|
|
|
|
int line_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
WriteStream & operator<<(WriteStream &, MathAtom const &);
|
|
|
|
|
///
|
|
|
|
|
WriteStream & operator<<(WriteStream &, MathArray const &);
|
|
|
|
|
///
|
|
|
|
|
WriteStream & operator<<(WriteStream &, char const *);
|
|
|
|
|
///
|
|
|
|
|
WriteStream & operator<<(WriteStream &, char);
|
|
|
|
|
///
|
|
|
|
|
WriteStream & operator<<(WriteStream &, int);
|
|
|
|
|
///
|
|
|
|
|
WriteStream & operator<<(WriteStream &, unsigned int);
|
|
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// MathML
|
|
|
|
|
//
|
2001-11-07 17:30:26 +00:00
|
|
|
|
|
2001-11-08 12:06:56 +00:00
|
|
|
|
struct MTag {
|
2001-11-07 17:30:26 +00:00
|
|
|
|
///
|
2001-11-08 12:06:56 +00:00
|
|
|
|
MTag(char const * const tag) : tag_(tag) {}
|
2001-11-07 17:30:26 +00:00
|
|
|
|
///
|
2001-11-08 12:06:56 +00:00
|
|
|
|
char const * const tag_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct ETag {
|
|
|
|
|
///
|
|
|
|
|
ETag(char const * const tag) : tag_(tag) {}
|
|
|
|
|
///
|
|
|
|
|
char const * const tag_;
|
|
|
|
|
};
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
|
class MathMLStream {
|
|
|
|
|
public:
|
2001-11-08 12:06:56 +00:00
|
|
|
|
///
|
|
|
|
|
explicit MathMLStream(std::ostream & os);
|
2001-11-07 17:30:26 +00:00
|
|
|
|
///
|
2001-12-03 16:24:50 +00:00
|
|
|
|
void cr();
|
2001-11-07 17:30:26 +00:00
|
|
|
|
///
|
2001-12-03 16:24:50 +00:00
|
|
|
|
std::ostream & os() { return os_; }
|
2001-11-08 12:06:56 +00:00
|
|
|
|
///
|
2002-01-11 15:23:10 +00:00
|
|
|
|
int line() const { return line_; }
|
2001-11-08 12:06:56 +00:00
|
|
|
|
///
|
2001-12-03 16:24:50 +00:00
|
|
|
|
int & tab() { return tab_; }
|
2002-01-11 15:23:10 +00:00
|
|
|
|
///
|
|
|
|
|
friend MathMLStream & operator<<(MathMLStream &, char const *);
|
2001-12-03 16:24:50 +00:00
|
|
|
|
private:
|
2001-11-08 12:06:56 +00:00
|
|
|
|
///
|
|
|
|
|
std::ostream & os_;
|
|
|
|
|
///
|
|
|
|
|
int tab_;
|
|
|
|
|
///
|
|
|
|
|
int line_;
|
2001-11-09 18:02:20 +00:00
|
|
|
|
///
|
|
|
|
|
char lastchar_;
|
2001-11-08 12:06:56 +00:00
|
|
|
|
};
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
|
///
|
2002-08-08 17:11:30 +00:00
|
|
|
|
MathMLStream & operator<<(MathMLStream &, MathAtom const &);
|
2001-12-03 16:24:50 +00:00
|
|
|
|
///
|
|
|
|
|
MathMLStream & operator<<(MathMLStream &, MathArray const &);
|
|
|
|
|
///
|
|
|
|
|
MathMLStream & operator<<(MathMLStream &, char const *);
|
|
|
|
|
///
|
|
|
|
|
MathMLStream & operator<<(MathMLStream &, char);
|
|
|
|
|
///
|
|
|
|
|
MathMLStream & operator<<(MathMLStream &, MTag const &);
|
|
|
|
|
///
|
|
|
|
|
MathMLStream & operator<<(MathMLStream &, ETag const &);
|
|
|
|
|
|
2001-11-08 12:06:56 +00:00
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Debugging
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
class NormalStream {
|
|
|
|
|
public:
|
2001-11-08 12:06:56 +00:00
|
|
|
|
///
|
|
|
|
|
explicit NormalStream(std::ostream & os) : os_(os) {}
|
|
|
|
|
///
|
2001-12-03 16:24:50 +00:00
|
|
|
|
std::ostream & os() { return os_; }
|
|
|
|
|
private:
|
2001-11-08 12:06:56 +00:00
|
|
|
|
///
|
2001-12-03 16:24:50 +00:00
|
|
|
|
std::ostream & os_;
|
2001-11-07 17:30:26 +00:00
|
|
|
|
};
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
|
///
|
2002-08-08 17:11:30 +00:00
|
|
|
|
NormalStream & operator<<(NormalStream &, MathAtom const &);
|
2001-12-03 16:24:50 +00:00
|
|
|
|
///
|
|
|
|
|
NormalStream & operator<<(NormalStream &, MathArray const &);
|
|
|
|
|
///
|
|
|
|
|
NormalStream & operator<<(NormalStream &, char const *);
|
|
|
|
|
///
|
|
|
|
|
NormalStream & operator<<(NormalStream &, char);
|
2002-07-11 09:34:58 +00:00
|
|
|
|
///
|
|
|
|
|
NormalStream & operator<<(NormalStream &, int);
|
2001-12-03 16:24:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Maple
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MapleStream {
|
|
|
|
|
public:
|
2001-11-07 17:30:26 +00:00
|
|
|
|
///
|
|
|
|
|
explicit MapleStream(std::ostream & os) : os_(os) {}
|
|
|
|
|
///
|
2001-12-03 16:24:50 +00:00
|
|
|
|
std::ostream & os() { return os_; }
|
|
|
|
|
private:
|
2001-11-07 17:30:26 +00:00
|
|
|
|
///
|
2001-12-03 16:24:50 +00:00
|
|
|
|
std::ostream & os_;
|
2001-11-07 17:30:26 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
|
///
|
2002-08-08 17:11:30 +00:00
|
|
|
|
MapleStream & operator<<(MapleStream &, MathAtom const &);
|
2001-12-03 16:24:50 +00:00
|
|
|
|
///
|
|
|
|
|
MapleStream & operator<<(MapleStream &, MathArray const &);
|
|
|
|
|
///
|
|
|
|
|
MapleStream & operator<<(MapleStream &, char const *);
|
|
|
|
|
///
|
|
|
|
|
MapleStream & operator<<(MapleStream &, char);
|
|
|
|
|
///
|
|
|
|
|
MapleStream & operator<<(MapleStream &, int);
|
|
|
|
|
|
|
|
|
|
|
2002-10-28 17:15:19 +00:00
|
|
|
|
//
|
|
|
|
|
// Maxima
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MaximaStream {
|
|
|
|
|
public:
|
|
|
|
|
///
|
|
|
|
|
explicit MaximaStream(std::ostream & os) : os_(os) {}
|
|
|
|
|
///
|
|
|
|
|
std::ostream & os() { return os_; }
|
|
|
|
|
private:
|
|
|
|
|
///
|
|
|
|
|
std::ostream & os_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
MaximaStream & operator<<(MaximaStream &, MathAtom const &);
|
|
|
|
|
///
|
|
|
|
|
MaximaStream & operator<<(MaximaStream &, MathArray const &);
|
|
|
|
|
///
|
|
|
|
|
MaximaStream & operator<<(MaximaStream &, char const *);
|
|
|
|
|
///
|
|
|
|
|
MaximaStream & operator<<(MaximaStream &, char);
|
|
|
|
|
///
|
|
|
|
|
MaximaStream & operator<<(MaximaStream &, int);
|
|
|
|
|
|
|
|
|
|
|
2002-07-01 11:17:14 +00:00
|
|
|
|
//
|
|
|
|
|
// Mathematica
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MathematicaStream {
|
|
|
|
|
public:
|
|
|
|
|
///
|
|
|
|
|
explicit MathematicaStream(std::ostream & os) : os_(os) {}
|
|
|
|
|
///
|
|
|
|
|
std::ostream & os() { return os_; }
|
|
|
|
|
private:
|
|
|
|
|
///
|
|
|
|
|
std::ostream & os_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///
|
2002-08-08 17:11:30 +00:00
|
|
|
|
MathematicaStream & operator<<(MathematicaStream &, MathAtom const &);
|
2002-07-01 11:17:14 +00:00
|
|
|
|
///
|
|
|
|
|
MathematicaStream & operator<<(MathematicaStream &, MathArray const &);
|
|
|
|
|
///
|
|
|
|
|
MathematicaStream & operator<<(MathematicaStream &, char const *);
|
|
|
|
|
///
|
|
|
|
|
MathematicaStream & operator<<(MathematicaStream &, char);
|
|
|
|
|
///
|
|
|
|
|
MathematicaStream & operator<<(MathematicaStream &, int);
|
|
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
|
//
|
|
|
|
|
// Octave
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class OctaveStream {
|
|
|
|
|
public:
|
2001-11-07 17:30:26 +00:00
|
|
|
|
///
|
|
|
|
|
explicit OctaveStream(std::ostream & os) : os_(os) {}
|
|
|
|
|
///
|
2001-12-03 16:24:50 +00:00
|
|
|
|
std::ostream & os() { return os_; }
|
|
|
|
|
private:
|
2001-11-07 17:30:26 +00:00
|
|
|
|
///
|
2001-12-03 16:24:50 +00:00
|
|
|
|
std::ostream & os_;
|
2001-11-07 17:30:26 +00:00
|
|
|
|
};
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
|
///
|
2002-08-08 17:11:30 +00:00
|
|
|
|
OctaveStream & operator<<(OctaveStream &, MathAtom const &);
|
2001-12-03 16:24:50 +00:00
|
|
|
|
///
|
|
|
|
|
OctaveStream & operator<<(OctaveStream &, MathArray const &);
|
|
|
|
|
///
|
|
|
|
|
OctaveStream & operator<<(OctaveStream &, char const *);
|
|
|
|
|
///
|
|
|
|
|
OctaveStream & operator<<(OctaveStream &, char);
|
2002-04-24 17:07:42 +00:00
|
|
|
|
///
|
|
|
|
|
OctaveStream & operator<<(OctaveStream &, int);
|
2001-11-08 12:06:56 +00:00
|
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
|
|
2001-11-07 17:30:26 +00:00
|
|
|
|
#endif
|