Cleanup MathMLStream

This is preparatory work for fixing ticket #13069.

Remove direct accesses to the underlying stream of MathMLStream in
InsetMathChar, InsetMathSpecialChar, and in all << operators other
than MathMLStream << docstring. This will allow to add a hook later in
this operator.

Move default values of MathMLStream private members to their definition.

Get rid of line_ member, which is not used.
This commit is contained in:
Jean-Marc Lasgouttes 2024-07-19 14:57:58 +02:00
parent d7ba7bceb3
commit fbd4b0a13f
4 changed files with 18 additions and 24 deletions

View File

@ -248,7 +248,7 @@ void InsetMathChar::mathmlize(MathMLStream & ms) const
if (ms.inText()) {
if (entity.empty())
ms.os().put(char_);
ms << char_;
else
ms << from_ascii(entity);
return;

View File

@ -139,7 +139,7 @@ void InsetMathSpecialChar::mathmlize(MathMLStream & ms) const
ms << "&amp;";
break;
default:
ms.os().put(char_);
ms << char_;
break;
}
}

View File

@ -289,7 +289,7 @@ TeXMathStream & operator<<(TeXMathStream & ws, unsigned int i)
MathMLStream::MathMLStream(odocstream & os, std::string const & xmlns)
: os_(os), tab_(0), line_(0), in_text_(false), xmlns_(xmlns)
: os_(os), xmlns_(xmlns)
{
if (in_text_)
font_math_style_ = TEXT_STYLE;
@ -338,23 +338,30 @@ MathMLStream & operator<<(MathMLStream & ms, MathData const & ar)
}
MathMLStream & operator<<(MathMLStream & ms, char const * s)
MathMLStream & operator<<(MathMLStream & ms, docstring const & s)
{
ms.os() << s;
return ms;
}
MathMLStream & operator<<(MathMLStream & ms, char const * s)
{
ms << from_utf8(s);
return ms;
}
MathMLStream & operator<<(MathMLStream & ms, char c)
{
ms.os() << c;
ms << docstring(1,c);
return ms;
}
MathMLStream & operator<<(MathMLStream & ms, char_type c)
{
ms.os().put(c);
ms << docstring(1,c);
return ms;
}
@ -410,13 +417,6 @@ MathMLStream & operator<<(MathMLStream & ms, CTag const & t)
}
MathMLStream & operator<<(MathMLStream & ms, docstring const & s)
{
ms.os() << s;
return ms;
}
//////////////////////////////////////////////////////////////////////

View File

@ -9,8 +9,8 @@
* Full author contact details are available in file CREDITS.
*/
#ifndef MATH_MATHMLSTREAM_H
#define MATH_MATHMLSTREAM_H
#ifndef MATH_MATHSTREAM_H
#define MATH_MATHSTREAM_H
#include "InsetMath.h"
#include "FontInfo.h"
@ -382,13 +382,9 @@ public:
void cr();
///
odocstream & os() { return os_; }
///
int line() const { return line_; }
///
/// Indentation when nesting tags
int & tab() { return tab_; }
///
friend MathMLStream & operator<<(MathMLStream &, char const *);
///
void defer(docstring const &);
///
void defer(std::string const &);
@ -412,11 +408,9 @@ private:
///
odocstream & os_;
///
int tab_;
int tab_ = 0;
///
int line_;
///
bool in_text_;
bool in_text_ = false;
///
odocstringstream deferred_;
///