]> git.lyx.org Git - lyx.git/commitdiff
change output to uses streams instead of strings
authorAndré Pönitz <poenitz@gmx.net>
Wed, 7 Nov 2001 17:30:26 +0000 (17:30 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Wed, 7 Nov 2001 17:30:26 +0000 (17:30 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2977 a592a061-630c-0410-9148-cb99ea01b6c8

26 files changed:
src/mathed/Makefile.am
src/mathed/array.C
src/mathed/array.h
src/mathed/formula.C
src/mathed/math_deliminset.C
src/mathed/math_deliminset.h
src/mathed/math_exfuncinset.C
src/mathed/math_exfuncinset.h
src/mathed/math_fracinset.C
src/mathed/math_fracinset.h
src/mathed/math_gridinset.C
src/mathed/math_gridinset.h
src/mathed/math_inset.C
src/mathed/math_inset.h
src/mathed/math_mathmlstream.C [new file with mode: 0644]
src/mathed/math_mathmlstream.h [new file with mode: 0644]
src/mathed/math_rootinset.C
src/mathed/math_rootinset.h
src/mathed/math_scriptinset.C
src/mathed/math_scriptinset.h
src/mathed/math_sqrtinset.C
src/mathed/math_sqrtinset.h
src/mathed/math_stringinset.C
src/mathed/math_stringinset.h
src/mathed/math_symbolinset.C
src/mathed/math_symbolinset.h

index 081ea869186187a25cadfaef65c02befde1c0388..10e26703d62ca31861263d1a49e8914cd9bacb2a 100644 (file)
@@ -72,6 +72,8 @@ libmathed_la_SOURCES = \
        math_macrotemplate.h \
        math_macrotable.C \
        math_macrotable.h \
+       math_mathmlstream.C \
+       math_mathmlstream.h \
        math_matrixinset.C \
        math_matrixinset.h \
        math_metricsinfo.h \
index 5331bf258857e67337f3e715ab476156f2427242..7a3af6592508b6798d395cafac27d43dc8eba0d7 100644 (file)
@@ -194,7 +194,7 @@ MathArray MathArray::glueChars() const
 }
 
 
-bool needAsterisk(MathAtom const & a, MathAtom const & b)
+bool needAsterisk(MathAtom const &, MathAtom const &)
 {
        return false;
 }
@@ -245,51 +245,47 @@ void MathArray::writeNormal(ostream & os) const
 }
 
 
-string MathArray::octavize() const
+void MathArray::octavize(OctaveStream & os) const
 {
        MathArray ar = glueChars();
-       string res;
        for (const_iterator it = ar.begin(); it != ar.end(); ++it) {
                MathInset const * p = it->nucleus();
                if (MathScriptInset const * q = ar.asScript(it)) {
-                       res += q->octavize(p);
+                       q->octavize(p, os);
                        ++it;
                } else 
-                       res += p->octavize();
+                       p->octavize(os);
        }
-       return res;
 }
 
 
-string MathArray::maplize() const
+void MathArray::maplize(MapleStream & os) const
 {
        MathArray ar = glueChars();
-       string res;
        for (const_iterator it = ar.begin(); it != ar.end(); ++it) {
                MathInset const * p = it->nucleus();
                if (MathScriptInset const * q = ar.asScript(it)) {
-                       res += q->maplize(p);
+                       q->maplize(p, os);
                        ++it;
                } else 
-                       res += p->maplize();
+                       p->maplize(os);
        }
-       return res;
 }
 
 
-string MathArray::mathmlize() const
+void MathArray::mathmlize(MathMLStream & os) const
 {
        MathArray ar = glueChars();
-       string res;
+       os << "<mrow>";
        for (const_iterator it = ar.begin(); it != ar.end(); ++it) {
                MathInset const * p = it->nucleus();
                if (MathScriptInset const * q = ar.asScript(it)) {
-                       res += q->mathmlize(p);
+                       q->mathmlize(p, os);
                        ++it;
                } else 
-                       res += p->mathmlize();
+                       p->mathmlize(os);
        }
-       return res;
+       os << "</mrow>";
 }
 
 
index 24c9e4fd0b257d727a6bc3aec052470c9ed1c590..e4d854cbc0291cd11e71f274de7c1738ed771790 100644 (file)
@@ -26,6 +26,9 @@ class MathScriptInset;
 class MathMacro;
 class MathWriteInfo;
 class MathMetricsInfo;
+class MathMLStream;
+class MapleStream;
+class OctaveStream;
 class LaTeXFeatures;
 
 #ifdef __GNUG__
@@ -122,11 +125,11 @@ public:
        MathArray guessAsterisks() const;
 
        /// interface to Octave
-       string octavize() const;
+       void octavize(OctaveStream &) const;
        /// interface to Maple
-       string maplize() const;
+       void maplize(MapleStream &) const;
        /// interface to MathML
-       string mathmlize() const;
+       void mathmlize(MathMLStream &) const;
 
        ///
        bool isMatrix() const;
@@ -139,4 +142,5 @@ private:
 
 std::ostream & operator<<(std::ostream & os, MathArray const & ar);
 
+
 #endif
index 235cb76bfd0d3d065c6ab3785b5060a80ddde735..506928cd7b7694e46b3ca5c6ad4b1c46de3ab731 100644 (file)
@@ -67,16 +67,33 @@ namespace {
 
        MathArray pipeThroughMaple(string const & extra, MathArray const & ar)
        {
-               string header = 
-                       "readlib(latex):\n"
-                       "`latex/csname_font` := ``:\n"
-                       "`latex/latex/*` := subs(`\\,`=`\\cdot `,eval(`latex/latex/*`)):\n";
+               string header = "readlib(latex):\n";
+
+               // remove the \\it for variable names
                //"#`latex/csname_font` := `\\it `:"
+               header +=
+                       "`latex/csname_font` := ``:\n";
+
+               // export matrices in (...) instead of [...]
+               header +=
+                       "`latex/latex/matrix` := "
+                               "subs(`[`=`(`, `]`=`)`,"
+                                       "eval(`latex/latex/matrix`)):\n";
+
+               // replace \\cdots with proper '*'
+               header +=
+                       "`latex/latex/*` := "
+                               "subs(`\\,`=`\\cdot `,"
+                                       "eval(`latex/latex/*`)):\n";
+
                //"#`latex/latex/symbol` "
                //      " := subs((\\'_\\' = \\'`\\_`\\',eval(`latex/latex/symbol`)): ";
 
                string trailer = "quit;";
-               string expr = ar.maplize();
+               ostringstream os;
+               MapleStream ms(os);
+               ms << ar;
+               string expr = os.str();
 
                for (int i = 0; i < 100; ++i) { // at most 100 attempts
                        // try to fix missing '*' the hard way by using mint
@@ -119,7 +136,10 @@ namespace {
        
        MathArray pipeThroughOctave(string const &, MathArray const & ar)
        {
-               string expr = ar.octavize();
+               ostringstream os;
+               OctaveStream vs(os);
+               vs << ar;
+               string expr = os.str();
                string out;
 
                for (int i = 0; i < 100; ++i) { // at most 100 attempts
@@ -278,13 +298,17 @@ int InsetFormula::ascii(Buffer const * buf, ostream & os, int) const
 
 int InsetFormula::linuxdoc(Buffer const * buf, ostream & os) const
 {
-       return ascii(buf, os, 0);
+       return docbook(buf, os);
 }
 
 
 int InsetFormula::docbook(Buffer const * buf, ostream & os) const
 {
-       return ascii(buf, os, 0);
+       MathMLStream ms(os);
+       ms << "<equation><alt>";
+       int res = ascii(buf, ms.os_, 0);
+       ms << "</alt>\n<mml>" << par_.nucleus() << "<mml></equation>";
+       return res + 1;
 }
 
 
index 767a60f7ec8a5bf58b50261e5d34ea197e179c16..50e86abd29af585d8a4b2cf1878bbd94a07ba844 100644 (file)
@@ -100,22 +100,24 @@ bool MathDelimInset::isMatrix() const
 }
 
 
-string MathDelimInset::octavize() const
+void MathDelimInset::octavize(OctaveStream & os) const
 {
        if (left_ == "|" && right_ == "|")
-               return "det(" + cell(0).octavize() + ")";
-       return left_ + cell(0).octavize() + right_;
+               os << "det(" << cell(0) << ")";
+       else
+               os << left_.c_str() << cell(0) << right_.c_str();
 }
 
 
-string MathDelimInset::maplize() const
+void MathDelimInset::maplize(MapleStream & os) const
 {
        if (left_ == "|" && right_ == "|") {
                if (cell(0).isMatrix()) 
-                       return "linalg[det](" + cell(0).maplize() + ")";
+                       os << "linalg[det](" << cell(0) << ")";
                else
-                       return "abs(" + cell(0).maplize() + ")";
+                       os << "abs(" << cell(0) << ")";
        }
-       return left_ + cell(0).maplize() + right_;
+       else
+               os << left_.c_str() << cell(0) << right_.c_str();
 }
 
index 0ffe24d3c7cd0ddd5d118d2d3493ec86abfed768..88f0fcce44fedc5fcbef0b5e2ea50c5d2b3a4f1b 100644 (file)
@@ -30,9 +30,9 @@ public:
        ///
        bool isMatrix() const;
        ///
-       string octavize() const;
+       void octavize(OctaveStream &) const;
        ///
-       string maplize() const;
+       void maplize(MapleStream &) const;
 private:
        ///
        int dw() const;
index 162792e320cc1d84db60853bcc8e91aec41626dd..3ca79da57f1f19731f680d3b5dbca095b9f1776e 100644 (file)
@@ -49,7 +49,7 @@ void MathExFuncInset::draw(Painter & pain, int x, int y) const
 }
 
 
-string MathExFuncInset::octavize() const
+void MathExFuncInset::octavize(OctaveStream & os) const
 {
-       return name_ + '(' + cell(0).octavize() + ')';
+       os << name_.c_str() << '(' << cell(0) << ')';
 }
index 3f434f69212c2b7c3ea0630f06984d2c60c90688..7ff103b01d89bd29430b493b7cbe6f8c17195ff4 100644 (file)
@@ -22,7 +22,7 @@ public:
        ///
        void draw(Painter &, int x, int y) const;
        ///
-       string octavize() const;
+       void octavize(OctaveStream &) const;
 
 private:
        ///
index 70e7737a395a70fc9269f5cdce0f9748b53405a2..22fc7eeb23807f0fee286d390e3f9c5641ff4f01 100644 (file)
@@ -63,7 +63,13 @@ void MathFracInset::writeNormal(std::ostream & os) const
 }
 
 
-string MathFracInset::maplize() const
+void MathFracInset::maplize(MapleStream & os) const
 {
-       return '(' + cell(0).maplize() + '/' + cell(1).maplize() + ')';
+       os << '(' << cell(0) << '/' << cell(1) << ')';
+}
+
+
+void MathFracInset::mathmlize(MathMLStream & os) const
+{
+       os << "<mfrac>" << cell(0) << cell(1) << "</mfrac>";
 }
index 4d14aaded6f152e7f65a68516751946a4df8abf1..479e0c8e8748d4a19349888889f84cc70c5f912f 100644 (file)
@@ -26,7 +26,9 @@ public:
        ///
        void draw(Painter &, int x, int y) const;
        ///
-       string maplize() const;
+       void maplize(MapleStream &) const;
+       ///
+       void mathmlize(MathMLStream &) const;
 public:
        ///
        const bool atop_;
index 17823c7973685c5c139d4eace5ba656ed47ddf8e..40cca94d6ff502deafb8e6467a3e2ecf6950105e 100644 (file)
@@ -587,40 +587,35 @@ std::vector<MathInset::idx_type>
 }
 
 
-string MathGridInset::octavize() const
+void MathGridInset::octavize(OctaveStream & os) const
 {
-       string res;
-       res += '[';
+       os << '[';
        for (row_type row = 0; row < nrows(); ++row) {
                if (row)
-                       res += ';';
-               res += '[';
-               for (col_type col = 0; col < ncols(); ++col) {
-                       res += cell(index(row, col)).octavize();
-                       res += ' ';
-               }
-               res += ']';
+                       os << ';';
+               os << '[';
+               for (col_type col = 0; col < ncols(); ++col) 
+                       os << cell(index(row, col)) << ' ';
+               os <<']';
        }
-       res += ']';
-       return res;
+       os <<']';
 }
 
 
-string MathGridInset::maplize() const
+void MathGridInset::maplize(MapleStream & os) const
 {
-       string res = "array([";
+       os << "array([";
        for (row_type row = 0; row < nrows(); ++row) {
                if (row)
-                       res += ',';
-               res += '[';
+                       os << ',';
+               os << '[';
                for (col_type col = 0; col < ncols(); ++col) {
                        if (col)
-                               res += ',';
-                       res += cell(index(row, col)).maplize();
+                               os << ',';
+                       os << cell(index(row, col));
                }
-               res += ']';
+               os << ']';
        }
-       res += "])";
-       return res;
+       os << "])";
 }
 
index af3f69e68db6d8081411b9b2e86cbff86a8579c5..c6de00adcff413fd495709e0b67bdd85b70abf4e 100644 (file)
@@ -150,9 +150,9 @@ public:
        void setDefaults();
 
        ///
-       string octavize() const;
+       void octavize(OctaveStream &) const;
        ///
-       string maplize() const;
+       void maplize(MapleStream &) const;
 
 protected:
        /// returns proper 'end of line' code for LaTeX
index d0b2655b55bfa7594c3efd6613a7504d5d02838e..2d73be133aab4772366f1d3c1a72a40545458f74 100644 (file)
@@ -217,22 +217,19 @@ void MathInset::write(MathWriteInfo &) const
 }
 
 
-string MathInset::octavize() const
+void MathInset::octavize(OctaveStream & os) const
 {
-       ostringstream os;
-       writeNormal(os);
-       return os.str();
-       return string();
+       writeNormal(os.os_);
 }
 
 
-string MathInset::maplize() const
+void MathInset::maplize(MapleStream & os) const
 {
-       return octavize();
+       writeNormal(os.os_);
 }
 
 
-string MathInset::mathmlize() const
+void MathInset::mathmlize(MathMLStream & os) const
 {
-       return string();
+       writeNormal(os.os_);
 }
index 5c81b6cc635fd37e94d718607ecf295ec9d45875..013fd1e59d429f5b9a7e81159199850608561ca1 100644 (file)
@@ -30,7 +30,7 @@
 
 #include "xarray.h"
 #include "math_defs.h"
-#include "LString.h"
+#include "math_mathmlstream.h"
 
 /** Abstract base class for all math objects.
     A math insets is for use of the math editor only, it isn't a
@@ -255,11 +255,11 @@ public:
        virtual void handleFont(MathTextCodes) {}
 
        ///
-       virtual string octavize() const;
+       virtual void octavize(OctaveStream &) const;
        ///
-       virtual string maplize() const;
+       virtual void maplize(MapleStream &) const;
        ///
-       virtual string mathmlize() const;
+       virtual void mathmlize(MathMLStream &) const;
 };
 
 std::ostream & operator<<(std::ostream &, MathInset const &);
diff --git a/src/mathed/math_mathmlstream.C b/src/mathed/math_mathmlstream.C
new file mode 100644 (file)
index 0000000..7bb87bd
--- /dev/null
@@ -0,0 +1,92 @@
+
+#include "math_inset.h"
+#include "math_mathmlstream.h"
+
+
+MathMLStream & MathMLStream::operator<<(MathInset const * p)
+{
+       p->mathmlize(*this);
+       return *this;           
+}
+
+
+MathMLStream & MathMLStream::operator<<(MathArray const & ar)
+{
+       ar.mathmlize(*this);
+       return *this;           
+}
+
+
+MathMLStream & MathMLStream::operator<<(char const * s)
+{
+       os_ << s;
+       return *this;           
+}
+
+
+MathMLStream & MathMLStream::operator<<(char c)
+{
+       os_ << c;
+       return *this;           
+}
+
+
+
+
+MapleStream & MapleStream::operator<<(MathInset const * p)
+{
+       p->maplize(*this);
+       return *this;           
+}
+
+
+MapleStream & MapleStream::operator<<(MathArray const & ar)
+{
+       ar.maplize(*this);
+       return *this;           
+}
+
+
+MapleStream & MapleStream::operator<<(char const * s)
+{
+       os_ << s;
+       return *this;           
+}
+
+
+MapleStream & MapleStream::operator<<(char c)
+{
+       os_ << c;
+       return *this;           
+}
+
+
+
+
+OctaveStream & OctaveStream::operator<<(MathInset const * p)
+{
+       p->octavize(*this);
+       return *this;           
+}
+
+
+OctaveStream & OctaveStream::operator<<(MathArray const & ar)
+{
+       ar.octavize(*this);
+       return *this;           
+}
+
+
+OctaveStream & OctaveStream::operator<<(char const * s)
+{
+       os_ << s;
+       return *this;           
+}
+
+
+OctaveStream & OctaveStream::operator<<(char c)
+{
+       os_ << c;
+       return *this;           
+}
+
diff --git a/src/mathed/math_mathmlstream.h b/src/mathed/math_mathmlstream.h
new file mode 100644 (file)
index 0000000..10d1430
--- /dev/null
@@ -0,0 +1,54 @@
+#ifndef MATH_MATH_MLSTREAM
+#define MATH_MATH_MLSTREAM
+
+#include <iosfwd>
+
+
+struct MathMLStream {
+       ///
+       explicit MathMLStream(std::ostream & os) : os_(os) {}
+       ///
+       std::ostream & os_;
+       ///
+       MathMLStream & operator<<(MathInset const *);
+       ///
+       MathMLStream & operator<<(MathArray const &);
+       ///
+       MathMLStream & operator<<(char const *);
+       ///
+       MathMLStream & operator<<(char);
+};
+
+
+struct MapleStream {
+       ///
+       explicit MapleStream(std::ostream & os) : os_(os) {}
+       ///
+       std::ostream & os_;
+       ///
+       MapleStream & operator<<(MathInset const *);
+       ///
+       MapleStream & operator<<(MathArray const &);
+       ///
+       MapleStream & operator<<(char const *);
+       ///
+       MapleStream & operator<<(char);
+};
+
+
+struct OctaveStream {
+       ///
+       explicit OctaveStream(std::ostream & os) : os_(os) {}
+       ///
+       std::ostream & os_;
+       ///
+       OctaveStream & operator<<(MathInset const *);
+       ///
+       OctaveStream & operator<<(MathArray const &);
+       ///
+       OctaveStream & operator<<(char const *);
+       ///
+       OctaveStream & operator<<(char);
+};
+
+#endif
index cc143bef377f4247350e8a8cd1049eb7f7d47f11..1625545fe9c3b1456e8ee7f3009ffeb7afc7b7e9 100644 (file)
@@ -94,7 +94,13 @@ bool MathRootInset::idxDown(int & idx, int & pos) const
 }
 
 
-string MathRootInset::octavize() const
+void MathRootInset::octavize(OctaveStream & os) const
 {
-       return "root(" + cell(1).octavize() + ',' + cell(0).octavize() + ')';
+       os << "root(" << cell(1) << ',' << cell(0) <<')';
+}
+
+
+void MathRootInset::mathmlize(MathMLStream & os) const
+{
+       os << "<mroot>" << cell(1) << cell(0) << "</mroot>";
 }
index e85e074c2ed6ad212891e1eb287f5a669cfe519d..9a1a8bb22ac275556fd60e1cde54914368925920 100644 (file)
@@ -44,7 +44,9 @@ public:
        ///
        bool idxDown(int & idx, int & pos) const;
        ///
-       string octavize() const;
+       void mathmlize(MathMLStream &) const;
+       ///
+       void octavize(OctaveStream &) const;
 };
 
 #endif
index 10f9163788128bff09959a44b7ccd8c5ecbcd396..c017deb4e5dc76e21d6b8a0f420679cd32cdd8a6 100644 (file)
@@ -346,28 +346,47 @@ bool MathScriptInset::idxLeft(MathInset::idx_type &,
 }
 
 
-string MathScriptInset::maplize(MathInset const * nuc) const
+void MathScriptInset::maplize(MathInset const * nuc, MapleStream & os) const
 {
-       string res;
        if (nuc)
-               res += nuc->maplize();
+               os << nuc;
        if (hasDown() && down().data_.size())
-               res += "[" + down().data_.maplize() + "]";
+               os << '[' << down().data_ << ']';
        if (hasUp() && up().data_.size())
-               res += "^(" + up().data_.maplize() + ")";
-       return res;
+               os << "^(" << up().data_ << ')';
 }
 
 
-string MathScriptInset::octavize(MathInset const * nuc) const
+void MathScriptInset::octavize(MathInset const * nuc, OctaveStream & os) const
 {
-       return maplize(nuc);
+       if (nuc)
+               os << nuc;
+       if (hasDown() && down().data_.size())
+               os << '[' << down().data_ << ']';
+       if (hasUp() && up().data_.size())
+               os << "^(" << up().data_ << ')';
 }
 
 
-string MathScriptInset::mathmlize(MathInset const * nuc) const
+void MathScriptInset::mathmlize(MathInset const * nuc, MathMLStream & os) const
 {
+       bool d = hasDown() && down().data_.size();
+       bool u = hasUp() && up().data_.size();
+
+       if (u)
+               os << "<sup>";
+
+       if (d)
+               os << "<sub>";
+
        if (nuc)
-               return nuc->mathmlize();
-       return string();
+               os << nuc;
+       else
+               os << "<mrow/>";
+
+       if (d)
+               os << down().data_ << "</sub>";
+
+       if (u)
+               os << up().data_ << "</sup>";
 }
index b48dbc8bef44a5eb4aaebbcdfd7843dbcb9f8fc4..fe72988fdc3f1cdbdd7bbd1ce24692fba3e2ab1d 100644 (file)
@@ -82,11 +82,11 @@ public:
        void ensure(bool up);
 
        ///
-       virtual string octavize(MathInset const * nuc) const;
+       void octavize(MathInset const * nuc, OctaveStream & os) const;
        ///
-       virtual string maplize(MathInset const * nuc) const;
+       void maplize(MathInset const * nuc, MapleStream & os) const;
        ///
-       virtual string mathmlize(MathInset const * nuc) const;
+       void mathmlize(MathInset const * nuc, MathMLStream & os) const;
 
 public:
        /// returns x offset for main part
index 0b3e2c72dbf1edadbee32c85f924c56c58cea74e..5e488bba80fb03b8c89ee71e631eeb5d45c2f445 100644 (file)
@@ -57,7 +57,13 @@ void MathSqrtInset::writeNormal(std::ostream & os) const
 }
 
 
-string MathSqrtInset::maplize() const
+void MathSqrtInset::maplize(MapleStream & os) const
 {
-       return "sqrt(" + cell(0).maplize() + ')';
+       os << "sqrt(" << cell(0) << ')';
+}
+
+
+void MathSqrtInset::mathmlize(MathMLStream & os) const
+{
+       os << "<msqrt>" << cell(0) << "</msqrt>";
 }
index 8f21fe99d8e05a4ea08c8bb499849095bcd3cb6b..769d085c240abcd383c192be1444cc1e2a2226e4 100644 (file)
@@ -26,6 +26,8 @@ public:
        ///
        void metrics(MathMetricsInfo const & st) const;
        ///
-       string maplize() const;
+       void maplize(MapleStream &) const;
+       ///
+       void mathmlize(MathMLStream &) const;
 };
 #endif
index 32981c22e2ea1743e6971c11fb931df74a33786f..61461a9d655849997627a94299b01b0455c5278c 100644 (file)
@@ -70,25 +70,42 @@ void MathStringInset::writeNormal(std::ostream & os) const
 }
 
 
-string MathStringInset::octavize() const
+void MathStringInset::maplize(MapleStream & os) const
 {
-       return maplize();
+       if (code_ != LM_TC_VAR || str_.size() <= 1) {
+               os << str_.c_str();
+               return;
+       }       
+
+       // insert '*' between adjacent chars if type is LM_TC_VAR
+       os << str_[0];
+       for (string::size_type i = 1; i < str_.size(); ++i) 
+               os << '*' << str_[i];
 }
 
 
-string MathStringInset::maplize() const
+void MathStringInset::octavize(OctaveStream & os) const
 {
-       if (code_ != LM_TC_VAR)
-               return str_;
-       if (str_.size() <= 1)
-               return str_;
-       string res;
+       if (code_ != LM_TC_VAR || str_.size() <= 1) {
+               os << str_.c_str();
+               return;
+       }       
 
        // insert '*' between adjacent chars if type is LM_TC_VAR
-       res += str_[0];
-       for (string::size_type i = 1; i < str_.size(); ++i) {
-               res += '*';
-               res += str_[i];
-       }
-       return res;
+       os << str_[0];
+       for (string::size_type i = 1; i < str_.size(); ++i) 
+               os << '*' << str_[i];
+}
+
+
+void MathStringInset::mathmlize(MathMLStream & os) const
+{
+       if (code_ == LM_TC_VAR)
+               os << "<mi>" << str_.c_str() << "</mi>";
+       else if (code_ == LM_TC_CONST)
+               os << "<mn>" << str_.c_str() << "</mn>";
+       else if (code_ == LM_TC_RM || code_ == LM_TC_TEXTRM)
+               os << "<mtext>" << str_.c_str() << "</mtext>";
+       else
+               os << str_.c_str();
 }
index 87aaa9d98d8f6085f83743e4017247a27247fb4e..edcaafe5c6ac41078982ecef658d2dd527ab1890 100644 (file)
@@ -33,11 +33,11 @@ public:
        ///
        int width() const;
        ///
-       string & str();
+       void octavize(OctaveStream &) const;
        ///
-       string octavize() const;
+       void maplize(MapleStream &) const;
        ///
-       string maplize() const;
+       void mathmlize(MathMLStream &) const;
 
 private:
        /// the string
index 0e8c4a609ac5d5e9e7a9ccd584c4cd2f1b5cad01..94d5697be0aecb6506d4a84b4056c2aca9b71de2 100644 (file)
@@ -114,23 +114,27 @@ bool MathSymbolInset::takesLimits() const
 }
 
 
-string MathSymbolInset::octavize() const
+void MathSymbolInset::maplize(MapleStream & os) const
 {
        if (sym_->name == "cdot")
-               return "*";
-       return sym_->name;
+               os << '*';
+       else
+               os << sym_->name.c_str();
 }
 
 
-string MathSymbolInset::maplize() const
+void MathSymbolInset::mathmlize(MathMLStream & os) const
 {
-       if (sym_->name == "cdot")
-               return "*";
-       return sym_->name;
+       os << sym_->name.c_str();
 }
 
 
-string MathSymbolInset::mathmlize() const
+void MathSymbolInset::octavize(OctaveStream & os) const
 {
-       return sym_->name;
+       if (sym_->name == "cdot")
+               os << '*';
+       else
+               os << sym_->name.c_str();
 }
+
+
index 3125f490b5c3fbc033a1f7358ee2da42280da13b..6a6ea11df5fac58d374bfb2065481acd86b2bfd3 100644 (file)
@@ -31,11 +31,11 @@ public:
        bool takesLimits() const;
 
        ///
-       string octavize() const;
+       void maplize(MapleStream &) const;
        ///
-       string maplize() const;
+       void mathmlize(MathMLStream &) const;
        ///
-       string mathmlize() const;
+       void octavize(OctaveStream &) const;
 private:
        ///
        MathTextCodes code() const;