Bug Fix, working around copy oper^ator for ifstream.

This commit is contained in:
Christian
2019-05-27 14:04:24 +02:00
parent 79bf420f8d
commit 0c36c0a938
5 changed files with 31 additions and 41 deletions
+16 -26
View File
@@ -55,7 +55,6 @@ private:
public:
void importFromCSV(std::string load_path);
private:
std::ifstream createImportStream(const std::string &load_path) ;
void addPointFromLine(const std::string &lineFromFile);
public:
@@ -65,9 +64,8 @@ private:
template <typename T> void rec_addPoint (std::map<double,T> *subMap, std::deque<double> pointIn);
public:
void exportToCSV(std::string exportPath) ;
void exportToCSV(std::string export_path) ;
private:
std::ofstream createExportStream(const std::string &exportPath) ;
std::string getExportFileHeader() ;
void rec_exportToCSV (const dim1Map &subMap, std::ofstream &exportStream, std::string preset = "") ;
template <typename T> void rec_exportToCSV(const T &subMap, std::ofstream &exportStream, std::string preset = "") ;
@@ -115,7 +113,13 @@ void Base_Container<T_Map>::inc_Count(std::map<double,T> *subMap, int *count) {
template <class T_Map>
void Base_Container<T_Map>::importFromCSV(std::string load_path) {
std::ifstream importStream = createImportStream(load_path);
std::ifstream importStream(load_path);
if (!importStream.good()) {
std::stringstream ss;
ss<<"Base_Container::readFromCSV: Could not open file. \n loadFilePath= "<<load_path<<"\n";
throw MyException(ss.str());
}
std::string lineFromFile;
while (getline(importStream, lineFromFile)) {
removeLeadingWhites(lineFromFile);
@@ -128,16 +132,6 @@ void Base_Container<T_Map>::importFromCSV(std::string load_path) {
importStream.close();
}
template <class T_Map>
std::ifstream Base_Container<T_Map>::createImportStream(const std::string &load_path) {
std::ifstream importStream(load_path);
if (!importStream.good()) {
std::stringstream ss;
ss<<"Base_Container::readFromCSV: Could not open file. \n loadFilePath= "<<load_path<<"\n";
throw MyException(ss.str());
}
return(importStream);
}
template <class T_Map>
void Base_Container<T_Map>::addPointFromLine(const std::string &lineFromFile) {
@@ -199,24 +193,20 @@ void Base_Container<T_Map>::rec_addPoint (std::map<double,T> *subMap, std::deque
template <class T_Map>
void Base_Container<T_Map>::exportToCSV(std::string exportPath) {
void Base_Container<T_Map>::exportToCSV(std::string export_path) {
checkEmpty();
std::ofstream exportStream = createExportStream(exportPath);
std::ofstream exportStream(export_path);
if (!exportStream.good()) {
std::stringstream ss;
ss<<"Base_Container::exportToCSV: Could not open file.\nexportFilePath\t "<<export_path<<"\n";
throw MyException(ss.str());
}
exportStream<<getExportFileHeader();
rec_exportToCSV(Map, exportStream, "");
exportStream.close();
}
template <class T_Map>
std::ofstream Base_Container<T_Map>::createExportStream(const std::string &exportPath) {
std::ofstream exportStream(exportPath);
if (!exportStream.good()) {
std::stringstream ss;
ss<<"Base_Container::exportToCSV: Could not open file.\nexportFilePath\t "<<exportPath<<"\n";
throw MyException(ss.str());
}
return(exportStream);
}
template <class T_Map>
std::string Base_Container<T_Map>::getExportFileHeader() {