Reading some lines

This commit is contained in:
Kristian Flikka
2013-03-14 15:53:36 +01:00
parent c1696f0ed1
commit b403377abc
5 changed files with 40 additions and 9 deletions

View File

@@ -5,7 +5,7 @@
* Created on March 11, 2013, 3:40 PM
*/
#include <boost/filesystem.hpp>
#include <iostream>
#include <fstream>
using std::ifstream;
@@ -15,15 +15,38 @@ Parser::Parser() {
}
Parser::Parser(const std::string &path) {
boost::filesystem::path currentPath;
currentPath = boost::filesystem::current_path();
// Read keyword definition from file
dataFilePath = path;
}
EclipseDeck Parser::Parse() {
EclipseDeck deck;
log.append("Initializing inputstream from file: " + dataFilePath + "\n");
ifstream inputstream;
inputstream.open(dataFilePath.c_str());
if (!inputstream.is_open()) {
log.append("ERROR: unable to open file");
return deck;
}
std::string line;
while (!inputstream.eof()) {
std::getline(inputstream, line);
if (line.substr(0, 2) != "--") {
deck.AddKeyword(line);
}
log.append("Linje: " + line + "\n");
}
inputstream.close();
std::ofstream logfile;
logfile.open("log.txt");
logfile << log;
logfile.close();
return deck;
}