21#include "../../kernel.hpp"
96 string sReturn = _sText;
98 for (
unsigned int i = 0; i < sReturn.length(); i++)
100 if (sReturn[i] ==
'Ä' || sReturn[i] == (
char)142)
101 sReturn.replace(i,1,
"\\\"A");
103 if (sReturn[i] ==
'ä' || sReturn[i] == (
char)132)
104 sReturn.replace(i,1,
"\\\"a");
106 if (sReturn[i] ==
'Ö' || sReturn[i] == (
char)153)
107 sReturn.replace(i,1,
"\\\"O");
109 if (sReturn[i] ==
'ö' || sReturn[i] == (
char)148)
110 sReturn.replace(i,1,
"\\\"o");
112 if (sReturn[i] ==
'Ü' || sReturn[i] == (
char)154)
113 sReturn.replace(i,1,
"\\\"U");
115 if (sReturn[i] ==
'ü' || sReturn[i] == (
char)129)
116 sReturn.replace(i,1,
"\\\"u");
118 if (sReturn[i] ==
'ß' || sReturn[i] == (
char)225)
119 sReturn.replace(i,1,
"\\ss ");
121 if (sReturn[i] ==
'°' || sReturn[i] == (
char)248)
122 sReturn.replace(i,1,
"$^\\circ$");
124 if (sReturn[i] == (
char)196 || sReturn[i] == (
char)249)
125 sReturn.replace(i,1,
"\\pm ");
127 if (sReturn[i] == (
char)171 || sReturn[i] == (
char)174)
128 sReturn.replace(i,1,
"\"<");
130 if (sReturn[i] == (
char)187 || sReturn[i] == (
char)175)
131 sReturn.replace(i,1,
"\">");
133 if ((!i && sReturn[i] ==
'_') || (i && sReturn[i] ==
'_' && sReturn[i-1] !=
'\\'))
134 sReturn.insert(i,1,
'\\');
162 if (sFile.rfind(
'.') != string::npos
163 && (sFile.substr(sFile.rfind(
'.')) ==
".ndat"
164 || sFile.substr(sFile.rfind(
'.')) ==
".nprc"
165 || sFile.substr(sFile.rfind(
'.')) ==
".nscr"))
166 sFile = sFile.substr(0,sFile.rfind(
'.'));
235 string sCommentSign =
"#";
246 print(sCommentSign +
" " +
_lang.
get(
"OUTPUT_PRINTLEGAL_LINE1"));
247 print(sCommentSign +
" NumeRe: Framework für Numerische Rechnungen");
248 print(sCommentSign +
"=============================================");
250 print(sCommentSign +
" " +
_lang.
get(
"OUTPUT_PRINTLEGAL_LINE3", sBuild.substr(0,4)));
251 print(sCommentSign +
"");
253 print(sCommentSign +
"");
256 print(sCommentSign +
" " +
_lang.
get(
"OUTPUT_PRINTLEGAL_TEX"));
258 print(sCommentSign +
" " +
_lang.
get(
"OUTPUT_PRINTLEGAL_STD"));
279 if (sOutput.find(
"---------") != string::npos || sOutput.find(
"<<SUMBAR>>") != string::npos)
281 if (sOutput.find(
"<<SUMBAR>>") != string::npos)
283 unsigned int nLength = sOutput.length();
286 sOutput.assign(nLength,
'-');
288 sOutput.assign(nLength,
'-');
291 sOutput.assign(sOutput.length(),
'-');
294 sOutput =
"\\midrule";
321 file_out <<
"#" << sOutput.substr(1) << endl;
340 if (
sPath.find(
'"') != string::npos)
345 while (sTime.find(
'\\') != string::npos)
346 sTime[sTime.find(
'\\')] =
'/';
358 time_t now = time(0);
359 tm *ltm = localtime(&now);
360 ostringstream Temp_str;
361 Temp_str << 1900+ltm->tm_year <<
"-";
363 if(1+ltm->tm_mon < 10)
366 Temp_str << 1+ltm->tm_mon <<
"-";
368 if(ltm->tm_mday < 10)
371 Temp_str << ltm->tm_mday;
378 if(ltm->tm_hour < 10)
381 Temp_str << ltm->tm_hour;
389 Temp_str << ltm->tm_min;
397 Temp_str << ltm->tm_sec;
399 return Temp_str.str();
403void Output::format(
string** _sMatrix,
long long int _nCol,
long long int _nLine,
const Settings& _option,
bool bDontAsk,
int nHeadLineCount)
408 unsigned int nLongest[_nCol];
409 unsigned int nLen = 0;
413 if (sLabel.find(
'/') != string::npos)
414 sLabel.erase(0,sLabel.rfind(
'/')+1);
416 if (sLabel.find(
".tex") != string::npos)
417 sLabel.erase(sLabel.rfind(
".tex"));
419 while (sLabel.find(
' ') != string::npos)
420 sLabel[sLabel.find(
' ')] =
'_';
428 for (
long long int j = 0; j < _nCol; j++)
432 for (
long long int i = 0; i < _nLine; i++)
436 if (_sMatrix[i][j].find(
'e') != string::npos)
438 _sMatrix[i][j] = _sMatrix[i][j].substr(0,_sMatrix[i][j].find(
'e'))
440 + (_sMatrix[i][j][_sMatrix[i][j].find(
'e')+1] ==
'-' ?
"-" :
"")
441 + _sMatrix[i][j].substr(_sMatrix[i][j].find_first_not_of(
'0', _sMatrix[i][j].find(
'e')+2))
445 if (_sMatrix[i][j].find(
'%') != string::npos)
447 _sMatrix[i][j] = _sMatrix[i][j].substr(0,_sMatrix[i][j].find(
'%'))
449 + _sMatrix[i][j].substr(_sMatrix[i][j].find(
'%'));
452 if (_sMatrix[i][j].find(
"+/-") != string::npos)
454 _sMatrix[i][j] = _sMatrix[i][j].substr(0,_sMatrix[i][j].find(
"+/-"))
456 + _sMatrix[i][j].substr(_sMatrix[i][j].find(
"+/-")+3);
459 if (_sMatrix[i][j] ==
"inf")
461 _sMatrix[i][j] =
"\\infty";
464 if (_sMatrix[i][j] ==
"-inf")
466 _sMatrix[i][j] =
"-\\infty";
473 nLen = _sMatrix[i][j].length();
475 if (nLen > nLongest[j])
484 for (
long long int j = 0; j < _nCol; j++)
488 for (
long long int i = 0; i < _nLine; i++)
490 if (i < 5 || i >= _nLine - 5)
492 nLen = _sMatrix[i][j].length();
494 if (nLen > nLongest[j])
505 for (
long long int j = 0; j < _nCol; j++)
514 for (
long long int j = 0; j < _nCol; j++)
532 print(
"\\begin{table}[htb]");
533 print(
"\\centering");
534 sPrint =
"\\begin{tabular}{";
536 for (
long long int j = 0; j < _nCol; j++)
545 sPrint =
"\\begin{longtable}{";
547 for (
long long int j = 0; j < _nCol; j++)
553 print(
"\\label{tab:" + sLabel +
"}\\\\");
557 for (
int i = 0; i < nHeadLineCount; i++)
559 for (
long long int j = 0; j < _nCol; j++)
560 sPrint += _sMatrix[i][j] +
" & ";
562 sPrint = sPrint.substr(0,sPrint.length()-2) +
"\\\\\n";
565 for (
unsigned int i = 0; i < sPrint.length(); i++)
567 if (sPrint[i] ==
'_')
573 print(
"\\endfirsthead");
574 print(
"\\caption{"+
_lang.
get(
"OUTPUT_FORMAT_TEXLONG_CAPTION")+
"}\\\\");
580 print(
"\\multicolumn{" +
toString(_nCol) +
"}{c}{--- \\emph{"+
_lang.
get(
"OUTPUT_FORMAT_TEXLONG_FOOT")+
"} ---}\\\\");
581 print(
"\\bottomrule");
583 print(
"\\bottomrule");
584 print(
"\\endlastfoot");
592 for (
long long int i = 0; i < _nLine; i++)
594 for (
long long int j = 0; j < _nCol; j++)
596 if (_sMatrix[i][j] !=
"---")
597 sPrint += _sMatrix[i][j];
608 long long int nCol_0 = 0;
609 long long int nCol_1 = _nCol;
610 unsigned int nLine = 0;
611 int nNotRepeatFirstCol = 1;
615 for (
long long int j = 0; j < _nCol; j++)
617 if (_option.
getWindow()-4 < nLine+nLongest[j])
623 nLine += nLongest[j];
631 if (nCol_0 == nCol_1)
634 for (
long long int i = 0; i < _nLine; i++)
636 if (
bPrintTeX && _nLine >= 30 && i < nHeadLineCount)
639 if (!
bCompact || _nLine < 12 || (
bCompact && _nLine >= 12 && (i < 5 || i >= _nLine - 5)))
641 for (
long long int j = nCol_0*nNotRepeatFirstCol; j < nCol_1; j++)
643 if (i < nHeadLineCount && j == nCol_0*nNotRepeatFirstCol)
651 for (
unsigned int n = 0; n < nLongest[j] - _sMatrix[i][j].length() - 1; n++)
658 if (!
bFile && j == nCol_0*nNotRepeatFirstCol)
663 for (
unsigned int n = 0; n < nLongest[j] - _sMatrix[i][j].length(); n++)
669 if (
bPrintTeX && i >= nHeadLineCount && _sMatrix[i][j] !=
"---" && !
bSumBar)
676 if (_sMatrix[i][j].find(
':') == string::npos)
677 sPrint +=
'$' + _sMatrix[i][j];
679 sPrint += _sMatrix[i][j].substr(0,_sMatrix[i][j].find(
':')+2) +
"$" + _sMatrix[i][j].substr(_sMatrix[i][j].find(
':')+2);
682 sPrint += _sMatrix[i][j];
684 if (!nCol_0 && nCol_1 != _nCol && nNotRepeatFirstCol && i >= nHeadLineCount)
686 if (_sMatrix[i][0].find(
':') != string::npos)
687 nNotRepeatFirstCol = 0;
690 if (
bPrintTeX && i >= nHeadLineCount && _sMatrix[i][j] !=
"---")
693 if (!nNotRepeatFirstCol && nCol_0 && !j)
699 for (
unsigned int k = 0; k < sPrint.length(); k++)
701 if (sPrint[k] ==
'_')
711 else if (
bCompact && _nLine >= 10 && i == 5)
716 for (
long long int j = nCol_0*nNotRepeatFirstCol; j < nCol_1; j++)
718 for (
unsigned int k = 0; k < nLongest[j] - 5; k++)
720 if (j == nCol_0*nNotRepeatFirstCol && k == nLongest[j]-6)
728 if (!nNotRepeatFirstCol && nCol_0 && !j)
735 if (i == nHeadLineCount-1)
740 sPrint =
"\\midrule";
751 sPrint.assign(nLine+2,
'-');
755 sPrint.assign(nLen-1,
'=');
756 sPrint.insert(0,
"#");
770 sPrint.assign(nLine+2,
'-');
778 if (!nNotRepeatFirstCol)
783 for (
long long int j = nCol_1; j < _nCol; j++)
785 if (_option.
getWindow()-4 < nLine + nLongest[j])
791 nLine += nLongest[j];
795 while (nCol_1 != _nCol);
825 print(
"\\bottomrule");
826 print(
"\\end{tabular}");
828 print(
"\\label{tab:" + sLabel +
"}");
829 print(
"\\end{table}");
833 print(
"\\end{longtable}");
836 string sConsoleOut =
"";
885 format(_sMatrix, _nCol, _nLine, _option);
const std::string sVersion
This class implements the basic input/ output file system and provides functionalities to work with f...
std::string ValidFileName(std::string _sFileName, const std::string sExtension=".dat", bool checkExtension=true, bool doCleanPath=true) const
This member function evaluates, whether the passed filename is a valid filename. One may supply a pre...
std::string get(const std::string &sMessage, const std::vector< std::string > &vTokens) const
This member function returns the language string for the passed language identifier and replaces all ...
static void getline(std::string &sLine)
This function is an implementation replacing the std::getline() function.
static void printPreFmt(const std::string &__sLine, bool printingEnabled=true)
This member function appends the pre- formatted string to the buffer and informs the terminal that we...
static void print(const std::string &__sLine, bool printingEnabled=true)
This member function appends the passed string as a new output line to the buffer and informs the ter...
void format(std::string **_sMatrix, long long int _nCol, long long int _nLine, const Settings &_option, bool bDontAsk=false, int nHeadLineCount=1)
std::string getFileName() const
std::string getPrefix() const
std::string replaceTeXControls(const std::string &_sText)
void print(std::string sOutput)
void setPrefix(std::string _sPrefix)
void setPluginName(std::string _sPluginName)
void setStatus(bool bStatus)
std::string getCommentLine() const
std::string getPluginName() const
void setCompact(bool _bCompact)
std::string getDate(bool bForFile)
void setCommentLine(std::string _sCommentLine)
std::string sPluginPrefix
void setFileName(std::string sFile)
This class manages the setting values of the internal (kernel) settings of this application.
bool systemPrints() const
Returns, whether system messages shall be printed to the terminal.
size_t getWindow(int nWindow=0) const
Returns the current window size of the terminal.
std::string toSystemCodePage(std::string)
Converts an internal to an external string. Does nothing currently.
static const char MONTH[]
CONSTCD11 std::enable_if<!std::chrono::treat_as_floating_point< T >::value, T >::type trunc(T t) NOEXCEPT
std::string toString(int)
Converts an integer to a string without the Settings bloat.