Renamed keyword data class, and added test file
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
|
||||
add_library(Parser Parser.cpp data/KeywordDataToken.cpp)
|
||||
add_library(Parser Parser.cpp data/KeywordRecordSet.cpp)
|
||||
add_library(Logger Logger.cpp)
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
@@ -55,20 +55,20 @@ namespace Opm {
|
||||
|
||||
void Parser::readKeywordAndDataTokens(std::ifstream& inputstream) {
|
||||
std::string line;
|
||||
KeywordDataToken currentKeywordDataToken;
|
||||
KeywordRecordSet currentKeywordRecordSet;
|
||||
while (std::getline(inputstream, line)) {
|
||||
if (isKeyword(line)) {
|
||||
currentKeywordDataToken = KeywordDataToken(line);
|
||||
m_keywordRawDatas.push_back(currentKeywordDataToken);
|
||||
currentKeywordRecordSet = KeywordRecordSet(line);
|
||||
m_keywordRawDatas.push_back(currentKeywordRecordSet);
|
||||
} else {
|
||||
addDataToDataToken(line, currentKeywordDataToken);
|
||||
addDataToDataToken(line, currentKeywordRecordSet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Parser::addDataToDataToken(const std::string& line, KeywordDataToken& currentKeywordDataToken) {
|
||||
if (currentKeywordDataToken.getKeyword() != "" && looksLikeData(line)) {
|
||||
currentKeywordDataToken.addDataElement(line);
|
||||
void Parser::addDataToDataToken(const std::string& line, KeywordRecordSet& currentKeywordRecordSet) {
|
||||
if (currentKeywordRecordSet.getKeyword() != "" && looksLikeData(line)) {
|
||||
currentKeywordRecordSet.addDataElement(line);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <fstream>
|
||||
|
||||
#include "Logger.hpp"
|
||||
#include "data/KeywordDataToken.hpp"
|
||||
#include "data/KeywordRecordSet.hpp"
|
||||
|
||||
namespace Opm {
|
||||
|
||||
@@ -39,11 +39,11 @@ namespace Opm {
|
||||
private:
|
||||
std::string m_dataFilePath;
|
||||
Logger m_logger;
|
||||
std::list<KeywordDataToken> m_keywordRawDatas;
|
||||
std::list<KeywordRecordSet> m_keywordRawDatas;
|
||||
void initInputStream(const std::string &path, std::ifstream& file);
|
||||
void readKeywordAndDataTokens(std::ifstream& inputstream);
|
||||
bool isKeyword(const std::string& line);
|
||||
void addDataToDataToken(const std::string& line, KeywordDataToken& currentKeywordDataToken);
|
||||
void addDataToDataToken(const std::string& line, KeywordRecordSet& currentKeywordRecordSet);
|
||||
bool looksLikeData(const std::string& line);
|
||||
void checkInputFile(const std::string& pathToInputFile);
|
||||
|
||||
|
||||
+8
-8
@@ -18,34 +18,34 @@
|
||||
*/
|
||||
|
||||
#include <utility>
|
||||
#include "KeywordDataToken.hpp"
|
||||
#include "KeywordRecordSet.hpp"
|
||||
namespace Opm {
|
||||
|
||||
KeywordDataToken::KeywordDataToken() {
|
||||
KeywordRecordSet::KeywordRecordSet() {
|
||||
}
|
||||
|
||||
KeywordDataToken::KeywordDataToken(const std::string& keyword, const std::list<std::string>& dataElements) {
|
||||
KeywordRecordSet::KeywordRecordSet(const std::string& keyword, const std::list<std::string>& dataElements) {
|
||||
setKeyword(keyword);
|
||||
m_data = dataElements;
|
||||
}
|
||||
|
||||
KeywordDataToken::KeywordDataToken(const std::string& keyword) {
|
||||
KeywordRecordSet::KeywordRecordSet(const std::string& keyword) {
|
||||
m_keyword = keyword;
|
||||
}
|
||||
|
||||
void KeywordDataToken::setKeyword(const std::string& keyword) {
|
||||
void KeywordRecordSet::setKeyword(const std::string& keyword) {
|
||||
m_keyword = keyword;
|
||||
}
|
||||
|
||||
void KeywordDataToken::addDataElement(const std::string& element) {
|
||||
void KeywordRecordSet::addDataElement(const std::string& element) {
|
||||
m_data.push_back(element);
|
||||
}
|
||||
|
||||
std::string KeywordDataToken::getKeyword() {
|
||||
std::string KeywordRecordSet::getKeyword() {
|
||||
return m_keyword;
|
||||
}
|
||||
|
||||
KeywordDataToken::~KeywordDataToken() {
|
||||
KeywordRecordSet::~KeywordRecordSet() {
|
||||
}
|
||||
}
|
||||
|
||||
+8
-8
@@ -5,8 +5,8 @@
|
||||
* Created on March 20, 2013, 3:59 PM
|
||||
*/
|
||||
|
||||
#ifndef KEYWORDATATOKEN_HPP
|
||||
#define KEYWORDATATOKEN_HPP
|
||||
#ifndef KEYWORDRECORDSET_HPP
|
||||
#define KEYWORDRECORDSET_HPP
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
@@ -14,21 +14,21 @@
|
||||
|
||||
namespace Opm {
|
||||
|
||||
class KeywordDataToken {
|
||||
class KeywordRecordSet {
|
||||
public:
|
||||
KeywordDataToken();
|
||||
KeywordDataToken(const std::string& keyword, const std::list<std::string>& dataElements);
|
||||
KeywordDataToken(const std::string& keyword);
|
||||
KeywordRecordSet();
|
||||
KeywordRecordSet(const std::string& keyword, const std::list<std::string>& dataElements);
|
||||
KeywordRecordSet(const std::string& keyword);
|
||||
|
||||
std::string getKeyword();
|
||||
void setKeyword(const std::string& keyword);
|
||||
void addDataElement(const std::string& element);
|
||||
virtual ~KeywordDataToken();
|
||||
virtual ~KeywordRecordSet();
|
||||
|
||||
private:
|
||||
std::string m_keyword;
|
||||
std::list<std::string> m_data;
|
||||
};
|
||||
}
|
||||
#endif /* KEYWORDATATOKEN_HPP */
|
||||
#endif /* KEYWORDRECORDSET_HPP */
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
Reference in New Issue
Block a user