Reading some lines
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user