2001-12-02 17:03:46 +00:00
|
|
|
#include <config.h>
|
2001-12-03 17:52:48 +00:00
|
|
|
#include <algorithm>
|
2001-12-02 17:03:46 +00:00
|
|
|
|
2001-11-07 17:30:26 +00:00
|
|
|
#include "math_mathmlstream.h"
|
2001-12-02 17:03:46 +00:00
|
|
|
#include "math_inset.h"
|
2001-11-09 08:35:57 +00:00
|
|
|
#include "math_extern.h"
|
2001-11-09 16:27:44 +00:00
|
|
|
#include "debug.h"
|
2001-11-07 17:30:26 +00:00
|
|
|
|
|
|
|
|
2001-11-08 12:06:56 +00:00
|
|
|
MathMLStream::MathMLStream(std::ostream & os)
|
2001-11-09 18:02:20 +00:00
|
|
|
: os_(os), tab_(0), line_(0), lastchar_(0)
|
2001-11-08 12:06:56 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
MathMLStream & operator<<(MathMLStream & ms, MathInset const * p)
|
2001-11-07 17:30:26 +00:00
|
|
|
{
|
2001-11-09 16:27:44 +00:00
|
|
|
if (p)
|
2001-12-03 16:24:50 +00:00
|
|
|
p->mathmlize(ms);
|
2001-11-09 16:27:44 +00:00
|
|
|
else
|
2001-12-03 16:24:50 +00:00
|
|
|
lyxerr << "operator<<(MathMLStream, NULL) called\n";
|
|
|
|
return ms;
|
2001-11-07 17:30:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
MathMLStream & operator<<(MathMLStream & ms, MathArray const & ar)
|
2001-11-07 17:30:26 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
mathmlize(ar, ms);
|
|
|
|
return ms;
|
2001-11-07 17:30:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
MathMLStream & operator<<(MathMLStream & ms, char const * s)
|
2001-11-07 17:30:26 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
ms.os() << s;
|
|
|
|
return ms;
|
2001-11-07 17:30:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
MathMLStream & operator<<(MathMLStream & ms, char c)
|
2001-11-07 17:30:26 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
ms.os() << c;
|
|
|
|
return ms;
|
2001-11-07 17:30:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
MathMLStream & operator<<(MathMLStream & ms, MTag const & t)
|
2001-11-08 12:06:56 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
++ms.tab();
|
|
|
|
ms.cr();
|
|
|
|
ms.os() << '<' << t.tag_ << '>';
|
|
|
|
return ms;
|
2001-11-08 12:06:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
MathMLStream & operator<<(MathMLStream & ms, ETag const & t)
|
2001-11-08 12:06:56 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
ms.cr();
|
|
|
|
if (ms.tab() > 0)
|
|
|
|
--ms.tab();
|
|
|
|
ms.os() << "</" << t.tag_ << '>';
|
|
|
|
return ms;
|
2001-11-08 12:06:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathMLStream::cr()
|
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
os() << '\n';
|
|
|
|
for (int i = 0; i < tab(); ++i)
|
|
|
|
os() << ' ';
|
2001-11-08 12:06:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
2001-11-07 17:30:26 +00:00
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
MapleStream & operator<<(MapleStream & ms, MathInset const * p)
|
2001-11-07 17:30:26 +00:00
|
|
|
{
|
2001-11-09 16:27:44 +00:00
|
|
|
if (p)
|
2001-12-03 16:24:50 +00:00
|
|
|
p->maplize(ms);
|
2001-11-09 16:27:44 +00:00
|
|
|
else
|
2001-12-03 16:24:50 +00:00
|
|
|
lyxerr << "operator<<(MapleStream, NULL) called\n";
|
|
|
|
return ms;
|
2001-11-07 17:30:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
MapleStream & operator<<(MapleStream & ms, MathArray const & ar)
|
2001-11-07 17:30:26 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
maplize(ar, ms);
|
|
|
|
return ms;
|
2001-11-07 17:30:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
MapleStream & operator<<(MapleStream & ms, char const * s)
|
2001-11-07 17:30:26 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
ms.os() << s;
|
|
|
|
return ms;
|
2001-11-07 17:30:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
MapleStream & operator<<(MapleStream & ms, char c)
|
2001-11-07 17:30:26 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
ms.os() << c;
|
|
|
|
return ms;
|
2001-11-07 17:30:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
MapleStream & operator<<(MapleStream & ms, int i)
|
2001-11-09 08:35:57 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
ms.os() << i;
|
|
|
|
return ms;
|
2001-11-09 08:35:57 +00:00
|
|
|
}
|
|
|
|
|
2001-11-07 17:30:26 +00:00
|
|
|
|
2001-11-08 12:06:56 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
2001-11-07 17:30:26 +00:00
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
OctaveStream & operator<<(OctaveStream & ns, MathInset const * p)
|
2001-11-07 17:30:26 +00:00
|
|
|
{
|
2001-11-09 16:27:44 +00:00
|
|
|
if (p)
|
2001-12-03 16:24:50 +00:00
|
|
|
p->octavize(ns);
|
2001-11-09 16:27:44 +00:00
|
|
|
else
|
2001-12-03 16:24:50 +00:00
|
|
|
lyxerr << "operator<<(OctaveStream, NULL) called\n";
|
|
|
|
return ns;
|
2001-11-07 17:30:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
OctaveStream & operator<<(OctaveStream & ns, MathArray const & ar)
|
2001-11-07 17:30:26 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
octavize(ar, ns);
|
|
|
|
return ns;
|
2001-11-07 17:30:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
OctaveStream & operator<<(OctaveStream & ns, char const * s)
|
2001-11-07 17:30:26 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
ns.os() << s;
|
|
|
|
return ns;
|
2001-11-07 17:30:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
OctaveStream & operator<<(OctaveStream & ns, char c)
|
2001-11-07 17:30:26 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
ns.os() << c;
|
|
|
|
return ns;
|
2001-11-07 17:30:26 +00:00
|
|
|
}
|
|
|
|
|
2001-11-08 12:06:56 +00:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
NormalStream & operator<<(NormalStream & ns, MathInset const * p)
|
2001-11-08 12:06:56 +00:00
|
|
|
{
|
2001-11-09 16:27:44 +00:00
|
|
|
if (p)
|
2001-12-03 16:24:50 +00:00
|
|
|
p->normalize(ns);
|
2001-11-09 16:27:44 +00:00
|
|
|
else
|
2001-12-03 16:24:50 +00:00
|
|
|
lyxerr << "operator<<(NormalStream, NULL) called\n";
|
|
|
|
return ns;
|
2001-11-08 12:06:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
NormalStream & operator<<(NormalStream & ns, MathArray const & ar)
|
2001-11-08 12:06:56 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
normalize(ar, ns);
|
|
|
|
return ns;
|
2001-11-08 12:06:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
NormalStream & operator<<(NormalStream & ns, char const * s)
|
2001-11-08 12:06:56 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
ns.os() << s;
|
|
|
|
return ns;
|
2001-11-08 12:06:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
NormalStream & operator<<(NormalStream & ns, char c)
|
2001-11-08 12:06:56 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
ns.os() << c;
|
|
|
|
return ns;
|
2001-11-08 12:06:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
WriteStream::WriteStream(std::ostream & os, bool fragile)
|
|
|
|
: os_(os), fragile_(fragile), line_(0)
|
2001-11-08 12:06:56 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
WriteStream::WriteStream(std::ostream & os)
|
|
|
|
: os_(os), fragile_(false), line_(0)
|
2001-11-08 12:06:56 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
WriteStream & operator<<(WriteStream & ws, MathInset const * p)
|
2001-11-08 12:06:56 +00:00
|
|
|
{
|
2001-11-09 16:27:44 +00:00
|
|
|
if (p)
|
2001-12-03 16:24:50 +00:00
|
|
|
p->write(ws);
|
2001-11-09 16:27:44 +00:00
|
|
|
else
|
2001-12-03 16:24:50 +00:00
|
|
|
lyxerr << "operator<<(WriteStream, NULL) called\n";
|
|
|
|
return ws;
|
2001-11-08 12:06:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
WriteStream & operator<<(WriteStream & ws, MathArray const & ar)
|
2001-11-08 12:06:56 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
write(ar, ws);
|
|
|
|
return ws;
|
2001-11-08 12:06:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
WriteStream & operator<<(WriteStream & ws, char const * s)
|
2001-12-02 17:03:46 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
ws.os() << s;
|
2001-12-03 17:52:48 +00:00
|
|
|
ws.line() += std::count(s, s + strlen(s), '\n');
|
2001-12-03 16:24:50 +00:00
|
|
|
return ws;
|
2001-11-08 12:06:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
WriteStream & operator<<(WriteStream & ws, char c)
|
2001-11-08 12:06:56 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
ws.os() << c;
|
2001-11-19 19:06:05 +00:00
|
|
|
if (c == '\n')
|
2001-12-03 16:24:50 +00:00
|
|
|
++ws.line();
|
|
|
|
return ws;
|
2001-11-08 12:06:56 +00:00
|
|
|
}
|
2001-11-20 07:04:00 +00:00
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
WriteStream & operator<<(WriteStream & ws, int i)
|
2001-11-20 07:04:00 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
ws.os() << i;
|
|
|
|
return ws;
|
2001-11-20 07:04:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
WriteStream & operator<<(WriteStream & ws, unsigned int i)
|
2001-11-20 07:04:00 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
ws.os() << i;
|
|
|
|
return ws;
|
2001-11-20 07:04:00 +00:00
|
|
|
}
|