Added export function to function container.

This commit is contained in:
Christian
2019-04-03 11:43:28 +02:00
parent c79661292e
commit e5d66411bb
6 changed files with 35 additions and 13 deletions
+19 -1
View File
@@ -58,7 +58,7 @@ void Func_Container::readFromCSV(std::string loadFilePath) {
if (!fileStream.good()) {
stringstream ss;
ss<<"Func_Container::readFromCSV: Could not open file: "<<loadFilePath<<endl;
ss<<"Func_Container::readFromCSV: Could not open file. \n loadFilePath= "<<loadFilePath<<endl;
throw MyException(ss.str());
}
@@ -97,6 +97,24 @@ void Func_Container::printAnkerpoints() {
}
}
void Func_Container::exportToFile(std::string exportFilePath) {
ofstream outFile;
outFile.open(exportFilePath);
if (!outFile.good()) {
stringstream ss;
ss<<"Func_Container::exportToFile: Could not open file. \n exportFilePath= "<<exportFilePath<<endl;
throw MyException(ss.str());
}
outFile<<"# Automatically generated Data of Function_Container class by exportToFile().\n";
outFile<<"# Generated on "<<getTimeString()<<".\n";
outFile<<"#key (usually Energy)\tparameter (usually TCS)\n";
dim1Map::iterator AnkerItr;
for (AnkerItr = Map.begin();AnkerItr!=Map.end();AnkerItr++) {
outFile<<AnkerItr->first<<"\t"<<AnkerItr->second<<"\n";
}
outFile.close();
}
// Func2D_Container
Func2D_Container::Func2D_Container(std::string loadFilePath) {
readFromCSV(loadFilePath);