23#include "../datamanagement/tablecolumnimpl.hpp"
24#include "../IgorLib/ReadWave.h"
25#include "../utils/tools.hpp"
26#include "../utils/BasicExcel.hpp"
27#include "../utils/tinyxml2.h"
28#include "../ui/language.hpp"
29#include "../version.h"
30#include "../../kernel.hpp"
32#define DEFAULT_PRECISION 14
57 if (sExt ==
"dat" && ZygoLib::DatFile::isDatFile(filename))
60 if (sExt ==
"txt" || sExt ==
"dat" || !sExt.length())
84 if (sExt ==
"jdx" || sExt ==
"dx" || sExt ==
"jcm")
119 long long int nLine = 0;
120 long long int nComment = 0;
126 if (!vFileContents.size())
131 for (
size_t i = 0; i < vFileContents.size(); i++)
144 for (
size_t i = 0; i < vFileContents.size(); i++)
146 if (vFileContents[i][0] ==
'#')
153 for (
size_t i = 0; i < vFileContents.size(); i++)
161 if (vFileContents.size() == nComment)
165 for (
size_t i = 0; i < vFileContents.size(); i++)
167 size_t elem =
tokenize(vFileContents[i],
" ",
true).size();
174 nRows = vFileContents.size() - nComment;
191 for (
size_t i = 0; i < vFileContents.size(); i++)
193 if (vFileContents[i][0] ==
'#' || (i < nComment && !
isNumeric(vFileContents[i])))
200 vector<string> vLine =
tokenize(vFileContents[i],
" ",
true);
205 if (vLine.size() >
nCols)
210 for (
size_t j = 0; j < vLine.size(); j++)
213 fileData->at(j)->setValue(nLine, vLine[j]);
244 size_t nNumberOfHeadlines = 1u;
273 fFileStream <<
"# NumeRe: Framework für Numerische Rechnungen" <<
"\n";
274 fFileStream <<
"#=============================================" <<
"\n";
295 for (
size_t i = 0; i < nNumberOfLines; i++)
299 for (
long long int j = 0; j <
nCols; j++)
328 for (
long long int i = 0; i <
nRows; i++)
330 for (
long long int j = 0; j <
nCols; j++)
366 for (
size_t j = 0; j < vColumnWidth.size(); j++)
372 if (j+1 < vColumnWidth.size())
392 long long int _nHeadline = 0;
393 string sCommentSign =
"#";
397 if (vFileContents.size() > 14)
398 sCommentSign.append(vFileContents[13].length()-1,
'=');
404 if (nComment >= 13 && vFileContents[2].substr(0, 21) ==
"# NumeRe: Framework f")
408 for (
size_t k = 11; k < vFileContents.size(); k++)
411 if (vFileContents[k] == sCommentSign)
415 for (
int kk = k-1; kk >= 0; kk--)
417 if (vFileContents[kk] ==
"#")
428 else if (nComment == 1)
432 for (
size_t i = 0; i < vFileContents.size(); i++)
434 if (vFileContents[i][0] ==
'#')
437 if (vFileContents[i].find(
' ') != string::npos)
442 if (vFileContents[i][1] !=
' ')
444 for (
unsigned int n = 0; n < vFileContents[i].length(); n++)
446 if (vFileContents[i][n] !=
'#')
448 if (vFileContents[i][n] !=
' ')
449 vFileContents[i].insert(n,
" ");
459 if (
nCols + 1 ==
tokenize(vFileContents[i],
" ",
true).size())
473 else if (vFileContents[0][0] ==
'#' || !
isNumeric(vFileContents[0]))
478 for (
size_t i = 0; i < vFileContents.size(); i++)
480 if (vFileContents[i][0] !=
'#' &&
isNumeric(vFileContents[i]))
482 if (vFileContents[i-1][0] ==
'#')
484 if ((
nCols > 1 && vFileContents[i-1].find(
' ') != string::npos)
485 || (
nCols == 1 && vFileContents[i-1].length() > 1))
490 if (vFileContents[i-1][1] !=
' ')
492 for (
unsigned int n = 0; n < vFileContents[i-1].length(); n++)
494 if (vFileContents[i-1][n] !=
'#')
496 if (vFileContents[i-1][n] !=
' ')
497 vFileContents[i-1].insert(n,
" ");
507 if (
tokenize(vFileContents[i-1],
" ",
true).size() <=
nCols+1)
515 && vFileContents[i-2][0] ==
'#'
516 && ((vFileContents[i-2].find(
' ') != string::npos &&
nCols > 1)
517 || (
nCols == 1 && vFileContents[i-2].length() > 1)))
522 if (vFileContents[i-2][1] !=
' ')
524 for (
size_t n = 0; n < vFileContents[i-2].length(); n++)
526 if (vFileContents[i-2][n] !=
'#')
528 if (vFileContents[i-2][n] !=
' ')
529 vFileContents[i-2].insert(n,
" ");
539 if (
tokenize(vFileContents[i-2],
" ",
true).size() <=
nCols+1)
545 if ((vFileContents[i-1].find(
' ') != string::npos &&
nCols > 1)
546 || (
nCols == 1 && vFileContents[i-1].length() > 1))
551 if (vFileContents[i-1][1] !=
' ')
553 for (
size_t n = 0; n < vFileContents[i-1].length(); n++)
555 if (vFileContents[i-1][n] !=
'#')
557 if (vFileContents[i-1][n] !=
' ')
558 vFileContents[i-1].insert(n,
" ");
568 if (
tokenize(vFileContents[i-1],
" ",
true).size() ==
nCols+1)
576 && vFileContents[i-2][0] ==
'#'
577 && ((vFileContents[i-2].find(
' ') != string::npos &&
nCols > 1)
578 || (
nCols == 1 && vFileContents[i-2].length() > 1)))
583 if (vFileContents[i-2][1] !=
' ')
585 for (
unsigned int n = 0; n < vFileContents[i-2].length(); n++)
587 if (vFileContents[i-2][n] !=
'#')
589 if (vFileContents[i-2][n] !=
' ')
590 vFileContents[i-2].insert(n,
" ");
600 if (
tokenize(vFileContents[i-2],
" ",
true).size() ==
nCols+1)
619 for (
size_t i = 0; i < vFileContents.size(); i++)
622 if (vFileContents[i][0] ==
'#' || !
isNumeric(vFileContents[i]))
636 for (
size_t k = i+1; k < vFileContents.size(); k++)
642 if (vFileContents[k].find(
" _ ") != string::npos
643 || (vFileContents[k].find_first_not_of(
" #") != string::npos && vFileContents[k][vFileContents[k].find_first_not_of(
" #")] ==
'_')
644 || vFileContents[k].back() ==
'_')
650 if (vFileContents[k][0] !=
'#' &&
isNumeric(vFileContents[k]))
654 if (vFileContents[k].substr(0, 4) ==
"#===" || vFileContents[k].substr(0, 5) ==
"# ===")
661 if (vFileContents[k].length() == vFileContents[i].length())
664 for (
unsigned int l = 0; l < vFileContents[k].length(); l++)
666 if (vFileContents[i][l] !=
' ' && vFileContents[k][l] ==
' ')
667 vFileContents[k][l] =
'_';
670 else if (vFileContents[k].length() < vFileContents[i].length() && vFileContents[i].back() !=
' ' && vFileContents[k].back() !=
' ')
672 vFileContents[k].append(vFileContents[i].length() - vFileContents[k].length(),
' ');
675 for (
unsigned int l = 0; l < vFileContents[k].length(); l++)
677 if (vFileContents[i][l] !=
' ' && vFileContents[k][l] ==
' ')
678 vFileContents[k][l] =
'_';
681 else if (vFileContents[k].length() > vFileContents[i].length() && vFileContents[k].back() !=
' ' && vFileContents[i].back() !=
' ')
684 for (
unsigned int l = 0; l < vFileContents[i].length(); l++)
686 if (vFileContents[i][l] !=
' ' && vFileContents[k][l] ==
' ')
687 vFileContents[k][l] =
'_';
694 bool bBreakSignal =
false;
695 vector<string> vHeadline;
696 vHeadline.resize((
unsigned int)(2*
nCols),
"");
703 for (
size_t k = i; k < vFileContents.size(); k++)
706 if ((vFileContents[k][0] !=
'#' &&
isNumeric(vFileContents[k])) || i+nComment == k)
710 if (vFileContents[k].substr(0, 4) ==
"#===" || vFileContents[k].substr(0, 5) ==
"# ===")
714 vector<string> vLine =
tokenize(vFileContents[k],
" ",
true);
718 if (vLine.front() ==
"#")
719 vLine.erase(vLine.begin());
725 for (
size_t j = 0; j < vLine.size(); j++)
728 vHeadline.push_back(
"");
730 if (k != i && j >= vHeadline.size())
737 if (vLine[j].find_first_not_of(
'_') == string::npos)
742 while (vLine[j].front() ==
'_')
745 while (vLine[j].back() ==
'_')
754 if (!vHeadline[j].length())
758 vHeadline[j] +=
"\n";
769 for (
size_t col = 0; col <
std::min(vHeadline.size(), (
size_t)
nCols); col++)
774 fileData->at(col)->m_sHeadLine = vHeadline[col];
797 vector<size_t> vColumnWidths;
804 for (
long long int j = 0; j <
nCols; j++)
813 vColumnWidths.push_back(
max(NUMBERFIELDLENGTH, pCellExtents.first));
815 if (nNumberOfLines < pCellExtents.second)
816 nNumberOfLines = pCellExtents.second;
819 return vColumnWidths;
829 isLegacy(false), timeStamp(0), versionMajor(0), versionMinor(0),
830 versionBuild(0), fileVersionRead(1.0f)
884 writeNumField<size_t>(10);
894 long long int t = _time64(0);
895 writeNumBlock<long long int>(&t, 1);
897 writeNumBlock<double>(
nullptr, 0);
899 writeNumBlock<double>(
nullptr, 0);
901 writeNumBlock<double>(
nullptr, 0);
925 long long int appZeros = 0;
928 fFileStream.write((
char*)&appZeros,
sizeof(
long long int));
959 size_t posEnd =
tellp();
967 writeNumField<size_t>(posEnd);
1007 size_t lenPos =
tellp();
1009 writeNumField<size_t>(lenPos);
1012 writeNumBlock<mu::value_type>(&values[0], values.size());
1014 size_t endPos =
tellp();
1016 writeNumField<size_t>(endPos-lenPos);
1031 size_t lenPos =
tellp();
1033 writeNumField<size_t>(lenPos);
1038 size_t endPos =
tellp();
1040 writeNumField<size_t>(endPos-lenPos);
1066 time_t oldTime = readNumField<time_t>();
1074 nRows = readNumField<long long int>();
1075 nCols = readNumField<long long int>();
1086 short fileVerMajor = readNumField<short>();
1087 short fileVerMinor = readNumField<short>();
1101 size_t fileEnd = readNumField<size_t>();
1108 if (sha_check !=
sha)
1151 if (dataType !=
"DTYPE=DOUBLE")
1156 nRows = readNumField<long long int>();
1157 nCols = readNumField<long long int>();
1171 readNumField<long long int>();
1172 readNumField<long long int>();
1174 long long int appZeros = 0;
1177 fFileStream.read((
char*)&appZeros,
sizeof(
long long int));
1195 open(ios::binary | ios::in);
1240 long long int stringBlockSize;
1241 long long int dataarrayrows;
1242 long long int dataarraycols;
1248 double** data = readDataArray<double>(dataarrayrows, dataarraycols);
1250 for (
long long int j = 0; j < dataarraycols; j++)
1253 fileData->at(j)->m_sHeadLine = sHeads[j];
1255 for (
long long int i = 0; i < dataarrayrows; i++)
1257 fileData->at(j)->setValue(i, data[i][j]);
1264 for (
long long int i = 0; i < dataarrayrows; i++)
1283 if (sDataType ==
"DTYPE=NONE")
1286 if (sDataType ==
"DTYPE=COMPLEX")
1289 col->m_sHeadLine = sHeadLine;
1290 long long int size = 0;
1295 else if (sDataType ==
"DTYPE=LOGICAL")
1298 col->m_sHeadLine = sHeadLine;
1299 long long int size = 0;
1304 else if (sDataType ==
"DTYPE=DATETIME")
1307 col->m_sHeadLine = sHeadLine;
1308 long long int size = 0;
1313 else if (sDataType ==
"DTYPE=STRING")
1316 col->m_sHeadLine = sHeadLine;
1317 long long int size = 0;
1322 else if (sDataType ==
"DTYPE=CATEGORICAL")
1325 col->m_sHeadLine = sHeadLine;
1326 long long int size = 0;
1347 if (sDataType ==
"DTYPE=NONE")
1350 if (sDataType ==
"DTYPE=COMPLEX")
1356 readNumField<size_t>();
1359 if (sColType ==
"CTYPE=VALUE")
1361 else if (sColType ==
"CTYPE=DATETIME")
1363 else if (sColType ==
"CTYPE=LOGICAL")
1368 col->m_sHeadLine = sHeadLine;
1369 long long int size = 0;
1374 else if (sDataType ==
"DTYPE=STRING")
1380 readNumField<size_t>();
1383 if (sColType ==
"CTYPE=STRING")
1385 else if (sColType ==
"CTYPE=CATEGORICAL")
1390 col->m_sHeadLine = sHeadLine;
1391 long long int size = 0;
1399 seekg(readNumField<size_t>());
1418 bool* bValidEntry =
new bool[
nCols];
1419 char** cHeadLine =
new char*[
nCols];
1420 long long int* nAppendedZeros =
new long long int[
nCols];
1427 for (
long long int i = 0; i <
nCols; i++)
1432 fFileStream.read((
char*)&nLength,
sizeof(
size_t));
1433 cHeadLine[i] =
new char[nLength];
1434 fFileStream.read(cHeadLine[i],
sizeof(
char)*nLength);
1435 fileData->at(i)->m_sHeadLine.resize(nLength-1);
1437 for (
unsigned int j = 0; j < nLength-1; j++)
1439 fileData->at(i)->m_sHeadLine[j] = cHeadLine[i][j];
1455 double* data =
new double[
nCols];
1457 for (
long long int i = 0; i <
nRows; i++)
1461 for (
long long int j = 0; j <
nCols; j++)
1463 fileData->at(j)->setValue(i, data[j]);
1472 for (
long long int i = 0; i <
nRows; i++)
1475 for (
long long int j = 0; j <
nCols; j++)
1477 if (!bValidEntry[j])
1483 for (
long long int i = 0; i <
nCols; i++)
1484 delete[] cHeadLine[i];
1487 delete[] bValidEntry;
1488 delete[] nAppendedZeros;
1507 type.erase(0, type.find(
'=')+1);
1513 if (type ==
"DOUBLE")
1515 double* data = readNumBlock<double>(size);
1518 else if (type ==
"INT")
1520 int* data = readNumBlock<int>(size);
1523 else if (type ==
"LINT")
1525 long int* data = readNumBlock<long int>(size);
1528 else if (type ==
"LLINT")
1530 long long int* data = readNumBlock<long long int>(size);
1533 else if (type ==
"UINT")
1535 size_t* data = readNumBlock<size_t>(size);
1538 else if (type ==
"BYTE")
1540 char* data = readNumBlock<char>(size);
1543 else if (type ==
"STRING")
1570 if (type ==
"DOUBLE")
1571 delete[] (
double*)data;
1572 else if (type ==
"INT")
1573 delete[] (
int*)data;
1574 else if (type ==
"LINT")
1575 delete[] (
long int*)data;
1576 else if (type ==
"LLINT")
1577 delete[] (
long long int*)data;
1578 else if (type ==
"UINT")
1579 delete[] (
size_t*)data;
1580 else if (type ==
"BYTE")
1581 delete[] (
char*)data;
1582 else if (type ==
"STRING")
1583 delete[] (
string*)data;
1682 size_t pos =
tellg();
1710 for (
size_t i = 0; i <
vFileIndex.size(); i++)
1735 open(ios::binary | ios::in);
1749 short fileVerMajor = readNumField<short>();
1750 readNumField<short>();
1760 size_t nNumberOfTables = readNumField<size_t>();
1765 vFileIndex = vector<size_t>(nNumberOfTables, 0u);
1770 long long int size = 0;
1771 size_t* nIndex = readNumBlock<size_t>(size);
1841 string sLabx_substr =
"";
1842 long long int nLine = 0;
1850 sLabx += sLabx_substr;
1855 if (!sLabx.length() || sLabx.find(
"<allchannels count=") == string::npos)
1860 sLabx_substr = sLabx.substr(sLabx.find(
"<allchannels count="));
1861 sLabx_substr = sLabx_substr.substr(sLabx_substr.find(
"=\"")+2, sLabx_substr.find(
"\">")-sLabx_substr.find(
"=\"")-2);
1869 vector<string> vHeadLines;
1870 vector<string> vCols;
1874 sLabx_substr = sLabx.substr(sLabx.find(
"<allchannels"), sLabx.find(
"</allchannels>")-sLabx.find(
"<allchannels"));
1875 sLabx_substr = sLabx_substr.substr(sLabx_substr.find(
"<channels"));
1879 for (
long long int i = 0; i <
nCols; i++)
1883 vCols.push_back(sLabx_substr.substr(sLabx_substr.find(
"<values"), sLabx_substr.find(
"</channel>")-sLabx_substr.find(
"<values")));
1889 if (sLabx_substr.find(
"<unit />") != string::npos && sLabx_substr.find(
"<unit />") < sLabx_substr.find(
"<unit>"))
1890 vHeadLines.push_back(sLabx_substr.substr(sLabx_substr.find(
"<quantity>")+10, sLabx_substr.find(
"</quantity>")-sLabx_substr.find(
"<quantity>")-10));
1893 vHeadLines.push_back(sLabx_substr.substr(sLabx_substr.find(
"<quantity>")+10, sLabx_substr.find(
"</quantity>")-sLabx_substr.find(
"<quantity>")-10)
1894 +
"_[" + sLabx_substr.substr(sLabx_substr.find(
"<unit>")+6, sLabx_substr.find(
"</unit>")-sLabx_substr.find(
"<unit>")-6) +
"]");
1899 vHeadLines.back() =
utf8parser(vHeadLines.back());
1900 sLabx_substr.erase(0, sLabx_substr.find(
"</channels>")+11);
1904 if (
StrToInt(vCols[i].substr(vCols[i].find(
"count=\"")+7, vCols[i].find(
"\">")-vCols[i].find(
"count=\"")-7)) > nLine)
1905 nLine =
StrToInt(vCols[i].substr(vCols[i].find(
"count=\"")+7, vCols[i].find(
"\">")-vCols[i].find(
"count=\"")-7));
1918 for (
long long int i = 0; i <
nCols; i++)
1921 fileData->at(i)->m_sHeadLine = vHeadLines[i];
1924 long long int nElements = 0;
1929 for (
long long int i = 0; i <
nCols; i++)
1933 if (vCols[i].find(
"<values count=\"0\" />") == string::npos)
1937 nElements =
StrToInt(vCols[i].substr(vCols[i].find(
'"')+1,
1938 vCols[i].find(
'"', vCols[i].find(
'"')+1)-1-vCols[i].find(
'"')));
1939 vCols[i].erase(0, vCols[i].find(
'>')+1);
1943 for (
long long int j = 0; j <
min(nElements,
nRows); j++)
1946 vCols[i].find(
'<', vCols[i].find(
'/'))-vCols[i].find(
"<value"))));
1947 vCols[i].erase(0, vCols[i].find(
'>', vCols[i].find(
'/'))+1);
1965 return StrToDb(sTag.substr(7, sTag.find(
'<', 7)-7));
1999 long long int nLine = 0;
2000 long long int nComment = 0;
2001 vector<string> vHeadLine;
2007 nLine = vFileData.size();
2028 vHeadLine.resize(
nCols);
2032 string sValidSymbols =
"0123456789.,;-+eE INFAinfa/";
2033 sValidSymbols += cSep;
2039 if (vFileData[0].find_first_not_of(sValidSymbols) != string::npos)
2043 vector<string> vTokens =
tokenize(vFileData[0],
string(1, cSep));
2045 for (
size_t i = 0; i < vTokens.size(); i++)
2056 for (
size_t n = 0; n < (vTokens.size() <
nCols ? vTokens.size() :
nCols); n++)
2066 vFileData[0].clear();
2084 for (
long long int j = 0; j <
nCols; j++)
2095 for (
long long int j = 0; j <
nCols; j++)
2097 fileData->at(j)->m_sHeadLine = vHeadLine[j];
2107 if (
sFileName.find(
'/') == string::npos)
2117 for (
size_t i = nComment; i < vFileData.size(); i++)
2120 if (!vFileData[i].length())
2124 vector<string> vTokens =
tokenize(vFileData[i],
string(1, cSep));
2127 for (
size_t j = 0; j < vTokens.size(); j++)
2133 fileData->at(j)->setValue(i-nComment, vTokens[j]);
2154 for (
long long int j = 0; j <
nCols; j++)
2166 for (
long long int i = 0; i <
nRows; i++)
2168 for (
long long int j = 0; j <
nCols; j++)
2203 if (vTextData[0].find(
'.') != string::npos && vTextData[0].find(
',') != string::npos && vTextData[0].find(
'\t') != string::npos)
2205 else if (vTextData[0].find(
';') != string::npos && (vTextData[0].find(
',') != string::npos || vTextData[0].find(
'.') != string::npos) && vTextData[0].find(
'\t') != string::npos)
2207 else if (vTextData[0].find(
'\t') != string::npos)
2209 else if (vTextData[0].find(
';') != string::npos)
2211 else if (vTextData[0].find(
',') != string::npos)
2213 else if (vTextData[0].find(
' ') != string::npos && vTextData.size() > 1 && vTextData[1].find(
' ') != string::npos)
2217 if (vTextData[0].find(
',') != string::npos)
2219 else if (vTextData[0].find(
';') != string::npos)
2221 else if (vTextData[0].find(
'\t') != string::npos)
2223 else if (vTextData[0].find(
' ') != string::npos)
2235 for (
size_t i = 0; i < vTextData.size(); i++)
2239 for (
size_t j = 0; j < vTextData[i].length(); j++)
2241 if (vTextData[i][j] == cSep)
2247 else if (nCol != cols)
2251 else if (cSep ==
';')
2253 else if (cSep ==
'\t')
2255 else if (cSep ==
' ')
2263 if (i+1 == vTextData.size())
2288 for (
size_t i = 0; i < vTextData.size(); i++)
2292 for (
size_t j = 0; j < vTextData[i].length(); j++)
2294 if (vTextData[i][j] == cSep)
2304 else if (cSep ==
';')
2306 else if (cSep ==
'\t')
2308 else if (cSep ==
' ')
2316 if (i+1 == vTextData.size())
2355 if (sLabel.find(
'/') != string::npos)
2356 sLabel.erase(0, sLabel.rfind(
'/')+1);
2358 if (sLabel.find(
".tex") != string::npos)
2359 sLabel.erase(sLabel.rfind(
".tex"));
2361 while (sLabel.find(
' ') != string::npos)
2362 sLabel[sLabel.find(
' ')] =
'_';
2377 string sPrint =
"\\begin{tabular}{";
2379 for (
long long int j = 0; j <
nCols; j++)
2390 string sPrint =
"\\begin{longtable}{";
2392 for (
long long int j = 0; j <
nCols; j++)
2398 fFileStream <<
"\\label{tab:" + sLabel +
"}\\\\\n";
2422 for (
long long int i = 0; i <
nRows; i++)
2424 for (
long long int j = 0; j <
nCols; j++)
2480 fFileStream <<
"% NumeRe: Framework für Numerische Rechnungen" <<
"\n";
2481 fFileStream <<
"%=============================================" <<
"\n";
2509 for (
long long int j = 0; j <
nCols; j++)
2512 sPrint = sPrint.substr(0, sPrint.length()-2) +
"\\\\\n";
2518 for (
size_t i = 0; i < sPrint.length(); i++)
2520 if (sPrint[i] ==
'_')
2538 size_t headlines = 0u;
2543 for (
long long int i = 0; i <
nCols; i++)
2550 if (extents.second > headlines)
2551 headlines = extents.second;
2569 string sReturn = _sText;
2571 for (
unsigned int i = 0; i < sReturn.length(); i++)
2573 if (sReturn[i] ==
'Ä' || sReturn[i] == (
char)142)
2574 sReturn.replace(i,1,
"\\\"A");
2576 if (sReturn[i] ==
'ä' || sReturn[i] == (
char)132)
2577 sReturn.replace(i,1,
"\\\"a");
2579 if (sReturn[i] ==
'Ö' || sReturn[i] == (
char)153)
2580 sReturn.replace(i,1,
"\\\"O");
2582 if (sReturn[i] ==
'ö' || sReturn[i] == (
char)148)
2583 sReturn.replace(i,1,
"\\\"o");
2585 if (sReturn[i] ==
'Ü' || sReturn[i] == (
char)154)
2586 sReturn.replace(i,1,
"\\\"U");
2588 if (sReturn[i] ==
'ü' || sReturn[i] == (
char)129)
2589 sReturn.replace(i,1,
"\\\"u");
2591 if (sReturn[i] ==
'ß' || sReturn[i] == (
char)225)
2592 sReturn.replace(i,1,
"\\ss ");
2594 if (sReturn[i] ==
'°' || sReturn[i] == (
char)248)
2595 sReturn.replace(i,1,
"$^\\circ$");
2597 if (sReturn[i] == (
char)196 || sReturn[i] == (
char)249)
2598 sReturn.replace(i,1,
"\\pm ");
2600 if (sReturn[i] == (
char)171 || sReturn[i] == (
char)174)
2601 sReturn.replace(i,1,
"\"<");
2603 if (sReturn[i] == (
char)187 || sReturn[i] == (
char)175)
2604 sReturn.replace(i,1,
"\">");
2606 if ((!i && sReturn[i] ==
'_') || (i && sReturn[i] ==
'_' && sReturn[i-1] !=
'\\'))
2607 sReturn.insert(i,1,
'\\');
2610 if (sReturn.find(
"+/-") != string::npos)
2612 sReturn = sReturn.substr(0, sReturn.find(
"+/-"))
2614 + sReturn.substr(sReturn.find(
"+/-")+3);
2635 while (sNumber.find(
'e') != std::string::npos)
2637 sNumber = sNumber.substr(0, sNumber.find(
'e'))
2639 + (sNumber[sNumber.find(
'e')+1] ==
'-' ?
"-" :
"")
2640 + sNumber.substr(sNumber.find_first_not_of(
'0', sNumber.find(
'e')+2))
2645 if (sNumber ==
"inf")
2646 sNumber =
"\\infty";
2648 if (sNumber ==
"-inf")
2649 sNumber =
"-\\infty";
2651 if (sNumber ==
"nan")
2655 return "$" + sNumber +
"$";
2721 size_t nTableStart = 0;
2722 std::vector<MetaData> vMeta(1u);
2729 std::vector<std::string> vFileContents =
readTextFile(
true);
2732 if (!vFileContents.size())
2737 for (
size_t i = 0; i < vFileContents.size(); i++)
2743 if (vFileContents[i].substr(0, 2) ==
"##"
2745 && vFileContents[i].substr(0, 6) !=
"##END=")
2750 sComment += vFileContents[i].substr(2);
2756 if (vFileContents[i].substr(0, 10) ==
"##NTUPLES=")
2766 for (
size_t j = i+1; j < vFileContents.size(); j++)
2772 if (vFileContents[j].substr(0, 2) ==
"##"
2773 && vFileContents[j].substr(0, 7) !=
"##PAGE=")
2778 sComment += vFileContents[j].substr(2);
2783 if (vFileContents[j].substr(0, 9) ==
"##SYMBOL=")
2785 else if (vFileContents[j].substr(0, 10) ==
"##VARTYPE=")
2787 else if (vFileContents[j].substr(0, 9) ==
"##VARDIM=")
2789 else if (vFileContents[j].substr(0, 8) ==
"##UNITS=")
2791 else if (vFileContents[j].substr(0, 8) ==
"##FIRST=")
2793 else if (vFileContents[j].substr(0, 7) ==
"##LAST=")
2795 else if (vFileContents[j].substr(0, 9) ==
"##FACTOR=")
2797 else if (vFileContents[j].substr(0, 7) ==
"##PAGE=")
2803 size_t dependentCount = 0;
2807 for (
size_t n = 0; n < varType.size(); n++)
2809 if (varType[n] ==
"DEPENDENT")
2813 if (dependentCount > vMeta.size())
2816 vMeta.back().m_symbol = symbol[n];
2817 vMeta.back().m_yUnit = units[n];
2819 if (varDim[n].size())
2820 vMeta.back().m_points =
StrToInt(varDim[n]);
2822 if (factor[n].size())
2823 vMeta.back().m_yFactor =
StrToDb(factor[n]);
2829 for (
size_t n = 0; n < varType.size(); n++)
2831 if (varType[n] ==
"INDEPENDENT" && symbol[n] ==
"X")
2835 meta.m_xUnit = units[n];
2837 if (factor[n].size())
2838 meta.m_xFactor =
StrToDb(factor[n]);
2840 if (firstVal[n].size())
2841 meta.m_firstX =
StrToDb(firstVal[n]);
2843 if (lastVal[n].size())
2844 meta.m_lastX =
StrToDb(lastVal[n]);
2857 if (vFileContents[i].substr(0, 6) ==
"##END=")
2859 vFileContents.erase(vFileContents.begin()+i+1, vFileContents.end());
2869 nTableStart =
readTable(vFileContents, nTableStart, vMeta.size() > page ? vMeta[page] : vMeta.front());
2872 while (nTableStart + 1 < vFileContents.size());
2875 for (
long long int j = 0; j <
nCols; j++)
2895 std::vector<double> vLine;
2896 long long int nPageOffset =
nCols;
2897 size_t nDataStart = 0;
2900 for (
size_t i = nTableStart; i < vFileContents.size(); i++)
2903 if (vFileContents[i].substr(0, 10) ==
"##NPOINTS=")
2906 if (vFileContents[i].substr(0,11) ==
"##XYPOINTS="
2907 || vFileContents[i].substr(0, 9) ==
"##XYDATA="
2908 || vFileContents[i].substr(0, 12) ==
"##PEAKTABLE="
2909 || vFileContents[i].substr(0, 12) ==
"##DATATABLE=")
2912 std::string sXYScheme = vFileContents[i].substr(vFileContents[i].find(
'=')+1);
2916 while (sXYScheme.find(
' ') != std::string::npos)
2917 sXYScheme.erase(sXYScheme.find(
' '), 1);
2920 if (sXYScheme.rfind(
')')+1 < sXYScheme.length())
2921 sXYScheme.erase(sXYScheme.rfind(
')')+1);
2924 if (sXYScheme.find(
'Y') == std::string::npos && meta.
m_symbol.length())
2928 if (sXYScheme ==
"(XY..XY)" || sXYScheme ==
"(X,Y..X,Y)")
2930 else if (sXYScheme ==
"(XY)" || sXYScheme ==
"(X,Y)")
2932 else if (sXYScheme ==
"(X++(Y..Y))")
2934 else if (sXYScheme ==
"(X++)(Y..Y)")
2955 for (
long long int j = nPageOffset; j <
nCols; j++)
2961 std::string sDataType =
"";
2966 for (
size_t j = nTableStart; j < nDataStart-1; j++)
2969 if (vFileContents[j].find(
"$$") != string::npos)
2970 vFileContents[j].erase(vFileContents[j].find(
"$$"));
2973 if (vFileContents[j].substr(0,10) ==
"##XFACTOR=")
2976 if (vFileContents[j].substr(0,10) ==
"##YFACTOR=")
2979 if (vFileContents[j].substr(0,9) ==
"##FIRSTX=")
2982 if (vFileContents[j].substr(0,8) ==
"##LASTX=")
2986 if (vFileContents[j].substr(0,9) ==
"##XUNITS=")
2988 meta.
m_xUnit = vFileContents[j].substr(9);
2993 if (vFileContents[j].substr(0,9) ==
"##YUNITS=")
2995 meta.
m_yUnit = vFileContents[j].substr(9);
3000 if (vFileContents[j].substr(0,11) ==
"##DATATYPE=")
3002 sDataType = vFileContents[j].substr(11);
3010 meta.
m_xUnit =
"Wellenzahl k [cm^-1]";
3012 meta.
m_xUnit =
"Wellenlänge lambda [mu m]";
3014 meta.
m_xUnit =
"Wellenlänge lambda [nm]";
3018 meta.
m_xUnit =
"Frequenz f [Hz]";
3026 meta.
m_yUnit =
"Transmission";
3032 meta.
m_yUnit =
"Kubelka-Munk";
3038 size_t currentRow = 0;
3045 for (
size_t j = nDataStart; j < vFileContents.size() - 1; j++)
3048 if (vFileContents[j].substr(0, 6) ==
"##END="
3049 || vFileContents[j].substr(0, 7) ==
"##PAGE=")
3053 if (vFileContents[j].substr(0, 2) ==
"##")
3057 if (vFileContents[j].find(
"$$") != string::npos)
3059 vFileContents[j].erase(vFileContents[j].find(
"$$"));
3079 for (
size_t k = 0; k < vLine.size(); k++)
3082 currentRow += k % 2;
3096 for (
size_t k = 2; k < vLine.size(); k++)
3105 for (
size_t k = 0; k < vLine.size(); k++)
3114 return vFileContents.size();
3130 if (sLine.find(
"##") == string::npos || sLine.find(
'=') == string::npos)
3133 for (
size_t i = 0; i < sLine.length(); i++)
3136 if (sLine[i] ==
' ' || sLine[i] ==
'-' || sLine[i] ==
'_')
3143 if (sLine[i] >=
'a' && sLine[i] <=
'z')
3144 sLine[i] +=
'A'-
'a';
3147 if (sLine[i] ==
'=')
3169 std::vector<double> vLine;
3170 std::string sValue =
"";
3171 const std::string sNumericChars =
"0123456789.+-";
3172 double lastDiff = 0;
3177 for (
size_t i = sLine.find_first_not_of(
" \t"); i < sLine.length(); i++)
3181 if ((sLine[i] >=
'0' && sLine[i] <=
'9') || sLine[i] ==
'.')
3183 else if (sValue.length()
3184 && (sLine[i] ==
'e' || sLine[i] ==
'E')
3185 && sLine.length() > i+2
3186 && (sLine[i] ==
'+' || sLine[i] ==
'-')
3187 && sNumericChars.find(sValue[0]) != std::string::npos)
3189 else if (sValue.length()
3190 && (sLine[i] ==
'+' || sLine[i] ==
'-')
3191 && sNumericChars.find(sValue[0]) != std::string::npos
3192 && (sValue[sValue.length()-1] ==
'e' || sValue[sValue.length()-1] ==
'E'))
3199 if (sValue.length())
3201 if ((sValue[0] >=
'J' && sValue[0] <=
'R'))
3204 sValue[0] =
toString(sValue[0]-
'J'+1)[0];
3206 vLine.push_back(vLine.back()+lastDiff);
3208 else if ((sValue[0] >=
'j' && sValue[0] <=
'r'))
3211 sValue[0] =
toString(sValue[0]-
'j'+1)[0];
3213 vLine.push_back(vLine.back()+lastDiff);
3215 else if (sValue[0] ==
'%')
3219 vLine.push_back(vLine.back());
3221 else if ((sValue[0] >=
'S' && sValue[0] <=
'Z') || sValue[0] ==
's')
3224 if (sValue[0] ==
's')
3227 sValue[0] = sValue[0]-
'S'+
'1';
3231 for (
int j = 0; j < iter-1; j++)
3232 vLine.push_back(vLine.back()+lastDiff);
3239 vLine.push_back(
StrToDb(sValue));
3247 if (sLine[i] >=
'A' && sLine[i] <=
'I')
3248 sValue +=
toString(sLine[i]-
'A'+1)[0];
3249 else if (sLine[i] >=
'a' && sLine[i] <=
'i')
3250 sValue +=
toString(
'a'-sLine[i]-1);
3251 else if (sLine[i] ==
'@')
3253 else if (sLine[i] ==
'%' && vLine.size() && sLine.size() > i+1)
3255 vLine.push_back(vLine.back());
3258 else if ((vLine.size()
3259 && ((sLine[i] >=
'J' && sLine[i] <=
'R')
3260 || (sLine[i] >=
'j' && sLine[i] <=
'r')
3261 || (sLine[i] >=
'S' && sLine[i] <=
'Z')
3262 || sLine[i] ==
's'))
3272 if (sValue.length())
3274 if (vLine.size() == 1)
3276 if ((sValue[0] >=
'J' && sValue[0] <=
'R'))
3279 sValue[0] =
toString(sValue[0]-
'J'+1)[0];
3280 vLine.push_back(vLine.back()+
StrToDb(sValue));
3282 else if ((sValue[0] >=
'j' && sValue[0] <=
'r'))
3285 sValue[0] =
toString(sValue[0]-
'j'+1)[0];
3286 vLine.push_back(vLine.back()-
StrToDb(sValue));
3288 else if (sValue[0] ==
'%')
3291 vLine.push_back(vLine.back());
3295 if ((sValue[0] >=
'S' && sValue[0] <=
'Z') || sValue[0] ==
's')
3298 if (sValue[0] ==
's')
3301 sValue[0] = sValue[0]-
'S'+
'1';
3309 for (
int j = 0; j < iter-2; j++)
3310 vLine.push_back(vLine.back()+lastDiff);
3315 else if (isdigit(sValue[0]) || sValue[0] ==
'+' || sValue[0] ==
'-')
3316 vLine.push_back(
StrToDb(sValue));
3353 string sODS_substr =
"";
3354 vector<string> vTables;
3355 vector<string> vMatrix;
3356 long long int nCommentLines = 0;
3357 long long int nMaxCols = 0;
3370 sODS.erase(0, sODS.find(
"<office:spreadsheet>"));
3377 sODS.erase(0, sODS.find(
"<table:table "));
3382 while (sODS.size() && sODS.find(
"<table:table ") != string::npos && sODS.find(
"</table:table>") != string::npos)
3384 vTables.push_back(sODS.substr(sODS.find(
"<table:table "), sODS.find(
"</table:table>")+14-sODS.find(
"<table:table ")));
3385 sODS.erase(sODS.find(
"<table:table "), sODS.find(
"</table:table>")+14-sODS.find(
"<table:table "));
3390 if (!vTables.size())
3396 for (
unsigned int i = 0; i < vTables.size(); i++)
3398 unsigned int nPos = 0;
3399 unsigned int nCount = 0;
3400 long long int _nCols = 0;
3407 while (vTables[i].find(
"<table:table-row ", nPos) != string::npos && vTables[i].find(
"</table:table-row>", nPos) != string::npos)
3411 nPos = vTables[i].find(
"<table:table-row ", nPos);
3412 sLine = vTables[i].substr(nPos, vTables[i].find(
"</table:table-row>", nPos)+18-nPos);
3421 vMatrix.push_back(sLine);
3427 if (vMatrix.size() <= nCount)
3429 vMatrix.push_back(
"<>");
3431 for (
long long int n = 1; n < nMaxCols; n++)
3432 vMatrix[nCount] +=
"<>";
3434 vMatrix[nCount] += sLine;
3437 vMatrix[nCount] += sLine;
3449 for (
unsigned int j = 0; j < vMatrix.size(); j++)
3455 for (
unsigned int n = 0; n < vMatrix[j].length(); n++)
3457 if (vMatrix[j][n] ==
'<')
3461 if (_nCols > nMaxCols)
3468 for (
unsigned int j = 0; j < vMatrix.size(); j++)
3474 for (
unsigned int n = 0; n < vMatrix[j].length(); n++)
3476 if (vMatrix[j][n] ==
'<')
3480 if (_nCols < nMaxCols)
3482 for (
long long int k = _nCols; k < nMaxCols; k++)
3490 for (
unsigned int i = 0; i < vMatrix.size(); i++)
3492 while (vMatrix[i].find(
' ') != string::npos)
3493 vMatrix[i].replace(vMatrix[i].find(
' '), 1,
"_");
3497 if (!vMatrix.size() || !nMaxCols)
3505 for (
unsigned int i = 0; i < vMatrix.size(); i++)
3507 bool bBreak =
false;
3509 for (
unsigned int j = 0; j < vMatrix[i].length(); j++)
3512 if (vMatrix[i][j] ==
'<' && vMatrix[i][j+1] !=
'>')
3516 if (
isNumeric(vMatrix[i].substr(j+1, vMatrix[i].find(
'>',j)-j-1)))
3523 if (j == vMatrix[i].length()-1)
3533 nRows = vMatrix.size() - nCommentLines;
3539 for (
long long int j = 0; j <
nCols; j++)
3544 unsigned int nPos = 0;
3548 for (
long long int i = 0; i < nCommentLines; i++)
3552 for (
long long int j = 0; j <
nCols; j++)
3554 nPos = vMatrix[i].find(
'<', nPos);
3555 string sEntry =
utf8parser(vMatrix[i].substr(nPos,vMatrix[i].find(
'>', nPos)+1-nPos));
3566 if (!
fileData->at(j)->m_sHeadLine.length())
3567 fileData->at(j)->m_sHeadLine = sEntry;
3568 else if (
fileData->at(j)->m_sHeadLine != sEntry)
3569 fileData->at(j)->m_sHeadLine +=
"\n" + sEntry;
3577 for (
long long int i = 0; i <
nRows; i++)
3581 for (
long long int j = 0; j <
nCols; j++)
3583 nPos = vMatrix[i+nCommentLines].find(
'<', nPos);
3584 string sEntry =
utf8parser(vMatrix[i+nCommentLines].substr(nPos,vMatrix[i+nCommentLines].find(
'>', nPos)+1-nPos));
3596 fileData->at(j)->setValue(i, sEntry);
3615 string sExpandedLine =
"";
3617 for (
unsigned int i = 0; i < sLine.length(); i++)
3619 if (sLine.substr(i, 17) ==
"<table:table-cell")
3621 if (sLine[sLine.find(
'>',i)-1] !=
'/')
3624 string sCellEntry = sLine.substr(i, sLine.find(
"</table:table-cell>", i)-i);
3628 if (sCellEntry.find(
"office:value-type=") != string::npos &&
getArgAtPos(sCellEntry, sCellEntry.find(
"office:value-type=")+18) ==
"float")
3629 sExpandedLine +=
"<" +
getArgAtPos(sCellEntry, sCellEntry.find(
"office:value=")+13) +
">";
3630 else if (sCellEntry.find(
"<text:p>") != string::npos)
3631 sExpandedLine +=
"<" + sCellEntry.substr(sCellEntry.find(
"<text:p>")+8, sCellEntry.find(
"</text:p>")-sCellEntry.find(
"<text:p>")-8) +
">";
3635 if (sLine.find(
"<table:table-cell", i+1) == string::npos && sLine.find(
"<table:covered-table-cell", i+1) == string::npos)
3638 if (sLine.substr(i, sLine.find(
'>',i)+1-i).find(
"table:number-columns-repeated=") != string::npos)
3643 string sTemp =
getArgAtPos(sLine, sLine.find(
"table:number-columns-repeated=", i)+30);
3645 if (sTemp.front() ==
'"')
3648 if (sTemp.back() ==
'"')
3653 for (
int j = 0; j <
StrToInt(sTemp); j++)
3654 sExpandedLine +=
"<>";
3657 sExpandedLine +=
"<>";
3660 else if (sLine.substr(i,25) ==
"<table:covered-table-cell")
3665 string sTemp =
getArgAtPos(sLine, sLine.find(
"table:number-columns-repeated=", i)+30);
3667 if (sTemp.front() ==
'"')
3670 if (sTemp.back() ==
'"')
3675 for (
int j = 0; j <
StrToInt(sTemp); j++)
3676 sExpandedLine +=
"<>";
3684 if (sExpandedLine.length())
3686 while (sExpandedLine.substr(sExpandedLine.length()-2) ==
"<>")
3688 sExpandedLine.erase(sExpandedLine.length()-2);
3690 if (!sExpandedLine.length() || sExpandedLine.length() < 2)
3695 return sExpandedLine;
3728 unsigned int nSheets = 0;
3729 long long int nExcelLines = 0;
3730 long long int nExcelCols = 0;
3731 long long int nOffset = 0;
3732 long long int nCommentLines = 0;
3733 vector<long long int> vCommentLines;
3734 bool bBreakSignal =
false;
3753 for (
unsigned int n = 0; n < nSheets; n++)
3756 bBreakSignal =
false;
3759 for (
unsigned int i = 0; i < _sheet->
GetTotalRows(); i++)
3761 for (
unsigned int j = 0; j < _sheet->
GetTotalCols(); j++)
3769 bBreakSignal =
true;
3780 vCommentLines.push_back(nCommentLines != 0);
3783 if (nExcelLines < _sheet->GetTotalRows()-(nCommentLines != 0))
3784 nExcelLines = _sheet->
GetTotalRows()-(nCommentLines != 0);
3793 nRows = nExcelLines;
3799 for (
long long int j = 0; j <
nCols; j++)
3806 for (
unsigned int n = 0; n < nSheets; n++)
3813 for (
long long int i = 0; i < vCommentLines[n]; i++)
3815 if (i >= nExcelLines)
3818 for (
long long int j = 0; j < nExcelCols; j++)
3820 if (j+nOffset >=
nCols)
3823 _cell = _sheet->
Cell(i,j);
3834 while (sEntry.find((
char)13) != string::npos)
3835 sEntry.replace(sEntry.find((
char)13), 1,
"\n");
3839 if (!
fileData->at(j+nOffset)->m_sHeadLine.length())
3840 fileData->at(j+nOffset)->m_sHeadLine = sEntry;
3841 else if (
fileData->at(j+nOffset)->m_sHeadLine != sEntry)
3842 fileData->at(j+nOffset)->m_sHeadLine +=
"\n" + sEntry;
3846 nOffset += nExcelCols;
3855 for (
unsigned int n = 0; n < nSheets; n++)
3861 for (
long long int i = vCommentLines[n]; i < nExcelLines; i++)
3863 if (i - vCommentLines[n] >=
nRows)
3866 for (
long long int j = 0; j < nExcelCols; j++)
3871 _cell = _sheet->
Cell(i,j);
3875 switch (_cell->
Type())
3878 fileData->at(j+nOffset)->setValue(i-vCommentLines[n],
"");
3893 fileData->at(j+nOffset)->setValue(i-vCommentLines[n],
"");
3898 nOffset += nExcelCols;
3930 for (
long long int j = 0; j <
nCols; j++)
3933 _cell = _sheet->
Cell(0u, j);
3936 sHeadLine =
fileData->at(j)->m_sHeadLine;
3939 while (sHeadLine.find(
'\n') != string::npos)
3940 sHeadLine.replace(sHeadLine.find(
'\n'), 2, 1, (
char)10);
3947 for (
long long int i = 0; i <
nRows; i++)
3949 for (
long long int j = 0; j <
nCols; j++)
3952 _cell = _sheet->
Cell(1 + i, j);
4001 unsigned int nSheets = 0;
4002 long long int nExcelLines = 0;
4003 long long int nExcelCols = 0;
4004 long long int nOffset = 0;
4005 int nLine = 0, nCol = 0;
4006 int nLinemin = 0, nLinemax = 0;
4007 int nColmin = 0, nColmax = 0;
4008 bool bBreakSignal =
false;
4010 vector<long long int> vCommentLines;
4012 string sSheetContent;
4013 string sStringsContent;
4014 string sCellLocation;
4028 if (!sEntry.length())
4034 _workbook.
Parse(sEntry.c_str());
4057 for (
unsigned int i = 0; i < nSheets; i++)
4064 if (!sSheetContent.length())
4069 _sheet.
Parse(sSheetContent.c_str());
4076 sCellLocation = _element->
Attribute(
"ref");
4077 int nLinemin = 0, nLinemax = 0;
4078 int nColmin = 0, nColmax = 0;
4081 evalIndices(sCellLocation.substr(0, sCellLocation.find(
':')), nLinemin, nColmin);
4082 evalIndices(sCellLocation.substr(sCellLocation.find(
':') + 1), nLinemax, nColmax);
4084 vCommentLines.push_back(0);
4106 if (_element->
Attribute(
"t") !=
string(
"s"))
4108 bBreakSignal =
true;
4114 bBreakSignal =
true;
4127 bBreakSignal =
false;
4132 if (nExcelLines < nLinemax-nLinemin+1-vCommentLines[i])
4133 nExcelLines = nLinemax-nLinemin+1-vCommentLines[i];
4137 nExcelCols += nColmax-nColmin+1;
4141 nRows = nExcelLines;
4148 for (
long long int j = 0; j <
nCols; j++)
4159 _strings.
Parse(sStringsContent.c_str());
4162 for (
unsigned int i = 0; i < nSheets; i++)
4167 _sheet.
Parse(sSheetContent.c_str());
4179 sCellLocation = _element->
Attribute(
"ref");
4180 evalIndices(sCellLocation.substr(0, sCellLocation.find(
':')), nLinemin, nColmin);
4181 evalIndices(sCellLocation.substr(sCellLocation.find(
':')+1), nLinemax, nColmax);
4199 sCellLocation = _element->
Attribute(
"r");
4204 if (nCol+nOffset >=
nCols || nLine-vCommentLines[i] >=
nRows)
4212 if (_element->
Attribute(
"t") ==
string(
"s"))
4219 for (
int k = 1; k <= nPos; k++)
4232 if (sEntry.length())
4234 if (nLine - vCommentLines[i] < 0)
4236 if (!
fileData->at(nCol+nOffset)->m_sHeadLine.length())
4237 fileData->at(nCol+nOffset)->m_sHeadLine = sEntry;
4238 else if (
fileData->at(nCol+nOffset)->m_sHeadLine != sEntry)
4239 fileData->at(nCol+nOffset)->m_sHeadLine +=
"\n" + sEntry;
4242 fileData->at(nCol+nOffset)->setValue(nLine-vCommentLines[i], sEntry);
4257 nOffset += nColmax-nColmin+1;
4277 for (
size_t i = 0; i < sIndices.length(); i++)
4282 if (isdigit(sIndices[i]))
4285 nLine =
StrToInt(sIndices.substr(i))-1;
4291 nCol = (sIndices[0]-
'A'+1)*26+sIndices[1]-
'A';
4293 nCol = sIndices[0]-
'A';
4344 void* vWaveDataPtr =
nullptr;
4345 long long int nFirstCol = 0;
4347 double dScalingFactorA[
MAXDIMS];
4348 double dScalingFactorB[
MAXDIMS];
4349 bool bReadComplexData =
false;
4350 int nSliceCounter = 0;
4351 float* fData =
nullptr;
4352 double* dData =
nullptr;
4353 int8_t* n8_tData =
nullptr;
4354 int16_t* n16_tData =
nullptr;
4355 int32_t* n32_tData =
nullptr;
4356 char* cName =
nullptr;
4364 if (
ReadWave(_cp_file_ref, &nType, &nPnts, nDim, dScalingFactorA, dScalingFactorB, &vWaveDataPtr, &cName))
4368 if (vWaveDataPtr != NULL)
4376 bReadComplexData =
true;
4381 fData = (
float*)vWaveDataPtr;
4383 dData = (
double*)vWaveDataPtr;
4384 else if (nType &
NT_I8)
4385 n8_tData = (int8_t*)vWaveDataPtr;
4387 n16_tData = (int16_t*)vWaveDataPtr;
4389 n32_tData = (int32_t*)vWaveDataPtr;
4394 if (vWaveDataPtr !=
nullptr)
4415 if (vWaveDataPtr !=
nullptr)
4429 else if (nDim[1] && (!nDim[2] || nDim[2] == 1))
4434 if (nDim[1] > nDim[0])
4437 else if (nDim[1] && nDim[2] && (!nDim[3] || nDim[3] == 1))
4450 for (
long long int j = 0; j <
nCols; j++)
4457 for (
long long int j = 0; j < nFirstCol; j++)
4459 fileData->at(j)->m_sHeadLine = cName + string(
"_[")+(char)(
'x'+j)+string(
"]");
4461 for (
long long int i = 0; i < nDim[j]; i++)
4463 fileData->at(j)->setValue(i, dScalingFactorA[j]*(
double)i + dScalingFactorB[j]);
4469 for (
long long int j = 0; j <
nCols-nFirstCol; j++)
4475 nSliceCounter += nDim[1];
4478 nSliceCounter = j/nDim[2];
4485 if (
nCols == 2 && !j)
4486 fileData->at(1)->m_sHeadLine = cName + string(
"_[y]");
4488 fileData->at(j+nFirstCol)->m_sHeadLine = cName + string(
"_["+
toString(j+1)+
"]");
4494 long long int nInsertion = 0;
4496 for (
long long int i = 0; i < (nDim[0]+bReadComplexData*nDim[0]); i++)
4500 if (bReadComplexData)
4501 fileData->at(nSliceCounter+nFirstCol)->setValue(nInsertion,
mu::value_type(dData[i+j*2*nDim[0]], dData[i+1+j*2*nDim[0]]));
4503 fileData->at(nSliceCounter+nFirstCol)->setValue(nInsertion, dData[i+j*(nDim[0])]);
4507 if (bReadComplexData)
4508 fileData->at(nSliceCounter+nFirstCol)->setValue(nInsertion,
mu::value_type(fData[i+j*2*nDim[0]], fData[i+1+j*2*nDim[0]]));
4510 fileData->at(nSliceCounter+nFirstCol)->setValue(nInsertion, (
double)fData[i+j*(nDim[0])]);
4514 if (bReadComplexData)
4515 fileData->at(nSliceCounter+nFirstCol)->setValue(nInsertion,
mu::value_type(n8_tData[i+j*2*nDim[0]], n8_tData[i+1+j*2*nDim[0]]));
4517 fileData->at(nSliceCounter+nFirstCol)->setValue(nInsertion, (
double)n8_tData[i+j*(nDim[0])]);
4522 if (bReadComplexData)
4523 fileData->at(nSliceCounter+nFirstCol)->setValue(nInsertion,
mu::value_type(n16_tData[i+j*2*nDim[0]], n16_tData[i+1+j*2*nDim[0]]));
4525 fileData->at(nSliceCounter+nFirstCol)->setValue(nInsertion, (
double)n16_tData[i+j*(nDim[0])]);
4529 if (bReadComplexData)
4530 fileData->at(nSliceCounter+nFirstCol)->setValue(nInsertion,
mu::value_type(n32_tData[i+j*2*nDim[0]], n32_tData[i+1+j*2*nDim[0]]));
4532 fileData->at(nSliceCounter+nFirstCol)->setValue(nInsertion, (
double)n32_tData[i+j*(nDim[0])]);
4536 i += bReadComplexData;
4544 if (vWaveDataPtr !=
nullptr)
4607 ZygoLib::DatFile zygofile(
sFileName,
false);
4608 std::vector<ZygoLib::InterferogramData> fileContent;
4613 fileContent = zygofile.read();
4622 for (
const ZygoLib::InterferogramData& layer : fileContent)
4624 if (
std::max(layer.header.cn_height, layer.header.cn_width) >
nRows)
4625 nRows =
std::max(layer.header.cn_height, layer.header.cn_width);
4627 nCols += 2+layer.header.cn_height;
4639 for (
long long int j = 0; j <
nCols; j++)
4644 uint16_t colOffset = 0;
4647 for (
const ZygoLib::InterferogramData& layer : fileContent)
4649 fileData->at(colOffset)->m_sHeadLine =
"x";
4650 fileData->at(colOffset+1)->m_sHeadLine =
"y";
4653 for (uint16_t i = 0; i < layer.header.cn_width; i++)
4655 fileData->at(colOffset)->setValue(i, i * layer.header.camera_res);
4659 for (uint16_t j = 0; j < layer.header.cn_height; j++)
4661 fileData->at(colOffset+1)->setValue(j, j * layer.header.camera_res);
4665 for (uint16_t i = 0; i < layer.header.cn_width; i++)
4667 for (uint16_t j = 0; j < layer.header.cn_height; j++)
4670 fileData->at(j+colOffset+2)->m_sHeadLine =
"z(x(:),y(" +
toString(j+1) +
"))";
4672 fileData->at(j+colOffset+2)->setValue(i, layer.phaseMatrix[j][i]);
4677 colOffset += 2+layer.header.cn_height;
const std::string sVersion
int ReadWave(CP_FILE_REF fr, int *typePtr, long *npntsPtr, long *ndimptr, double *sfa, double *sfb, void **waveDataPtrPtr, char **name)
std::string toLowerCase(const std::string &)
Converts uppercase to lowercase letters.
A table column containing categorical values.
A table column containing numerical values formatted as dates and times.
This class extends the std::vector for endlessness.
This class implements the basic input/ output file system and provides functionalities to work with f...
std::vector< std::string > getFileParts(const std::string &sFilePath) const
This member function separates all path parts into single strings: the drive letter,...
void initializeFromKernel()
Member function to remote-initialize the class from the kernel. Cannot be used during kernel start-up...
This class handles the internal language system and returns the language strings of the selected lang...
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 ...
A table column containing logical values.
CacheFile(const std::string &filename)
void readCacheHeader()
This member function will read the cache file header and ensure that the version of the file is not n...
void reset()
This member function will reset the string information and the internal storage. This is used before ...
void writeSome()
This member function will write the current contents in the internal storage to the target file....
std::vector< size_t > vFileIndex
void readSome()
This member function will read the next table, which is availale in the cache file,...
void writeCacheHeader()
This member function will write the standard cache file header to the cache file.
virtual ~CacheFile()
This destructor will write the offsets for the different tables to the file before the file stream wi...
This class resembles the CASSYLab *.labx file format, which is based upon XML. Only reading from this...
void readFile()
This member function will read the contents of the associated LABX file to the internal storage.
CassyLabx(const std::string &filename)
double extractValueFromTag(const std::string &sTag)
This simple member function extracts the numerical value of the XML tag string.
This class resembles a comma separated value file format (*.csv). The algorithm may detect the separa...
char findSeparator(const std::vector< std::string > &vTextData)
This member function determines the separator character used for the current file name....
virtual ~CommaSeparatedValues()
void readFile()
This member function is used to read the target file to memory.
void writeFile()
This member function is used to write the contents in the internal storage to the target file.
void countColumns(const std::vector< std::string > &vTextData, char &cSep)
This member function determines the number of columns available in the current file and alters the se...
CommaSeparatedValues(const std::string &filename)
Template class representing a generic file. This class may be specified for the main data type contai...
void writeStringField(const std::string &sString)
This method may be used to write a string to file in binary mode.
unsigned short nPrecFields
void writeNumBlock(T *data, long long int size)
This method template may be used to write a block of data of the selected type to the file in binary ...
void writeNumField(T num)
This method template can be used to write a numeric value to file in binary mode.
std::string * readStringBlock(long long int &size)
This method can be used for reading a block of string data to memory in binary mode.
void writeStringBlock(std::string *data, long long int size)
This method may be used to write a block of strings into the file in binary mode.
std::string getTableName()
Returns the table name referenced in the file. Will default to the file name with non-alnum character...
bool isNumeric(const std::string &sString)
This method may be used to determine, whether a string contains only numeric data.
size_t tellg()
Wrapper for fstream::tellg()
size_t tellp()
Wrapper for fstream::tellp()
void seekp(size_t pos)
Wrapper for fstream::seekp() with start from the beginning of the stream.
void copyArray(T *from, T *to, long long int nElements)
This method template may be used to copy arrays of data of the selected type. Both source and target ...
std::pair< size_t, size_t > calculateCellExtents(const std::string &sContents)
This method calculates the extents of the passed string, if it is used as a table column headlines....
std::string getZipFileItem(const std::string &filename)
This method may be used to get the contents of an embedded file in a zipfile and return the contents ...
void replaceTabSign(std::string &_sToReplace, bool bAddPlaceholders=false)
This method replaces tabulator characters with whitespaces to simplify the column determination (the ...
std::string getLineFromHead(long long int nCol, size_t nLineNumber)
This method gets the selected line number from the table column headline in the selected column....
void clearStorage()
This method cleares the internal storage. This method is called by the destructor automatically.
bool is_open()
Wrapper for fstream::is_open()
TableColumnArray * fileData
std::vector< std::string > tokenize(std::string sString, const std::string &sSeparators, bool skipEmptyTokens=false)
This method may be used to separater a line into multiple tokens using a set of separator characters....
std::string readStringField()
This mehtod can be used to read a string field from the file in binary mode.
void open(std::ios::openmode mode)
This method has to be used to open the target file in stream mode. If the file cannot be opened,...
void createStorage()
This method prepares the internal storage, so that it may contain the read data. This method is only ...
void assign(const GenericFile &file)
This method is used by the assignment operator and the copy constructor to copy the contents of the p...
std::vector< std::string > readTextFile(bool stripEmptyLines)
This method may be used to read the file in text mode and to obtain the data as a vector.
void seekg(size_t pos)
Wrapper for fstream::seekg() with start from the beginning of the stream.
void stripTrailingSpaces(std::string &_sToStrip)
This method strips trailing spaces from the passed string.
This class resembles an Igor binary wave file format (*.ibw). The data is read by the WaveMetrics imp...
IgorBinaryWave & operator=(const IgorBinaryWave &file)
This is an overload for the assignment operator of the GenericFile class.
void readFile()
This member function is used to read the contents of the IBW file into the internal storage....
virtual ~IgorBinaryWave()
IgorBinaryWave(const std::string &filename)
This class resembles a JCAMP-DX file format (*.jcm, *.jdx, *.dx). The data in this format may be hash...
size_t readTable(std::vector< std::string > &vFileContents, size_t nTableStart, MetaData)
Reads a single table from the currently opened JCAMP-DX file.
std::vector< double > parseLine(const std::string &sLine)
This member function parses the current data line into numerical values by decoding the JCAMP-DX enco...
void readFile()
This member function is used to read the conents of the JCAMP-DX file to the internal storage.
void parseLabel(std::string &sLine)
This member function parses JCAMP-DX labels by removing whitespaces, minus characters and underscores...
JcampDX(const std::string &filename)
This class resembles a LaTeX table. This class formats the data into this format using some heuristic...
LaTeXTable(const std::string &filename)
std::string replaceNonASCII(const std::string &sText)
This member function replaces all non- ASCII characters into their corresponding LaTeX entities.
std::string formatNumber(const mu::value_type &number)
This member function formats a complex as LaTeX number string.
void writeFile()
This member function is used to write the contents of the internal storage to the file.
void writeHeader()
This member function writes the legal header to the file.
void writeTableHeads()
This member function writes the table column heads to the file. The number of lines needed for the he...
size_t countHeadLines()
This member function calculates the number of lines needed for the complete table column heads.
This class resembles the binary NumeRe data file format. The data is red and written in binary mode u...
void writeDummyHeader()
This member function will write the dummy header, which is readable in older versions of NumeRe....
std::string getVersionString()
This simple member function returns the version string associated with the current file type.
const short fileSpecVersionMinor
NumeReDataFile(const std::string &filename)
void readColumnV4(TblColPtr &col)
Reads a single column from file in v4 format.
void * readGenericField(std::string &type, long long int &size)
This member function will read a generic field from the header (the three fields, which can be used i...
void writeHeader()
This member function writest the new standard header for NDAT files. It includes a dummy section,...
void skipDummyHeader()
This function jumps over the dummy section in the new file format, because it does not conatin any va...
void readFile()
This member function will read the contents of the target file.
void deleteGenericData(void *data, const std::string &type)
This member function will delete the data array obtained from the generic fields but convert them int...
const short fileSpecVersionMajor
virtual ~NumeReDataFile()
void readLegacyFormat()
This member function reads the data section of the target file in legacy format. The function readHea...
void writeFile()
This member function will write the data in the internal storage into the target file.
void writeColumn(const TblColPtr &col)
Writes a single column to the file.
void readHeader()
This member function will read the header in the selected file. It will automatically detect,...
void readColumn(TblColPtr &col)
Reads a single column from file.
NumeReDataFile & operator=(NumeReDataFile &file)
This member function is an overload for the assignment operator. It extends the already available ass...
This class resembles an OpenDocument spreadsheet (*.ods), which is based upon a zipped XML file....
std::string expandLine(const std::string &sLine)
This member function is used by the readFile() member function to expand the XML- based table row str...
void readFile()
This member function is used to read the targed file into the internal storage. ODS is a ZIP file con...
OpenDocumentSpreadSheet(const std::string &filename)
virtual ~OpenDocumentSpreadSheet()
This class resembles an arbitrary text data file, which is formatted in a table-like manner....
void writeTableHeads(const std::vector< size_t > &vColumnWidth, size_t nNumberOfLines)
This member function is used to write the table heads into the target file.
void readFile()
This method reads the data in the referenced text file to memory.
TextDataFile(const std::string &filename)
void writeHeader()
This member function writes the header lines or the text files.
void writeTableContents(const std::vector< size_t > &vColumnWidth)
This member function is used to write the data in memory to the target text file.
std::vector< size_t > calculateColumnWidths(size_t &nNumberOfLines)
This member function calculates the widths of the columns and also determines the number of lines nee...
void addSeparator(const std::vector< size_t > &vColumnWidth)
This member function draws a separator based upon the overall width of the columns.
void writeFile()
This method writes the data in memory to the referenced text file.
void decodeTableHeads(std::vector< std::string > &vFileContents, long long int nComment)
This member function decodes the table heads in the text file and stores them in memory.
This class resembles an Excel (97) workbook (*.xls), which is composed out of a compound file....
virtual ~XLSSpreadSheet()
void writeFile()
This member function is used to write the data in the internal storage to the target XLS spreadsheet.
XLSSpreadSheet(const std::string &filename)
void readFile()
This member function is used to read the data from the XLS spreadsheet ino the internal storage.
This class resembles an Excel (2003) spreadsheet (*.xlsx), which is based upon a zipped XML file....
XLSXSpreadSheet(const std::string &filename)
virtual ~XLSXSpreadSheet()
void evalIndices(const std::string &sIndices, int &nLine, int &nCol)
This member function converts the usual Excel indices into numerical ones.
void readFile()
This member function is used to read the data from the XLSX spreadsheet into the internal storage....
This class implements a Zygo MetroPro binary dat file. The data is read by accessing the ZygoLib.
void readFile()
This member function is used to read the contents of the Zygo Dat file into the internal storage....
ZygoDat(const std::string &filename)
ZygoDat & operator=(const ZygoDat &file)
This is an overload for the assignment operator of the GenericFile class.
static void issueWarning(std::string sWarningMessage)
This static function may be used to issue a warning to the user. The warning will be printed by the t...
A table column containing only strings as values.
Common exception class for all exceptions thrown in NumeRe.
@ COL_COUNTS_DOESNT_MATCH
INSERT HERE.
@ DATAFILE_NOT_EXIST
INSERT HERE.
@ INSUFFICIENT_NUMERE_VERSION
static size_t invalid_position
A table column containing only numerical values.
This class abstracts all the index logics, i.e. the logical differences between single indices and in...
void SetDouble(double val)
Set content of current Excel cell to a double.
int Type() const
Get type of value stored in current Excel cell. Returns one of the above enums.
const char * GetString() const
Get an ANSI string. Returns 0 if cell does not contain an ANSI string.
void EraseContents()
Erase the content of current Excel cell. Set type to UNDEFINED.
const wchar_t * GetWString() const
Get an Unicode string. Returns 0 if cell does not contain an Unicode string.
double GetDouble() const
Get a double value. Returns 0.0 if cell does not contain a double.
int GetInteger() const
Get an integer value. Returns 0 if cell does not contain an integer.
void SetString(const char *str)
Set content of current Excel cell to an ANSI string.
void New(int sheets=3)
Create a new Excel workbook with a given number of spreadsheets (Minimum 1).
BasicExcelWorksheet * GetWorksheet(size_t sheetIndex)
Get a pointer to an Excel worksheet at the given index. Index starts from 0. Returns 0 if index is in...
size_t GetTotalWorkSheets()
Total number of Excel worksheets in current Excel workbook.
bool Load(const char *filename)
Load an Excel workbook from a file.
bool SaveAs(const char *filename)
Save current Excel workbook to a file.
bool RenameWorksheet(size_t sheetIndex, const char *to)
Rename an Excel worksheet at the given index to the given ANSI name. Index starts from 0....
size_t GetTotalCols()
Total number of columns in current Excel worksheet.
BasicExcelCell * Cell(size_t row, size_t col)
Return a pointer to an Excel cell. row and col starts from 0. Returns 0 if row exceeds 65535 or col e...
size_t GetTotalRows()
Total number of rows in current Excel worksheet.
XMLError Parse(const char *xml, size_t nBytes=static_cast< size_t >(-1))
XMLError ErrorID() const
Return the errorID.
const char * GetText() const
const char * Attribute(const char *name, const char *value=0) const
XMLError QueryIntText(int *ival) const
const char * Value() const
virtual XMLText * ToText()
Safely cast to Text, or null.
const XMLElement * NextSiblingElement(const char *name=0) const
Get the next (right) sibling element of this node, with an optionally supplied name.
const XMLElement * FirstChildElement(const char *name=0) const
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
const XMLNode * NextSibling() const
Get the next (right) sibling node of this node.
#define DEFAULT_PRECISION
static const char MONTH[]
GenericFile * getFileByType(const string &filename)
This function determines the correct class to be used for the filename passed to this function....
CONSTCD11 std::enable_if<!std::chrono::treat_as_floating_point< T >::value, T >::type trunc(T t) NOEXCEPT
CONSTCD11 std::chrono::duration< Rep, Period > abs(std::chrono::duration< Rep, Period > d)
MUP_BASETYPE value_type
The numeric datatype used by the parser.
CONSTDATA solar_hijri::month sha
void StripSpaces(std::string &)
Removes leading and trailing white spaces and tabulator characters.
int StrToInt(const std::string &)
Converts a string into an integer.
static std::string getDefaultColumnHead(size_t colNo)
Creates a default column headline for a column, which can be used without an instance of this class.
std::string toString(int)
Converts an integer to a string without the Settings bloat.
std::unique_ptr< TableColumn > TblColPtr
Typedef for simplifying the usage of a smart pointer in combination with a TableColumn instance.
std::vector< TblColPtr > TableColumnArray
This typedef represents the actual table, which is implemented using a std::vector.