![]() |
NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
|
This class resembles the binary NumeRe data file format. The data is red and written in binary mode using the methods from GenericFile. More...
#include <file.hpp>
Public Member Functions | |
NumeReDataFile (const std::string &filename) | |
NumeReDataFile (const NumeReDataFile &file) | |
This copy constructor extents the copy constructor of the parent class. More... | |
virtual | ~NumeReDataFile () |
virtual bool | read () override |
Pure virtual declaration of the read access method. Has to be implemented in all derived classes and can be used to read the contents of the file to memory. More... | |
virtual bool | write () override |
Pure virtual declaration of the write access method. Has to be implemented in all derived classes and can be used to write the contents in memory to the target file. More... | |
NumeReDataFile & | operator= (NumeReDataFile &file) |
This member function is an overload for the assignment operator. It extends the already available assingnment operator of the parent class. More... | |
void | readFileInformation () |
Reads only the header of the referenced file. More... | |
__time64_t | getTimeStamp () |
Returns the file timestamp. More... | |
virtual FileHeaderInfo | getFileHeaderInformation () override |
Returns the file header information structure. More... | |
std::string | getVersionString () |
This simple member function returns the version string associated with the current file type. More... | |
![]() | |
GenericFile (const std::string &fileName) | |
Constructor from filename. More... | |
GenericFile (const GenericFile &file) | |
Copy constructor. More... | |
virtual | ~GenericFile () |
Virtual destructor: we'll work with instances on the heap, therefore we'll need virtual declared destructors. This destructor will clear the internal memory and closes the file stream, if it is still open. More... | |
bool | is_open () |
Wrapper for fstream::is_open() More... | |
void | close () |
Wrapper for fstream::close(). Will also clear the internal memory. More... | |
bool | good () |
Wrapper for fstream::good() More... | |
size_t | tellg () |
Wrapper for fstream::tellg() More... | |
size_t | tellp () |
Wrapper for fstream::tellp() More... | |
void | seekg (size_t pos) |
Wrapper for fstream::seekg() with start from the beginning of the stream. More... | |
void | seekp (size_t pos) |
Wrapper for fstream::seekp() with start from the beginning of the stream. More... | |
std::string | getExtension () |
Returns the file extension. More... | |
std::string | getFileName () |
Returns the file name. More... | |
std::string | getTableName () |
Returns the table name referenced in the file. Will default to the file name with non-alnum characters replaced with underscores, if the file does not reference a table name by itself. More... | |
std::string | getComment () |
Returns the comment stored with the referenced file. More... | |
void | setComment (const std::string &comment) |
Sets the comment to be written to the referencedfile. More... | |
long long int | getRows () |
Returns the number of rows. More... | |
long long int | getCols () |
Returns the number of columns. More... | |
virtual FileHeaderInfo | getFileHeaderInformation () |
Returns the file header information structure. More... | |
virtual bool | read ()=0 |
Pure virtual declaration of the read access method. Has to be implemented in all derived classes and can be used to read the contents of the file to memory. More... | |
virtual bool | write ()=0 |
Pure virtual declaration of the write access method. Has to be implemented in all derived classes and can be used to write the contents in memory to the target file. More... | |
GenericFile & | operator= (const GenericFile &file) |
Assignment operator definition. More... | |
void | getData (TableColumnArray *data) |
This method copies the internal data to the passed memory address. The target memory must already exist. More... | |
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 not stored for future use, because the referenced memory will be deleted upon destruction of this class instance. More... | |
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 in advance. More... | |
void | setTableName (const std::string &name) |
Set the table's name. More... | |
void | setTextfilePrecision (unsigned short nPrecision) |
Set the precision, which shall be used to convert the floating point numbers into strings. More... | |
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. More... | |
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 long as thos class exists. More... | |
![]() | |
FileSystem () | |
Default constructor. More... | |
FileSystem & | assign (const FileSystem &_fSys) |
Assignment member function to copy the settings from another FileSystem instance. More... | |
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 preferred filename extension. More... | |
std::string | ValidFolderName (std::string _sFileName, bool doCleanPath=true, bool appendTrailingSeparator=true) const |
This member function evaluates, whether the passed foldername is a valid foldername. More... | |
std::string | ValidizeAndPrepareName (const std::string &_sFileName, const std::string &sExtension=".dat") const |
This member function validizes the passed file name and creates the needed folders on-the-fly. More... | |
int | setPath (std::string _sPath, bool bMkDir, std::string _sExePath) |
This member function may be used to set the preferred file path of the current FileSystem instance. More... | |
void | createRevisionsFolder () |
This member function creates the hidden revisions folders for the version control system. More... | |
std::string | getPath () const |
Returns the default path of this FileSystem instance. More... | |
std::vector< std::string > | getFileParts (const std::string &sFilePath) const |
This member function separates all path parts into single strings: the drive letter, the path, the name and the extension. This function may also handle folder paths and network paths. More... | |
FileInfo | getFileInfo (const std::string &sFilePath) const |
Return the file information about the passed file path. More... | |
void | setTokens (std::string _sTokens) |
This member function may be used to update the path placeholders of the current FileSystem instance. More... | |
bool | isFile (const std::string &_sPath) const |
This function determines, whether a path name indicates a file or a folder. More... | |
void | initializeFromKernel () |
Member function to remote-initialize the class from the kernel. Cannot be used during kernel start-up. More... | |
void | setProgramPath (std::string _sExePath) |
std::string | getProgramPath () const |
void | declareFileType (const std::string &sFileType) |
Protected Member Functions | |
void | writeHeader () |
This member function writest the new standard header for NDAT files. It includes a dummy section, which older versions of NumeRe may read without errors, but which won't contain any reasonable information. More... | |
void | writeDummyHeader () |
This member function will write the dummy header, which is readable in older versions of NumeRe. In a nutshell, this is the legacy format of NDAT files for a 1x1 data set. More... | |
void | writeFile () |
This member function will write the data in the internal storage into the target file. More... | |
void | writeColumn (const TblColPtr &col) |
Writes a single column to the file. More... | |
void | readHeader () |
This member function will read the header in the selected file. It will automatically detect, whether the file is in legacy format or not. If the file format is newer than expected, it will throw an error. More... | |
void | skipDummyHeader () |
This function jumps over the dummy section in the new file format, because it does not conatin any valid information. More... | |
void | readFile () |
This member function will read the contents of the target file. More... | |
void | readColumn (TblColPtr &col) |
Reads a single column from file. More... | |
void | readColumnV4 (TblColPtr &col) |
Reads a single column from file in v4 format. More... | |
void | readLegacyFormat () |
This member function reads the data section of the target file in legacy format. The function readHeader() determines, whether the target file is in legacy mode. More... | |
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 in future versions of NumeRe). More... | |
void | deleteGenericData (void *data, const std::string &type) |
This member function will delete the data array obtained from the generic fields but convert them into their original type first, because deleting of void* is undefined behavior (the length of the field in memory is not defined). More... | |
![]() | |
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, this method throws an error. More... | |
void | stripTrailingSpaces (std::string &_sToStrip) |
This method strips trailing spaces from the passed string. More... | |
void | replaceDecimalSign (std::string &_sToReplace) |
This method simply replaces commas with dots in the passed string to enable correct parsing into a double. More... | |
void | replaceTabSign (std::string &_sToReplace, bool bAddPlaceholders=false) |
This method replaces tabulator characters with whitespaces to simplify the column determination (the used tokenizer will only have to consider whitespaces as separator characters). Sometimes, replacing tabulators into whitespaces will destroy column information. To avoid this, placeholders (underscores) may be inserted as "empty" column cells. More... | |
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. This method will return a std::pair<> with the maximal number of characters in a line in the first and the number of lines in the second component. More... | |
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. If the selected text does not contain enough lines, a simple whitespaces is returned. More... | |
template<typename T > | |
T | readNumField () |
This method is a template fo reading a numeric field of the selected template type in binary mode. More... | |
std::string | readStringField () |
This mehtod can be used to read a string field from the file in binary mode. More... | |
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 as string. More... | |
template<typename T > | |
T * | readNumBlock (long long int &size) |
This method template is for reading a block of numeric data into memory in binary mode. More... | |
template<typename T > | |
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. More... | |
std::string * | readStringBlock (long long int &size) |
This method can be used for reading a block of string data to memory in binary mode. More... | |
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. More... | |
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. If empty token shall be skipped, then only tokens with a non-zero length are stored. More... | |
template<typename T > | |
void | writeNumField (T num) |
This method template can be used to write a numeric value to file in binary mode. More... | |
void | writeStringField (const std::string &sString) |
This method may be used to write a string to file in binary mode. More... | |
template<typename T > | |
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 mode. More... | |
template<typename T > | |
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. More... | |
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. More... | |
void | createStorage () |
This method prepares the internal storage, so that it may contain the read data. This method is only used for textual files. More... | |
void | clearStorage () |
This method cleares the internal storage. This method is called by the destructor automatically. More... | |
template<typename T > | |
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 to exist in advance. More... | |
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. More... | |
template<typename T > | |
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 arrays have to exist in advance. More... | |
bool | isNumeric (const std::string &sString) |
This method may be used to determine, whether a string contains only numeric data. More... | |
void | assign (const GenericFile &file) |
This method is used by the assignment operator and the copy constructor to copy the contents of the passed GenericFile instance. More... | |
![]() | |
int | createFolders (const std::string &_sPath) const |
This member function creates all missing directories in the passed path. More... | |
Protected Attributes | |
bool | isLegacy |
__time64_t | timeStamp |
long int | versionMajor |
long int | versionMinor |
long int | versionBuild |
const short | fileSpecVersionMajor = 4 |
const short | fileSpecVersionMinor = 0 |
float | fileVersionRead |
size_t | checkPos |
size_t | checkStart |
![]() | |
std::fstream | fFileStream |
std::string | sFileExtension |
std::string | sFileName |
std::string | sTableName |
std::string | sComment |
long long int | nRows |
long long int | nCols |
unsigned short | nPrecFields |
bool | useExternalData |
std::ios::openmode | openMode |
TableColumnArray * | fileData |
![]() | |
std::string | sPath |
std::string | sExecutablePath |
std::string | sTokens [7][2] |
std::string | sValidExtensions |
This class resembles the binary NumeRe data file format. The data is red and written in binary mode using the methods from GenericFile.
NumeRe::NumeReDataFile::NumeReDataFile | ( | const std::string & | filename | ) |
NumeRe::NumeReDataFile::NumeReDataFile | ( | const NumeReDataFile & | file | ) |
This copy constructor extents the copy constructor of the parent class.
file | const NumeReDataFile& |
Definition at line 843 of file file.cpp.
References fileVersionRead, isLegacy, NumeRe::GenericFile::sComment, timeStamp, versionBuild, versionMajor, and versionMinor.
|
protected |
This member function will delete the data array obtained from the generic fields but convert them into their original type first, because deleting of void* is undefined behavior (the length of the field in memory is not defined).
data | void* |
type | const string& |
Definition at line 1566 of file file.cpp.
Referenced by readHeader().
|
inlineoverridevirtual |
Returns the file header information structure.
Reimplemented from NumeRe::GenericFile.
Definition at line 1540 of file file.hpp.
References NumeRe::FileHeaderInfo::fileVersion, fileVersionRead, NumeRe::GenericFile::getTableName(), NumeRe::FileHeaderInfo::nCols, NumeRe::GenericFile::nCols, NumeRe::FileHeaderInfo::nRows, NumeRe::GenericFile::nRows, NumeRe::FileHeaderInfo::sComment, NumeRe::GenericFile::sComment, NumeRe::FileHeaderInfo::sFileExtension, NumeRe::GenericFile::sFileExtension, NumeRe::FileHeaderInfo::sFileName, NumeRe::GenericFile::sFileName, NumeRe::FileHeaderInfo::sTableName, NumeRe::FileHeaderInfo::timeStamp, timeStamp, NumeRe::FileHeaderInfo::versionBuild, versionBuild, NumeRe::FileHeaderInfo::versionMajor, versionMajor, NumeRe::FileHeaderInfo::versionMinor, and versionMinor.
Referenced by getFileInfo().
|
inline |
std::string NumeRe::NumeReDataFile::getVersionString | ( | ) |
This simple member function returns the version string associated with the current file type.
Definition at line 1620 of file file.cpp.
References toString(), versionBuild, versionMajor, and versionMinor.
NumeReDataFile & NumeRe::NumeReDataFile::operator= | ( | NumeReDataFile & | file | ) |
This member function is an overload for the assignment operator. It extends the already available assingnment operator of the parent class.
file | NumeReDataFile& |
Definition at line 1598 of file file.cpp.
References NumeRe::GenericFile::assign(), isLegacy, NumeRe::GenericFile::sComment, timeStamp, versionBuild, versionMajor, and versionMinor.
|
inlineoverridevirtual |
Pure virtual declaration of the read access method. Has to be implemented in all derived classes and can be used to read the contents of the file to memory.
Implements NumeRe::GenericFile.
Reimplemented in NumeRe::CacheFile.
Definition at line 1502 of file file.hpp.
References readFile().
|
protected |
Reads a single column from file.
col | TblColPtr& |
Definition at line 1278 of file file.cpp.
References VectorIndex::OPEN_END, NumeRe::GenericFile::readStringBlock(), and NumeRe::GenericFile::readStringField().
Referenced by readFile().
|
protected |
Reads a single column from file in v4 format.
col | TblColPtr& |
Definition at line 1342 of file file.cpp.
References VectorIndex::OPEN_END, NumeRe::GenericFile::readStringBlock(), NumeRe::GenericFile::readStringField(), and NumeRe::GenericFile::seekg().
Referenced by readFile().
|
protected |
This member function will read the contents of the target file.
Definition at line 1190 of file file.cpp.
References NumeRe::GenericFile::createStorage(), NumeRe::GenericFile::fileData, fileVersionRead, NumeRe::GenericFile::is_open(), isLegacy, NumeRe::GenericFile::open(), readColumn(), readColumnV4(), readHeader(), readLegacyFormat(), and NumeRe::GenericFile::readStringBlock().
Referenced by read(), and NumeRe::CacheFile::readSome().
|
inline |
Reads only the header of the referenced file.
Definition at line 1523 of file file.hpp.
References NumeRe::GenericFile::open(), and readHeader().
Referenced by getFileInfo().
|
protected |
This member function will read a generic field from the header (the three fields, which can be used in future versions of NumeRe).
type | std::string& |
size | long longint& |
Definition at line 1503 of file file.cpp.
References NumeRe::GenericFile::readStringBlock(), and NumeRe::GenericFile::readStringField().
Referenced by readHeader().
|
protected |
This member function will read the header in the selected file. It will automatically detect, whether the file is in legacy format or not. If the file format is newer than expected, it will throw an error.
Definition at line 1060 of file file.cpp.
References _lang, SyntaxError::CANNOT_READ_FILE, checkStart, deleteGenericData(), NumeRe::GenericFile::fFileStream, fileSpecVersionMajor, fileVersionRead, Language::get(), SyntaxError::INSUFFICIENT_NUMERE_VERSION, SyntaxError::invalid_position, isLegacy, NumeReKernel::issueWarning(), NumeRe::GenericFile::nCols, NumeRe::GenericFile::nRows, readGenericField(), NumeRe::GenericFile::readStringField(), NumeRe::GenericFile::sComment, NumeRe::GenericFile::seekg(), NumeRe::GenericFile::sFileName, skipDummyHeader(), NumeRe::GenericFile::sTableName, NumeRe::GenericFile::tellg(), timeStamp, versionBuild, versionMajor, and versionMinor.
Referenced by readFile(), and readFileInformation().
|
protected |
This member function reads the data section of the target file in legacy format. The function readHeader() determines, whether the target file is in legacy mode.
Definition at line 1413 of file file.cpp.
References NumeRe::GenericFile::createStorage(), NumeRe::GenericFile::fFileStream, NumeRe::GenericFile::fileData, NumeRe::GenericFile::nCols, and NumeRe::GenericFile::nRows.
Referenced by readFile().
|
protected |
This function jumps over the dummy section in the new file format, because it does not conatin any valid information.
Definition at line 1169 of file file.cpp.
References NumeRe::GenericFile::fFileStream, and NumeRe::GenericFile::readStringField().
Referenced by readHeader().
|
inlineoverridevirtual |
Pure virtual declaration of the write access method. Has to be implemented in all derived classes and can be used to write the contents in memory to the target file.
Implements NumeRe::GenericFile.
Reimplemented in NumeRe::CacheFile.
Definition at line 1508 of file file.hpp.
References writeFile().
Referenced by TableViewer::saveTable().
|
protected |
Writes a single column to the file.
col | const TblColPtr& |
Definition at line 981 of file file.cpp.
References VectorIndex::OPEN_END, NumeRe::GenericFile::seekp(), NumeRe::GenericFile::tellp(), TableColumn::TYPE_CATEGORICAL, TableColumn::TYPE_DATETIME, TableColumn::TYPE_LOGICAL, TableColumn::TYPE_NONE, TableColumn::TYPE_STRING, TableColumn::TYPE_VALUE, NumeRe::GenericFile::writeStringBlock(), and NumeRe::GenericFile::writeStringField().
Referenced by writeFile().
|
protected |
This member function will write the dummy header, which is readable in older versions of NumeRe. In a nutshell, this is the legacy format of NDAT files for a 1x1 data set.
Definition at line 920 of file file.cpp.
References NumeRe::GenericFile::fFileStream, NumeRe::GenericFile::writeNumField(), and NumeRe::GenericFile::writeStringField().
Referenced by writeHeader().
|
protected |
This member function will write the data in the internal storage into the target file.
Definition at line 942 of file file.cpp.
References checkPos, checkStart, NumeRe::GenericFile::fFileStream, NumeRe::GenericFile::fileData, NumeRe::GenericFile::is_open(), NumeRe::GenericFile::open(), NumeRe::GenericFile::seekp(), NumeRe::GenericFile::tellp(), date::detail::trunc(), writeColumn(), writeHeader(), and NumeRe::GenericFile::writeStringField().
Referenced by write(), and NumeRe::CacheFile::writeSome().
|
protected |
This member function writest the new standard header for NDAT files. It includes a dummy section, which older versions of NumeRe may read without errors, but which won't contain any reasonable information.
Definition at line 871 of file file.cpp.
References AutoVersion::BUILD, checkPos, checkStart, fileSpecVersionMajor, fileSpecVersionMinor, NumeRe::GenericFile::getTableName(), AutoVersion::MAJOR, AutoVersion::MINOR, NumeRe::GenericFile::nCols, NumeRe::GenericFile::nRows, NumeRe::GenericFile::sComment, NumeRe::GenericFile::tellp(), writeDummyHeader(), NumeRe::GenericFile::writeNumField(), and NumeRe::GenericFile::writeStringField().
Referenced by writeFile().
|
protected |
Definition at line 1481 of file file.hpp.
Referenced by writeFile(), and writeHeader().
|
protected |
Definition at line 1482 of file file.hpp.
Referenced by readHeader(), writeFile(), and writeHeader().
|
protected |
Definition at line 1478 of file file.hpp.
Referenced by NumeRe::CacheFile::readCacheHeader(), readHeader(), NumeRe::CacheFile::writeCacheHeader(), and writeHeader().
|
protected |
Definition at line 1479 of file file.hpp.
Referenced by NumeRe::CacheFile::writeCacheHeader(), and writeHeader().
|
protected |
Definition at line 1480 of file file.hpp.
Referenced by getFileHeaderInformation(), NumeReDataFile(), readFile(), and readHeader().
|
protected |
Definition at line 1473 of file file.hpp.
Referenced by NumeReDataFile(), operator=(), readFile(), and readHeader().
|
protected |
Definition at line 1474 of file file.hpp.
Referenced by getFileHeaderInformation(), getTimeStamp(), NumeReDataFile(), operator=(), NumeRe::CacheFile::readCacheHeader(), and readHeader().
|
protected |
Definition at line 1477 of file file.hpp.
Referenced by getFileHeaderInformation(), getVersionString(), NumeReDataFile(), operator=(), NumeRe::CacheFile::readCacheHeader(), and readHeader().
|
protected |
Definition at line 1475 of file file.hpp.
Referenced by getFileHeaderInformation(), getVersionString(), NumeReDataFile(), operator=(), NumeRe::CacheFile::readCacheHeader(), and readHeader().
|
protected |
Definition at line 1476 of file file.hpp.
Referenced by getFileHeaderInformation(), getVersionString(), NumeReDataFile(), operator=(), NumeRe::CacheFile::readCacheHeader(), and readHeader().