#include <algorithm>
#include <sstream>
+using lyx::docstring;
+using lyx::odocstream;
+using lyx::odocstringstream;
using lyx::support::cmd_ret;
using lyx::support::getVectorFromString;
using lyx::support::libFileSearch;
using std::auto_ptr;
using std::istringstream;
using std::ostream;
-using std::ostringstream;
using std::swap;
using std::vector;
-ostream & operator<<(ostream & os, MathArray const & ar)
-{
- NormalStream ns(os);
- ns << ar;
- return os;
-}
-
-
// define a function for tests
typedef bool TestItemFunc(MathAtom const &);
return string::npos;
}
- MathArray pipeThroughMaxima(string const &, MathArray const & ar)
+ MathArray pipeThroughMaxima(docstring const &, MathArray const & ar)
{
- ostringstream os;
+ lyx::odocstringstream os;
MaximaStream ms(os);
ms << ar;
- string expr = os.str();
+ // FIXME UNICODE Is utf8 encoding correct?
+ string expr = lyx::to_utf8(os.str());
string const header = "simpsum:true;";
string out;
}
- MathArray pipeThroughMaple(string const & extra, MathArray const & ar)
+ MathArray pipeThroughMaple(docstring const & extra, MathArray const & ar)
{
string header = "readlib(latex):\n";
// " := subs((\\'_\\' = \\'`\\_`\\',eval(`latex/latex/symbol`)): ";
string trailer = "quit;";
- ostringstream os;
+ lyx::odocstringstream os;
MapleStream ms(os);
ms << ar;
- string expr = os.str();
+ // FIXME UNICODE Is utf8 encoding correct?
+ string expr = lyx::to_utf8(os.str());
lyxerr << "ar: '" << ar << "'\n"
- << "ms: '" << os.str() << "'" << endl;
+ << "ms: '" << expr << "'" << endl;
for (int i = 0; i < 100; ++i) { // at most 100 attempts
// try to fix missing '*' the hard way by using mint
expr.insert(pos, 1, '*');
}
- string full = "latex(" + extra + '(' + expr + "));";
+ // FIXME UNICODE Is utf8 encoding correct?
+ string full = "latex(" + lyx::to_utf8(extra) + '(' + expr + "));";
string out = captureOutput("maple -q", header + full + trailer);
// change \_ into _
}
- MathArray pipeThroughOctave(string const &, MathArray const & ar)
+ MathArray pipeThroughOctave(docstring const &, MathArray const & ar)
{
- ostringstream os;
+ lyx::odocstringstream os;
OctaveStream vs(os);
vs << ar;
- string expr = os.str();
+ // FIXME UNICODE Is utf8 encoding correct?
+ string expr = lyx::to_utf8(os.str());
string out;
lyxerr << "pipe: ar: '" << ar << "'\n"
}
- MathArray pipeThroughMathematica(string const &, MathArray const & ar)
+ MathArray pipeThroughMathematica(docstring const &, MathArray const & ar)
{
- ostringstream os;
+ lyx::odocstringstream os;
MathematicaStream ms(os);
ms << ar;
- string const expr = os.str();
+ // FIXME UNICODE Is utf8 encoding correct?
+ string const expr = lyx::to_utf8(os.str());
string out;
lyxerr << "expr: '" << expr << "'" << endl;
}
-MathArray pipeThroughExtern(string const & lang, string const & extra,
+MathArray pipeThroughExtern(string const & lang, docstring const & extra,
MathArray const & ar)
{
if (lang == "octave")
return pipeThroughMathematica(extra, ar);
// create normalized expression
- ostringstream os;
+ lyx::odocstringstream os;
NormalStream ns(os);
os << '[' << extra << ' ';
ns << ar;
os << ']';
- string data = os.str();
+ // FIXME UNICODE Is utf8 encoding correct?
+ string data = lyx::to_utf8(os.str());
// search external script
string file = libFileSearch("mathed", "extern_" + lang);