NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
file.hpp
Go to the documentation of this file.
1/*****************************************************************************
2 NumeRe: Framework fuer Numerische Rechnungen
3 Copyright (C) 2019 Erik Haenel et al.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17******************************************************************************/
18
19#ifndef NUMERE_FILE_HPP
20#define NUMERE_FILE_HPP
21
22#include <string>
23#include <fstream>
24#include <cmath>
25#include <vector>
26#include <utility>
27
28#include "../utils/zip++.hpp"
29#include "../utils/stringtools.hpp"
30#include "../ui/error.hpp"
31#include "../datamanagement/tablecolumn.hpp"
32#include "filesystem.hpp"
33
34namespace NumeRe
35{
41 {
42 std::string sFileExtension;
43 std::string sFileName;
44 std::string sTableName;
45 std::string sComment;
46 long long int nRows;
47 long long int nCols;
48 long int versionMajor;
49 long int versionMinor;
50 long int versionBuild;
52 __time64_t timeStamp;
53
55 };
56
57
67 class GenericFile : public FileSystem
68 {
69 protected:
70 std::fstream fFileStream;
71 std::string sFileExtension;
72 std::string sFileName;
73 std::string sTableName;
74 std::string sComment;
75 long long int nRows;
76 long long int nCols;
77 unsigned short nPrecFields;
78
79 // Flag for using external data, i.e. data, which won't be deleted
80 // by this class upon calling "clearStorage()" or the destructor
82 std::ios::openmode openMode;
83
84 // The main data table
86
96 void open(std::ios::openmode mode)
97 {
98 if (fFileStream.is_open())
99 fFileStream.close();
100
101 fFileStream.open(sFileName.c_str(), mode);
102
103 if (!fFileStream.good())
105
106 openMode = mode;
107 }
108
117 void stripTrailingSpaces(std::string& _sToStrip)
118 {
119 if (_sToStrip.find_first_not_of(" \t") != std::string::npos)
120 _sToStrip.erase(_sToStrip.find_last_not_of(" \t")+1);
121 }
122
132 void replaceDecimalSign(std::string& _sToReplace)
133 {
134 for (size_t i = 0; i < _sToReplace.length(); i++)
135 {
136 if (_sToReplace[i] == ',')
137 _sToReplace[i] = '.';
138 }
139 }
140
157 void replaceTabSign(std::string& _sToReplace, bool bAddPlaceholders = false)
158 {
159 bool bKeepColumns = false;
160
161 // Determine, if columns shall be kept (automatic heuristics)
162 if (!bAddPlaceholders && _sToReplace.find(' ') == std::string::npos)
163 {
164 bKeepColumns = true;
165
166 if (_sToReplace[0] == '\t')
167 _sToReplace.insert(0, "---");
168 }
169
170 for (size_t i = 0; i < _sToReplace.length(); i++)
171 {
172 if (_sToReplace[i] == '\t')
173 {
174 _sToReplace.replace(i, 1, " ");
175
176 // Shall "empty cells" be added?
177 if (bAddPlaceholders)
178 {
179 // Insert underscores as empty cells
180 if (!i)
181 _sToReplace.insert(0, 1, '_');
182 else if (_sToReplace[i-1] == ' ')
183 _sToReplace.insert(i, 1, '_');
184
185 if (i+2 == _sToReplace.length())
186 _sToReplace += "_";
187 }
188
189 // Shall empty cells be kept (determined by heuristic)
190 if (bKeepColumns && (i+2 == _sToReplace.length() || _sToReplace[i+2] == '\t'))
191 _sToReplace.insert(i + 2, "---");
192 }
193 }
194
195 // Transform single whitespaces into special characters,
196 // which will hide them from the tokenizer. Do this only,
197 // if there are also locations with multiple whitespaces
198 if (bAddPlaceholders && _sToReplace.find(" ") != std::string::npos)
199 {
200 for (size_t i = 1+(_sToReplace.front() == '#'); i < _sToReplace.length()-1; i++)
201 {
202 if (_sToReplace[i] == ' ' && _sToReplace[i-1] != ' ' && _sToReplace[i+1] != ' ')
203 _sToReplace[i] = '\1';
204 }
205 }
206 }
207
220 std::pair<size_t, size_t> calculateCellExtents(const std::string& sContents)
221 {
222 // Prepare the std::pair<> to contain the extents of the cell.
223 // (One line is the minimal value)
224 std::pair<size_t, size_t> pCellExtents(0u, 1u);
225 size_t nLastLineBreak = 0;
226
227 // Search for linebreak characters
228 for (size_t i = 0; i < sContents.length(); i++)
229 {
230 // Linebreak character found?
231 if (sContents[i] == '\n')
232 {
233 // Increment the number of lines
234 pCellExtents.second++;
235
236 // Use the maximal number of characters per line
237 // as the first column
238 if (i - nLastLineBreak > pCellExtents.first)
239 pCellExtents.first = i - nLastLineBreak;
240
241 nLastLineBreak = i;
242 }
243 /*else if (sContents.substr(i, 2) == "\\n")
244 {
245 // Increment the number of lines
246 pCellExtents.second++;
247
248 // Use the maximal number of characters per line
249 // as the first column
250 if (i - nLastLineBreak > pCellExtents.first)
251 pCellExtents.first = i - nLastLineBreak;
252
253 nLastLineBreak = i+1;
254 }*/
255 }
256
257 // Examine the last part of the string, which won't be
258 // detected by the for loop
259 if (sContents.length() - nLastLineBreak > pCellExtents.first)
260 pCellExtents.first = sContents.length() - nLastLineBreak;
261
262 return pCellExtents;
263 }
264
277 std::string getLineFromHead(long long int nCol, size_t nLineNumber)
278 {
279 size_t nLastLineBreak = 0u;
280
281 if (!fileData->at(nCol))
282 {
283 if (!nLineNumber)
285
286 return " ";
287 }
288
289 std::string sHeadLine = fileData->at(nCol)->m_sHeadLine;
290
291 // Search the selected part
292 for (size_t i = 0; i < sHeadLine.length(); i++)
293 {
294 // Linebreak character found?
295 if (sHeadLine[i] == '\n')
296 {
297 // If this is the correct line number, return
298 // the corresponding substring
299 if (!nLineNumber)
300 return sHeadLine.substr(nLastLineBreak, i - nLastLineBreak);
301
302 // Decrement the line number and store the
303 // position of the current line break
304 nLineNumber--;
305 nLastLineBreak = i+1;
306 }
307 /*else if (sHeadLine.substr(i, 2) == "\\n")
308 {
309 // If this is the correct line number, return
310 // the corresponding substring
311 if (!nLineNumber)
312 return sHeadLine.substr(nLastLineBreak, i - nLastLineBreak);
313
314 // Decrement the line number and store the
315 // position of the current line break
316 nLineNumber--;
317 nLastLineBreak = i+2;
318 }*/
319 }
320
321 // Catch the last part of the string, which is not found by
322 // the for loop
323 if (!nLineNumber)
324 return sHeadLine.substr(nLastLineBreak);
325
326 // Not enough lines in this string, return a whitespace character
327 return " ";
328 }
329
338 template <typename T> T readNumField()
339 {
340 T num;
341 fFileStream.read((char*)&num, sizeof(T));
342 return num;
343 }
344
352 std::string readStringField()
353 {
354 // Get the length of the field
355 size_t nLength = readNumField<size_t>();
356
357 // If the length is zero, return an empty string
358 if (!nLength)
359 return "";
360
361 // Create a character buffer with the corresponding
362 // length
363 char* buffer = new char[nLength];
364
365 // Read the contents into the buffer
366 fFileStream.read(buffer, nLength);
367
368 // Copy the buffer into a string and delete the buffer
369 std::string sBuffer(buffer, nLength);
370 delete[] buffer;
371
372 return sBuffer;
373 }
374
384 std::string getZipFileItem(const std::string& filename)
385 {
386 // Create a Zipfile class object
387 Zipfile* _zip = new Zipfile();
388
389 // Open the file in ZIP mode
390 if (!_zip->open(sFileName))
391 {
392 _zip->close();
393 delete _zip;
395 }
396
397 // Obtain the contents of the embedded file
398 std::string sFileItem = _zip->getZipItem(filename);
399
400 // Close the Zip file and delete the class instance
401 _zip->close();
402 delete _zip;
403
404 return sFileItem;
405 }
406
416 template <typename T> T* readNumBlock(long long int& size)
417 {
418 // Get the number of values in the data block
419 size = readNumField<long long int>();
420
421 // If the size is zero, return a null pointer
422 if (!size)
423 return nullptr;
424
425 // Create new storage for the data
426 T* data = new T[size];
427
428 // Read the contents of the file into the created storager
429 fFileStream.read((char*)data, sizeof(T)*size);
430
431 return data;
432 }
433
444 template <typename T> T** readDataArray(long long int& rows, long long int& cols)
445 {
446 // Get the dimensions of the data block in memory
447 rows = readNumField<long long int>();
448 cols = readNumField<long long int>();
449
450 // If one of the dimensions is zero, return a null pointer
451 if (!rows || !cols)
452 return nullptr;
453
454 // Prepare a new storage object for the contained data
455 T** data = new T*[rows];
456
457 // Create the storage for the columns during reading the
458 // file and read the contents directly to memory
459 for (long long int i = 0; i < rows; i++)
460 {
461 data[i] = new T[cols];
462 fFileStream.read((char*)data[i], sizeof(T)*cols);
463 }
464
465 return data;
466 }
467
476 std::string* readStringBlock(long long int& size)
477 {
478 // Get the number of strings in the current block
479 size = readNumField<long long int>();
480
481 // If no strings are in the file, return a null pointer
482 if (!size)
483 return nullptr;
484
485 // Create an array of strings for the data in the file
486 std::string* data = new std::string[size];
487
488 // Read each string separately (because their length is
489 // most probably independent on each other)
490 for (long long int i = 0; i < size; i++)
491 {
492 data[i] = readStringField();
493 }
494
495 return data;
496 }
497
507 std::vector<std::string> readTextFile(bool stripEmptyLines)
508 {
509 std::vector<std::string> vTextFile;
510 std::string currentLine;
511
512 // Read the whole file linewise
513 while (!fFileStream.eof())
514 {
515 std::getline(fFileStream, currentLine);
516
517 // If empty lines shall be stripped, strip
518 // trailing whitespaces first
519 if (stripEmptyLines)
520 stripTrailingSpaces(currentLine);
521
522 // If empty lines shall be stripped, store
523 // only non-empty lines
524 if (!stripEmptyLines || currentLine.length())
525 vTextFile.push_back(currentLine);
526 }
527
528 return vTextFile;
529 }
530
544 std::vector<std::string> tokenize(std::string sString, const std::string& sSeparators, bool skipEmptyTokens = false)
545 {
546 std::vector<std::string> vTokens;
547
548 // As long as the string has a length
549 while (sString.length())
550 {
551 // Store the string until the first separator character
552 vTokens.push_back(sString.substr(0, sString.find_first_of(sSeparators)));
553
554 // If empty tokens shall not be stored, remove the last
555 // token again, if it is empty
556 if (skipEmptyTokens && !vTokens.back().length())
557 vTokens.pop_back();
558
559 // Erase the contents of the line including the first
560 // separator character
561 if (sString.find_first_of(sSeparators) != std::string::npos)
562 sString.erase(0, sString.find_first_of(sSeparators)+1);
563 else
564 break;
565 }
566
567 return vTokens;
568 }
569
578 template <typename T> void writeNumField(T num)
579 {
580 fFileStream.write((char*)&num, sizeof(T));
581 }
582
591 void writeStringField(const std::string& sString)
592 {
593 // Store the length of string as numeric value first
594 writeNumField<size_t>(sString.length());
595 fFileStream.write(sString.c_str(), sString.length());
596 }
597
608 template <typename T> void writeNumBlock(T* data, long long int size)
609 {
610 // Store the length of the data block first
611 writeNumField<long long int>(size);
612 fFileStream.write((char*)data, sizeof(T)*size);
613 }
614
626 template <typename T> void writeDataArray(T** data, long long int rows, long long int cols)
627 {
628 // Store the dimensions of the array first
629 writeNumField<long long int>(rows);
630 writeNumField<long long int>(cols);
631
632 // Write the contents to the file in linewise fashion
633 for (long long int i = 0; i < rows; i++)
634 fFileStream.write((char*)data[i], sizeof(T)*cols);
635 }
636
646 void writeStringBlock(std::string* data, long long int size)
647 {
648 // Store the number of fields first
649 writeNumField<long long int>(size);
650
651 // Write each field separately, because their length is
652 // independent on each other
653 for (long long int i = 0; i < size; i++)
654 {
655 writeStringField(data[i]);
656 }
657 }
658
669 {
670 if (nCols > 0 && !fileData)
671 {
673 fileData->resize(nCols);
674 }
675 else if (nRows < 0 || nCols < 0)
677 }
678
688 {
689 // Only delete the storage, if it is internal data. Do
690 // not delete the storage, if it is linked from an external
691 // source
693 {
694 fileData->clear();
695 delete fileData;
696 fileData = nullptr;
697 }
698 else
699 fileData = nullptr;
700
701 nRows = 0;
702 nCols = 0;
703 }
704
717 template <typename T> void copyDataArray(T** from, T** to, long long int rows, long long int cols)
718 {
719 if (!from || !to || !rows || !cols)
720 return;
721
722 for (long long int i = 0; i < rows; i++)
723 {
724 for (long long int j = 0; j < cols; j++)
725 to[i][j] = from[i][j];
726 }
727 }
728
740 void copyStringArray(std::string* from, std::string* to, long long int nElements)
741 {
742 if (!from || !to || !nElements)
743 return;
744
745 for (long long int i = 0; i < nElements; i++)
746 to[i] = from[i];
747 }
748
761 template <typename T> void copyArray(T* from, T* to, long long int nElements)
762 {
763 if (!from || !to || !nElements)
764 return;
765
766 for (long long int i = 0; i < nElements; i++)
767 to[i] = from[i];
768 }
769
779 bool isNumeric(const std::string& sString)
780 {
781 if (!sString.length())
782 return false;
783
784 return isConvertible(sString, CONVTYPE_VALUE);
785 }
786
796 void assign(const GenericFile& file)
797 {
798 clearStorage();
799
800 nRows = file.nRows;
801 nCols = file.nCols;
804 sFileName = file.sFileName;
806 sTableName = file.sTableName;
807 sComment = file.sComment;
808
809 // Creates only the vector but leaves the
810 // actual columns untouched
812
813 if (file.fileData && fileData)
814 {
815 for (long long int col = 0; col < nCols; col++)
816 fileData->at(col).reset(file.fileData->at(col)->copy());
817 }
818 }
819
820 public:
821 // Constructor from filename
828 GenericFile(const std::string& fileName) : FileSystem(), nRows(0), nCols(0), nPrecFields(7), useExternalData(false), fileData(nullptr)
829 {
830 // Initializes the file system from the kernel
832 sFileName = ValidFileName(fileName, "", false);
834 }
835
843 {
844 assign(file);
845 }
846
854 virtual ~GenericFile()
855 {
856 clearStorage();
857
858 if (fFileStream.is_open())
859 fFileStream.close();
860 }
861
868 bool is_open()
869 {
870 return fFileStream.is_open();
871 }
872
880 void close()
881 {
882 fFileStream.close();
883 clearStorage();
884 }
885
892 bool good()
893 {
894 return fFileStream.good();
895 }
896
903 size_t tellg()
904 {
905 return fFileStream.tellg();
906 }
907
914 size_t tellp()
915 {
916 return fFileStream.tellp();
917 }
918
927 void seekg(size_t pos)
928 {
929 fFileStream.seekg(pos, std::ios::beg);
930 }
931
940 void seekp(size_t pos)
941 {
942 fFileStream.seekp(pos, std::ios::beg);
943 }
944
951 std::string getExtension()
952 {
953 return sFileExtension;
954 }
955
962 std::string getFileName()
963 {
964 return sFileName;
965 }
966
977 std::string getTableName()
978 {
979 // Has the table name not been defined yet
980 if (!sTableName.length())
981 {
982 // Get the file name (not the whole path)
984
985 // Replace all non-alnum characters with underscores
986 for (size_t i = 0; i < sTableName.length(); i++)
987 {
988 if (sTableName[i] != '_' && !isalnum(sTableName[i]))
989 sTableName[i] = '_';
990 }
991
992 // If the first character is a digit, prepend an
993 // underscore
994 if (isdigit(sTableName.front()))
995 sTableName.insert(0, 1, '_');
996 }
997
998 return sTableName;
999 }
1000
1008 std::string getComment()
1009 {
1010 return sComment;
1011 }
1012
1021 void setComment(const std::string& comment)
1022 {
1023 sComment = comment;
1024 }
1025
1032 long long int getRows()
1033 {
1034 return nRows;
1035 }
1036
1043 long long int getCols()
1044 {
1045 return nCols;
1046 }
1047
1056 {
1057 FileHeaderInfo info;
1058
1059 info.nCols = nCols;
1060 info.nRows = nRows;
1062 info.sFileName = sFileName;
1063 info.sTableName = getTableName();
1064 info.sComment = sComment;
1065
1066 return info;
1067 }
1068
1078 virtual bool read() = 0;
1079
1089 virtual bool write() = 0;
1090
1099 {
1100 assign(file);
1101 return *this;
1102 }
1103
1114 {
1115 if (data && fileData)
1116 {
1117 for (long long int col = 0; col < nCols; col++)
1118 {
1119 if (fileData->at(col))
1120 data->at(col).reset(fileData->at(col)->copy());
1121 }
1122 }
1123 }
1124
1137 TableColumnArray* getData(long long int& rows, long long int& cols)
1138 {
1139 rows = nRows;
1140 cols = nCols;
1141
1142 return fileData;
1143 }
1144
1155 void setDimensions(long long int rows, long long int cols)
1156 {
1157 clearStorage();
1158
1159 nRows = rows;
1160 nCols = cols;
1161 }
1162
1170 void setTableName(const std::string& name)
1171 {
1172 sTableName = name;
1173 }
1174
1184 void setTextfilePrecision(unsigned short nPrecision)
1185 {
1186 nPrecFields = nPrecision;
1187 }
1188
1200 void addData(TableColumnArray* data, long long int rows, long long int cols)
1201 {
1202 if (!nRows && !nCols)
1203 {
1204 nRows = rows;
1205 nCols = cols;
1206 }
1207
1208 createStorage();
1209
1210 if (fileData && data)
1211 {
1212 for (long long int col = 0; col < nCols; col++)
1213 fileData->at(col).reset(data->at(col)->copy());
1214 }
1215 }
1216
1229 void setData(TableColumnArray* data, long long int rows, long long int cols)
1230 {
1231 useExternalData = true;
1232
1233 fileData = data;
1234 nRows = rows;
1235 nCols = cols;
1236 }
1237 };
1238
1239
1254 GenericFile* getFileByType(const std::string& filename);
1255
1256
1264 {
1265 private:
1267
1268 public:
1272 GenericFileView() : m_file(nullptr) {}
1273
1282
1291 void attach(GenericFile* _file)
1292 {
1293 m_file = _file;
1294 }
1295
1304 {
1305 return m_file;
1306 }
1307
1315 long long int getCols() const
1316 {
1317 if (m_file)
1318 return m_file->getCols();
1319
1320 return 0;
1321 }
1322
1330 long long int getRows() const
1331 {
1332 if (m_file)
1333 return m_file->getRows();
1334
1335 return 0;
1336 }
1337
1349 mu::value_type getElement(long long int row, long long int col) const
1350 {
1351 if (m_file)
1352 {
1353 if (row >= m_file->getRows() || col >= m_file->getCols())
1354 return 0;
1355
1356 // dummy variable
1357 long long int r,c;
1358 TableColumnArray* arr = m_file->getData(r,c);
1359
1360 if (arr->at(col))
1361 return arr->at(col)->getValue(row);
1362 }
1363
1364 return mu::value_type();
1365 }
1366
1377 std::string getStringElement(long long int row, long long int col) const
1378 {
1379 if (m_file)
1380 {
1381 if (row >= m_file->getRows() || col >= m_file->getCols())
1382 return 0;
1383
1384 // dummy variable
1385 long long int r,c;
1386 TableColumnArray* arr = m_file->getData(r,c);
1387
1388 if (arr->at(col))
1389 return arr->at(col)->getValueAsInternalString(row);
1390 }
1391
1392 return "";
1393 }
1394
1404 std::string getColumnHead(long long int col) const
1405 {
1406 if (m_file)
1407 {
1408 if (col >= m_file->getCols())
1409 return "";
1410
1411 // dummy variable
1412 long long int r,c;
1413 TableColumnArray* arr = m_file->getData(r,c);
1414
1415 if (arr->at(col))
1416 return arr->at(col)->m_sHeadLine;
1417 }
1418
1419 return "";
1420 }
1421 };
1422
1423
1425
1426
1434 {
1435 private:
1436 void readFile();
1437 void writeFile();
1438 void writeHeader();
1439 void writeTableHeads(const std::vector<size_t>& vColumnWidth, size_t nNumberOfLines);
1440 void writeTableContents(const std::vector<size_t>& vColumnWidth);
1441 void addSeparator(const std::vector<size_t>& vColumnWidth);
1442
1443 void decodeTableHeads(std::vector<std::string>& vFileContents, long long int nComment);
1444 std::vector<size_t> calculateColumnWidths(size_t& nNumberOfLines);
1445
1446 public:
1447 TextDataFile(const std::string& filename);
1448 virtual ~TextDataFile();
1449
1450 virtual bool read() override
1451 {
1452 readFile();
1453 return true;
1454 }
1455
1456 virtual bool write() override
1457 {
1458 writeFile();
1459 return true;
1460 }
1461 };
1462
1463
1471 {
1472 protected:
1474 __time64_t timeStamp;
1478 const short fileSpecVersionMajor = 4;
1479 const short fileSpecVersionMinor = 0;
1481 size_t checkPos;
1483
1484 void writeHeader();
1485 void writeDummyHeader();
1486 void writeFile();
1487 void writeColumn(const TblColPtr& col);
1488 void readHeader();
1489 void skipDummyHeader();
1490 void readFile();
1491 void readColumn(TblColPtr& col);
1492 void readColumnV4(TblColPtr& col);
1493 void readLegacyFormat();
1494 void* readGenericField(std::string& type, long long int& size);
1495 void deleteGenericData(void* data, const std::string& type);
1496
1497 public:
1498 NumeReDataFile(const std::string& filename);
1499 NumeReDataFile(const NumeReDataFile& file);
1500 virtual ~NumeReDataFile();
1501
1502 virtual bool read() override
1503 {
1504 readFile();
1505 return true;
1506 }
1507
1508 virtual bool write() override
1509 {
1510 writeFile();
1511 return true;
1512 }
1513
1515
1524 {
1525 open(std::ios::in | std::ios::binary);
1526 readHeader();
1527 }
1528
1535 __time64_t getTimeStamp()
1536 {
1537 return timeStamp;
1538 }
1539
1541 {
1542 FileHeaderInfo info;
1543
1544 info.nCols = nCols;
1545 info.nRows = nRows;
1547 info.sFileName = sFileName;
1548 info.sTableName = getTableName();
1549 info.sComment = sComment;
1554 info.timeStamp = timeStamp;
1555
1556 return info;
1557 }
1558
1559 std::string getVersionString();
1560 };
1561
1562
1576 {
1577 private:
1578 std::vector<size_t> vFileIndex;
1580
1581 void reset();
1582 void readSome();
1583 void writeSome();
1584
1585
1586 public:
1587 CacheFile(const std::string& filename);
1588 virtual ~CacheFile();
1589
1590 virtual bool read() override
1591 {
1592 readSome();
1593 return true;
1594 }
1595
1596 virtual bool write() override
1597 {
1598 writeSome();
1599 return true;
1600 }
1601
1602 void readCacheHeader();
1603 void writeCacheHeader();
1604
1613 {
1614 return vFileIndex.size();
1615 }
1616
1625 void setNumberOfTables(size_t nTables)
1626 {
1627 vFileIndex = std::vector<size_t>(nTables, 0u);
1628 }
1629
1638 size_t getPosition(size_t nthTable)
1639 {
1640 if (nthTable < vFileIndex.size())
1641 return vFileIndex[nthTable];
1642
1643 return -1;
1644 }
1645 };
1646
1647
1654 class CassyLabx : public GenericFile
1655 {
1656 private:
1657 void readFile();
1658 double extractValueFromTag(const std::string& sTag);
1659
1660 public:
1661 CassyLabx(const std::string& filename);
1662 virtual ~CassyLabx();
1663
1664 virtual bool read() override
1665 {
1666 readFile();
1667 return true;
1668 }
1669
1670 virtual bool write() override
1671 {
1672 // do nothing here
1673 return false;
1674 }
1675 };
1676
1677
1686 {
1687 private:
1688 void readFile();
1689 void writeFile();
1690 char findSeparator(const std::vector<std::string>& vTextData);
1691 void countColumns(const std::vector<std::string>& vTextData, char& cSep);
1692
1693 public:
1694 CommaSeparatedValues(const std::string& filename);
1695 virtual ~CommaSeparatedValues();
1696
1697 virtual bool read() override
1698 {
1699 readFile();
1700 return true;
1701 }
1702
1703 virtual bool write() override
1704 {
1705 writeFile();
1706 return true;
1707 }
1708 };
1709
1710
1720 {
1721 private:
1722 void writeFile();
1723 void writeHeader();
1724 void writeTableHeads();
1725 size_t countHeadLines();
1726 std::string replaceNonASCII(const std::string& sText);
1727 std::string formatNumber(const mu::value_type& number);
1728
1729 public:
1730 LaTeXTable(const std::string& filename);
1731 virtual ~LaTeXTable();
1732
1733 virtual bool read() override
1734 {
1735 // do nothing here
1736 return false;
1737 }
1738
1739 virtual bool write() override
1740 {
1741 writeFile();
1742 return true;
1743 }
1744 };
1745
1746
1753 class JcampDX : public GenericFile
1754 {
1755 private:
1756 struct MetaData;
1757
1758 void readFile();
1759 size_t readTable(std::vector<std::string>& vFileContents, size_t nTableStart, MetaData);
1760 void parseLabel(std::string& sLine);
1761 std::vector<double> parseLine(const std::string& sLine);
1762
1763 public:
1764 JcampDX(const std::string& filename);
1765 virtual ~JcampDX();
1766
1767 virtual bool read() override
1768 {
1769 readFile();
1770 return true;
1771 }
1772
1773 virtual bool write() override
1774 {
1775 // do nothing
1776 return false;
1777 }
1778 };
1779
1780
1789 {
1790 private:
1791 void readFile();
1792 std::string expandLine(const std::string& sLine);
1793
1794 public:
1795 OpenDocumentSpreadSheet(const std::string& filename);
1796 virtual ~OpenDocumentSpreadSheet();
1797
1798 virtual bool read() override
1799 {
1800 readFile();
1801 return true;
1802 }
1803
1804 virtual bool write() override
1805 {
1806 // do nothing
1807 return false;
1808 }
1809 };
1810
1811
1819 {
1820 private:
1821 void readFile();
1822 void writeFile();
1823
1824 public:
1825 XLSSpreadSheet(const std::string& filename);
1826 virtual ~XLSSpreadSheet();
1827
1828 virtual bool read() override
1829 {
1830 readFile();
1831 return true;
1832 }
1833
1834 virtual bool write() override
1835 {
1836 writeFile();
1837 return true;
1838 }
1839 };
1840
1841
1850 {
1851 private:
1852 void readFile();
1853 void evalIndices(const std::string& sIndices, int& nLine, int& nCol);
1854
1855 public:
1856 XLSXSpreadSheet(const std::string& filename);
1857 virtual ~XLSXSpreadSheet();
1858
1859 virtual bool read() override
1860 {
1861 readFile();
1862 return true;
1863 }
1864
1865 virtual bool write() override
1866 {
1867 // do nothing
1868 return false;
1869 }
1870 };
1871
1872
1881 {
1882 private:
1884
1885 void readFile();
1886
1887 public:
1888 IgorBinaryWave(const std::string& filename);
1889 IgorBinaryWave(const IgorBinaryWave& file);
1890 virtual ~IgorBinaryWave();
1891
1892 virtual bool read() override
1893 {
1894 readFile();
1895 return true;
1896 }
1897
1898 virtual bool write() override
1899 {
1900 // do nothing
1901 return false;
1902 }
1903
1905
1915 {
1916 bXZSlice = true;
1917 }
1918 };
1919
1920
1926 class ZygoDat : public GenericFile
1927 {
1928 private:
1929 void readFile();
1930
1931 public:
1932 ZygoDat(const std::string& filename);
1933 ZygoDat(const ZygoDat& file);
1934 virtual ~ZygoDat();
1935
1936 virtual bool read() override
1937 {
1938 readFile();
1939 return true;
1940 }
1941
1942 virtual bool write() override
1943 {
1944 return false;
1945 }
1946
1947 ZygoDat& operator=(const ZygoDat& file);
1948 };
1949}
1950
1951
1952
1953#endif // NUMERE_FILE_HPP
1954
1955
This class implements the basic input/ output file system and provides functionalities to work with f...
Definition: filesystem.hpp:92
std::vector< std::string > getFileParts(const std::string &sFilePath) const
This member function separates all path parts into single strings: the drive letter,...
Definition: filesystem.cpp:566
void initializeFromKernel()
Member function to remote-initialize the class from the kernel. Cannot be used during kernel start-up...
Definition: filesystem.cpp:750
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...
Definition: filesystem.cpp:280
This class resembles the cache file used to autosave and recover the tables in memory....
Definition: file.hpp:1576
CacheFile(const std::string &filename)
Definition: file.cpp:1630
void readCacheHeader()
This member function will read the cache file header and ensure that the version of the file is not n...
Definition: file.cpp:1732
virtual bool read() override
Pure virtual declaration of the read access method. Has to be implemented in all derived classes and ...
Definition: file.hpp:1590
void reset()
This member function will reset the string information and the internal storage. This is used before ...
Definition: file.cpp:1661
void writeSome()
This member function will write the current contents in the internal storage to the target file....
Definition: file.cpp:1704
size_t nIndexPos
Definition: file.hpp:1579
void setNumberOfTables(size_t nTables)
Sets the number of tables to be stored in the referenced cache file.
Definition: file.hpp:1625
virtual bool write() override
Pure virtual declaration of the write access method. Has to be implemented in all derived classes and...
Definition: file.hpp:1596
std::vector< size_t > vFileIndex
Definition: file.hpp:1578
size_t getPosition(size_t nthTable)
Returns the character position of the passed table index.
Definition: file.hpp:1638
void readSome()
This member function will read the next table, which is availale in the cache file,...
Definition: file.cpp:1679
void writeCacheHeader()
This member function will write the standard cache file header to the cache file.
Definition: file.cpp:1784
size_t getNumberOfTables()
Returns the number of tables stored in the referenced cache file.
Definition: file.hpp:1612
virtual ~CacheFile()
This destructor will write the offsets for the different tables to the file before the file stream wi...
Definition: file.cpp:1641
This class resembles the CASSYLab *.labx file format, which is based upon XML. Only reading from this...
Definition: file.hpp:1655
virtual bool read() override
Pure virtual declaration of the read access method. Has to be implemented in all derived classes and ...
Definition: file.hpp:1664
void readFile()
This member function will read the contents of the associated LABX file to the internal storage.
Definition: file.cpp:1835
virtual bool write() override
Pure virtual declaration of the write access method. Has to be implemented in all derived classes and...
Definition: file.hpp:1670
CassyLabx(const std::string &filename)
Definition: file.cpp:1815
virtual ~CassyLabx()
Definition: file.cpp:1821
double extractValueFromTag(const std::string &sTag)
This simple member function extracts the numerical value of the XML tag string.
Definition: file.cpp:1963
This class resembles a comma separated value file format (*.csv). The algorithm may detect the separa...
Definition: file.hpp:1686
char findSeparator(const std::vector< std::string > &vTextData)
This member function determines the separator character used for the current file name....
Definition: file.cpp:2199
virtual ~CommaSeparatedValues()
Definition: file.cpp:1979
void readFile()
This member function is used to read the target file to memory.
Definition: file.cpp:1992
void writeFile()
This member function is used to write the contents in the internal storage to the target file.
Definition: file.cpp:2147
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...
Definition: file.cpp:2284
virtual bool read() override
Pure virtual declaration of the read access method. Has to be implemented in all derived classes and ...
Definition: file.hpp:1697
virtual bool write() override
Pure virtual declaration of the write access method. Has to be implemented in all derived classes and...
Definition: file.hpp:1703
CommaSeparatedValues(const std::string &filename)
Definition: file.cpp:1973
Template class representing a generic file. This class may be specified for the main data type contai...
Definition: file.hpp:68
TableColumnArray * getData(long long int &rows, long long int &cols)
This method returns a pointer to the internal memory with read and write access. This pointer shall n...
Definition: file.hpp:1137
void writeStringField(const std::string &sString)
This method may be used to write a string to file in binary mode.
Definition: file.hpp:591
void getData(TableColumnArray *data)
This method copies the internal data to the passed memory address. The target memory must already exi...
Definition: file.hpp:1113
unsigned short nPrecFields
Definition: file.hpp:77
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 ...
Definition: file.hpp:608
void setTextfilePrecision(unsigned short nPrecision)
Set the precision, which shall be used to convert the floating point numbers into strings.
Definition: file.hpp:1184
void replaceDecimalSign(std::string &_sToReplace)
This method simply replaces commas with dots in the passed string to enable correct parsing into a do...
Definition: file.hpp:132
void writeNumField(T num)
This method template can be used to write a numeric value to file in binary mode.
Definition: file.hpp:578
T readNumField()
This method is a template fo reading a numeric field of the selected template type in binary mode.
Definition: file.hpp:338
void close()
Wrapper for fstream::close(). Will also clear the internal memory.
Definition: file.hpp:880
std::string * readStringBlock(long long int &size)
This method can be used for reading a block of string data to memory in binary mode.
Definition: file.hpp:476
virtual ~GenericFile()
Virtual destructor: we'll work with instances on the heap, therefore we'll need virtual declared dest...
Definition: file.hpp:854
void setTableName(const std::string &name)
Set the table's name.
Definition: file.hpp:1170
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.
Definition: file.hpp:646
virtual bool read()=0
Pure virtual declaration of the read access method. Has to be implemented in all derived classes and ...
std::string getTableName()
Returns the table name referenced in the file. Will default to the file name with non-alnum character...
Definition: file.hpp:977
bool isNumeric(const std::string &sString)
This method may be used to determine, whether a string contains only numeric data.
Definition: file.hpp:779
size_t tellg()
Wrapper for fstream::tellg()
Definition: file.hpp:903
size_t tellp()
Wrapper for fstream::tellp()
Definition: file.hpp:914
void writeDataArray(T **data, long long int rows, long long int cols)
This method may be used to write a two-dimensional array of data to the file in binary mode.
Definition: file.hpp:626
void seekp(size_t pos)
Wrapper for fstream::seekp() with start from the beginning of the stream.
Definition: file.hpp:940
std::string getComment()
Returns the comment stored with the referenced file.
Definition: file.hpp:1008
long long int nRows
Definition: file.hpp:75
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 ...
Definition: file.hpp:761
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....
Definition: file.hpp:220
std::string sFileName
Definition: file.hpp:72
GenericFile & operator=(const GenericFile &file)
Assignment operator definition.
Definition: file.hpp:1098
void setData(TableColumnArray *data, long long int rows, long long int cols)
This method refernces the passed external data internally. The data is not copied and must exist as l...
Definition: file.hpp:1229
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 ...
Definition: file.hpp:384
void copyDataArray(T **from, T **to, long long int rows, long long int cols)
This method may be used to copy two- dimensional arrays of data. Both source and target arrays have t...
Definition: file.hpp:717
void replaceTabSign(std::string &_sToReplace, bool bAddPlaceholders=false)
This method replaces tabulator characters with whitespaces to simplify the column determination (the ...
Definition: file.hpp:157
GenericFile(const GenericFile &file)
Copy constructor.
Definition: file.hpp:842
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....
Definition: file.hpp:277
bool good()
Wrapper for fstream::good()
Definition: file.hpp:892
std::string sTableName
Definition: file.hpp:73
void addData(TableColumnArray *data, long long int rows, long long int cols)
This method created the internal storage and copies the passed data to this storage.
Definition: file.hpp:1200
void clearStorage()
This method cleares the internal storage. This method is called by the destructor automatically.
Definition: file.hpp:687
virtual FileHeaderInfo getFileHeaderInformation()
Returns the file header information structure.
Definition: file.hpp:1055
std::fstream fFileStream
Definition: file.hpp:70
bool is_open()
Wrapper for fstream::is_open()
Definition: file.hpp:868
std::string sComment
Definition: file.hpp:74
std::ios::openmode openMode
Definition: file.hpp:82
std::string sFileExtension
Definition: file.hpp:71
TableColumnArray * fileData
Definition: file.hpp:85
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....
Definition: file.hpp:544
GenericFile(const std::string &fileName)
Constructor from filename.
Definition: file.hpp:828
long long int getRows()
Returns the number of rows.
Definition: file.hpp:1032
virtual bool write()=0
Pure virtual declaration of the write access method. Has to be implemented in all derived classes and...
void setDimensions(long long int rows, long long int cols)
Sets the dimensions of the data table, which will be used in the future. Clears the internal memory i...
Definition: file.hpp:1155
void setComment(const std::string &comment)
Sets the comment to be written to the referencedfile.
Definition: file.hpp:1021
std::string readStringField()
This mehtod can be used to read a string field from the file in binary mode.
Definition: file.hpp:352
void copyStringArray(std::string *from, std::string *to, long long int nElements)
This method may be used to copy string arrays. Both source and target arrays have to exist in advance...
Definition: file.hpp:740
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,...
Definition: file.hpp:96
T * readNumBlock(long long int &size)
This method template is for reading a block of numeric data into memory in binary mode.
Definition: file.hpp:416
std::string getFileName()
Returns the file name.
Definition: file.hpp:962
void createStorage()
This method prepares the internal storage, so that it may contain the read data. This method is only ...
Definition: file.hpp:668
long long int nCols
Definition: file.hpp:76
bool useExternalData
Definition: file.hpp:81
void assign(const GenericFile &file)
This method is used by the assignment operator and the copy constructor to copy the contents of the p...
Definition: file.hpp:796
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.
Definition: file.hpp:507
void seekg(size_t pos)
Wrapper for fstream::seekg() with start from the beginning of the stream.
Definition: file.hpp:927
T ** readDataArray(long long int &rows, long long int &cols)
This method template is for reading a whole two-dimensional array of data into memory in binary mode.
Definition: file.hpp:444
long long int getCols()
Returns the number of columns.
Definition: file.hpp:1043
std::string getExtension()
Returns the file extension.
Definition: file.hpp:951
void stripTrailingSpaces(std::string &_sToStrip)
This method strips trailing spaces from the passed string.
Definition: file.hpp:117
This class is a facet for an arbitrary GenericFile instance. It can be used to read the contents of t...
Definition: file.hpp:1264
mu::value_type getElement(long long int row, long long int col) const
Returns the value stored at the passed positions. A default constructed mu::value_type object instanc...
Definition: file.hpp:1349
GenericFile * getPtr()
Returns the internally stored GenericFile instance pointer.
Definition: file.hpp:1303
long long int getCols() const
Returns the number of columns in the internally stored GenericFile instance.
Definition: file.hpp:1315
void attach(GenericFile *_file)
Attaches a new GenericFile instance to this facet class.
Definition: file.hpp:1291
GenericFileView(GenericFile *_file)
Constructor from an available GenericFile instance.
Definition: file.hpp:1281
std::string getColumnHead(long long int col) const
Returns the column heading stored for the passed column. Returns an empty string, if the column does ...
Definition: file.hpp:1404
long long int getRows() const
Returns the number of rows in the internally stored GenericFile instance.
Definition: file.hpp:1330
std::string getStringElement(long long int row, long long int col) const
Returns the value stored at the passed positions. An empty string is returned, if the element does no...
Definition: file.hpp:1377
GenericFileView()
Default constructor.
Definition: file.hpp:1272
GenericFile * m_file
Definition: file.hpp:1266
This class resembles an Igor binary wave file format (*.ibw). The data is read by the WaveMetrics imp...
Definition: file.hpp:1881
void useXZSlicing()
Activates the XZ-slicing of the Igor binary wave, which is used to roll out 3D data in 2D slices.
Definition: file.hpp:1914
IgorBinaryWave & operator=(const IgorBinaryWave &file)
This is an overload for the assignment operator of the GenericFile class.
Definition: file.cpp:4557
void readFile()
This member function is used to read the contents of the IBW file into the internal storage....
Definition: file.cpp:4339
virtual bool read() override
Pure virtual declaration of the read access method. Has to be implemented in all derived classes and ...
Definition: file.hpp:1892
virtual ~IgorBinaryWave()
Definition: file.cpp:4324
IgorBinaryWave(const std::string &filename)
Definition: file.cpp:4305
virtual bool write() override
Pure virtual declaration of the write access method. Has to be implemented in all derived classes and...
Definition: file.hpp:1898
This class resembles a JCAMP-DX file format (*.jcm, *.jdx, *.dx). The data in this format may be hash...
Definition: file.hpp:1754
size_t readTable(std::vector< std::string > &vFileContents, size_t nTableStart, MetaData)
Reads a single table from the currently opened JCAMP-DX file.
Definition: file.cpp:2893
virtual bool read() override
Pure virtual declaration of the read access method. Has to be implemented in all derived classes and ...
Definition: file.hpp:1767
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...
Definition: file.cpp:3167
virtual ~JcampDX()
Definition: file.cpp:2669
virtual bool write() override
Pure virtual declaration of the write access method. Has to be implemented in all derived classes and...
Definition: file.hpp:1773
void readFile()
This member function is used to read the conents of the JCAMP-DX file to the internal storage.
Definition: file.cpp:2715
void parseLabel(std::string &sLine)
This member function parses JCAMP-DX labels by removing whitespaces, minus characters and underscores...
Definition: file.cpp:3128
JcampDX(const std::string &filename)
Definition: file.cpp:2663
This class resembles a LaTeX table. This class formats the data into this format using some heuristic...
Definition: file.hpp:1720
LaTeXTable(const std::string &filename)
Definition: file.cpp:2326
virtual bool read() override
Pure virtual declaration of the read access method. Has to be implemented in all derived classes and ...
Definition: file.hpp:1733
std::string replaceNonASCII(const std::string &sText)
This member function replaces all non- ASCII characters into their corresponding LaTeX entities.
Definition: file.cpp:2567
std::string formatNumber(const mu::value_type &number)
This member function formats a complex as LaTeX number string.
Definition: file.cpp:2629
virtual bool write() override
Pure virtual declaration of the write access method. Has to be implemented in all derived classes and...
Definition: file.hpp:1739
void writeFile()
This member function is used to write the contents of the internal storage to the file.
Definition: file.cpp:2346
void writeHeader()
This member function writes the legal header to the file.
Definition: file.cpp:2470
void writeTableHeads()
This member function writes the table column heads to the file. The number of lines needed for the he...
Definition: file.cpp:2500
size_t countHeadLines()
This member function calculates the number of lines needed for the complete table column heads.
Definition: file.cpp:2536
virtual ~LaTeXTable()
Definition: file.cpp:2332
This class resembles the binary NumeRe data file format. The data is red and written in binary mode u...
Definition: file.hpp:1471
void writeDummyHeader()
This member function will write the dummy header, which is readable in older versions of NumeRe....
Definition: file.cpp:920
std::string getVersionString()
This simple member function returns the version string associated with the current file type.
Definition: file.cpp:1620
const short fileSpecVersionMinor
Definition: file.hpp:1479
NumeReDataFile(const std::string &filename)
Definition: file.cpp:827
void readColumnV4(TblColPtr &col)
Reads a single column from file in v4 format.
Definition: file.cpp:1342
virtual bool read() override
Pure virtual declaration of the read access method. Has to be implemented in all derived classes and ...
Definition: file.hpp:1502
long int versionBuild
Definition: file.hpp:1477
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...
Definition: file.cpp:1503
void writeHeader()
This member function writest the new standard header for NDAT files. It includes a dummy section,...
Definition: file.cpp:871
void skipDummyHeader()
This function jumps over the dummy section in the new file format, because it does not conatin any va...
Definition: file.cpp:1169
void readFile()
This member function will read the contents of the target file.
Definition: file.cpp:1190
__time64_t getTimeStamp()
Returns the file timestamp.
Definition: file.hpp:1535
__time64_t timeStamp
Definition: file.hpp:1474
void readFileInformation()
Reads only the header of the referenced file.
Definition: file.hpp:1523
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...
Definition: file.cpp:1566
const short fileSpecVersionMajor
Definition: file.hpp:1478
virtual ~NumeReDataFile()
Definition: file.cpp:855
void readLegacyFormat()
This member function reads the data section of the target file in legacy format. The function readHea...
Definition: file.cpp:1413
void writeFile()
This member function will write the data in the internal storage into the target file.
Definition: file.cpp:942
void writeColumn(const TblColPtr &col)
Writes a single column to the file.
Definition: file.cpp:981
void readHeader()
This member function will read the header in the selected file. It will automatically detect,...
Definition: file.cpp:1060
virtual FileHeaderInfo getFileHeaderInformation() override
Returns the file header information structure.
Definition: file.hpp:1540
void readColumn(TblColPtr &col)
Reads a single column from file.
Definition: file.cpp:1278
NumeReDataFile & operator=(NumeReDataFile &file)
This member function is an overload for the assignment operator. It extends the already available ass...
Definition: file.cpp:1598
virtual bool write() override
Pure virtual declaration of the write access method. Has to be implemented in all derived classes and...
Definition: file.hpp:1508
long int versionMajor
Definition: file.hpp:1475
long int versionMinor
Definition: file.hpp:1476
This class resembles an OpenDocument spreadsheet (*.ods), which is based upon a zipped XML file....
Definition: file.hpp:1789
virtual bool write() override
Pure virtual declaration of the write access method. Has to be implemented in all derived classes and...
Definition: file.hpp:1804
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...
Definition: file.cpp:3613
virtual bool read() override
Pure virtual declaration of the read access method. Has to be implemented in all derived classes and ...
Definition: file.hpp:1798
void readFile()
This member function is used to read the targed file into the internal storage. ODS is a ZIP file con...
Definition: file.cpp:3350
OpenDocumentSpreadSheet(const std::string &filename)
Definition: file.cpp:3329
This class resembles an arbitrary text data file, which is formatted in a table-like manner....
Definition: file.hpp:1434
virtual bool write() override
Pure virtual declaration of the write access method. Has to be implemented in all derived classes and...
Definition: file.hpp:1456
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.
Definition: file.cpp:293
void readFile()
This method reads the data in the referenced text file to memory.
Definition: file.cpp:115
virtual ~TextDataFile()
Definition: file.cpp:102
virtual bool read() override
Pure virtual declaration of the read access method. Has to be implemented in all derived classes and ...
Definition: file.hpp:1450
TextDataFile(const std::string &filename)
Definition: file.cpp:96
void writeHeader()
This member function writes the header lines or the text files.
Definition: file.cpp:263
void writeTableContents(const std::vector< size_t > &vColumnWidth)
This member function is used to write the data in memory to the target text file.
Definition: file.cpp:326
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...
Definition: file.cpp:795
void addSeparator(const std::vector< size_t > &vColumnWidth)
This member function draws a separator based upon the overall width of the columns.
Definition: file.cpp:362
void writeFile()
This method writes the data in memory to the referenced text file.
Definition: file.cpp:234
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.
Definition: file.cpp:390
This class resembles an Excel (97) workbook (*.xls), which is composed out of a compound file....
Definition: file.hpp:1819
virtual ~XLSSpreadSheet()
Definition: file.cpp:3709
virtual bool read() override
Pure virtual declaration of the read access method. Has to be implemented in all derived classes and ...
Definition: file.hpp:1828
virtual bool write() override
Pure virtual declaration of the write access method. Has to be implemented in all derived classes and...
Definition: file.hpp:1834
void writeFile()
This member function is used to write the data in the internal storage to the target XLS spreadsheet.
Definition: file.cpp:3911
XLSSpreadSheet(const std::string &filename)
Definition: file.cpp:3703
void readFile()
This member function is used to read the data from the XLS spreadsheet ino the internal storage.
Definition: file.cpp:3723
This class resembles an Excel (2003) spreadsheet (*.xlsx), which is based upon a zipped XML file....
Definition: file.hpp:1850
XLSXSpreadSheet(const std::string &filename)
Definition: file.cpp:3978
virtual ~XLSXSpreadSheet()
Definition: file.cpp:3984
void evalIndices(const std::string &sIndices, int &nLine, int &nCol)
This member function converts the usual Excel indices into numerical ones.
Definition: file.cpp:4272
virtual bool read() override
Pure virtual declaration of the read access method. Has to be implemented in all derived classes and ...
Definition: file.hpp:1859
void readFile()
This member function is used to read the data from the XLSX spreadsheet into the internal storage....
Definition: file.cpp:3999
virtual bool write() override
Pure virtual declaration of the write access method. Has to be implemented in all derived classes and...
Definition: file.hpp:1865
This class implements a Zygo MetroPro binary dat file. The data is read by accessing the ZygoLib.
Definition: file.hpp:1927
void readFile()
This member function is used to read the contents of the Zygo Dat file into the internal storage....
Definition: file.cpp:4604
virtual bool write() override
Pure virtual declaration of the write access method. Has to be implemented in all derived classes and...
Definition: file.hpp:1942
virtual ~ZygoDat()
Definition: file.cpp:4589
ZygoDat(const std::string &filename)
Definition: file.cpp:4570
ZygoDat & operator=(const ZygoDat &file)
This is an overload for the assignment operator of the GenericFile class.
Definition: file.cpp:4690
virtual bool read() override
Pure virtual declaration of the read access method. Has to be implemented in all derived classes and ...
Definition: file.hpp:1936
Common exception class for all exceptions thrown in NumeRe.
Definition: error.hpp:32
@ CANNOT_READ_FILE
Definition: error.hpp:75
@ DATAFILE_NOT_EXIST
INSERT HERE.
Definition: error.hpp:94
static size_t invalid_position
Definition: error.hpp:235
bool open(const std::string &sZipFilename, int nOpenmode=0)
Definition: zip++.cpp:38
bool close()
Definition: zip++.cpp:59
std::string getZipItem(const std::string &sFilename)
Definition: zip++.cpp:106
GenericFile * getFileByType(const string &filename)
This function determines the correct class to be used for the filename passed to this function....
Definition: file.cpp:45
GenericFileView FileView
Definition: file.hpp:1424
MUP_BASETYPE value_type
The numeric datatype used by the parser.
Definition: muParserDef.h:251
char name[32]
Definition: resampler.cpp:371
bool isConvertible(const std::string &sStr, ConvertibleType type)
This function checks, whether a string can be converted to the selected ConvertibleType.
@ CONVTYPE_VALUE
Definition: stringtools.hpp:44
This structure wraps all necessary meta information of a single file.
Definition: file.hpp:41
long long int nCols
Definition: file.hpp:47
__time64_t timeStamp
Definition: file.hpp:52
long int versionBuild
Definition: file.hpp:50
std::string sTableName
Definition: file.hpp:44
std::string sFileName
Definition: file.hpp:43
std::string sComment
Definition: file.hpp:45
std::string sFileExtension
Definition: file.hpp:42
long long int nRows
Definition: file.hpp:46
long int versionMinor
Definition: file.hpp:49
long int versionMajor
Definition: file.hpp:48
Structure for storing the JCAMP-DX meta data.
Definition: file.cpp:2681
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::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.