Merged in documentation

This commit is contained in:
Joakim Hove
2013-05-06 09:44:00 +02:00
32 changed files with 1191 additions and 630 deletions

View File

@@ -16,32 +16,30 @@
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <opm/parser/eclipse/Parser/ParserKW.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include "opm/parser/eclipse/Parser/Parser.hpp"
#include "opm/parser/eclipse/Parser/ParserKW.hpp"
#include "opm/parser/eclipse/RawDeck/RawParserKWs.hpp"
namespace Opm {
Parser::Parser() {
}
Parser::Parser() {
}
RawDeckPtr Parser::parse(const std::string &path) {
Logger::initLogger();
Logger::setLogLevel(Logger::DEBUG);
Logger::info("Starting parsing of file: " + path);
RawDeckPtr rawDeck(new RawDeck());
rawDeck -> readDataIntoDeck(path);
Logger::info("Done parsing of file: " + path);
return rawDeck;
}
RawDeckPtr Parser::parse(const std::string &path) {
Logger::initLogger();
Logger::info("Starting parsing of file: " + path);
RawDeckPtr rawDeck(new RawDeck(RawParserKWsConstPtr(new RawParserKWs())));
rawDeck->readDataIntoDeck(path);
Logger::info("Done parsing of file: " + path);
Logger::closeLogger();
return rawDeck;
}
Parser::~Parser() {
}
void Parser::addKW(ParserKWConstPtr parserKW) {
keywords.insert( std::make_pair( parserKW->getName() , parserKW ));
}
Parser::~Parser() {
}
void Parser::addKW(ParserKWConstPtr parserKW) {
keywords.insert(std::make_pair(parserKW->getName(), parserKW));
}
} // namespace Opm

View File

@@ -25,26 +25,30 @@
#include <boost/shared_ptr.hpp>
#include <opm/parser/eclipse/Logger.hpp>
#include <opm/parser/eclipse/RawDeck/RawKeyword.hpp>
#include <opm/parser/eclipse/RawDeck/RawDeck.hpp>
#include <opm/parser/eclipse/Parser/ParserKW.hpp>
namespace Opm {
class Parser {
public:
Parser();
RawDeckPtr parse(const std::string &path);
virtual ~Parser();
/// The hub of the parsing process.
/// An input file in the eclipse data format is specified, several steps of parsing is performed
/// and the semantically parsed result is returned.
class Parser {
public:
Parser();
void addKW(ParserKWConstPtr parserKW);
private:
//Logger m_logger;
std::map<std::string,ParserKWConstPtr> keywords;
};
/// The starting point of the parsing process. The supplied file is parsed, and the resulting Deck is returned.
RawDeckPtr parse(const std::string &path);
virtual ~Parser();
typedef boost::shared_ptr<Parser> ParserPtr;
/// Method to add ParserKW instances, these holding type and size information about the keywords and their data.
void addKW(ParserKWConstPtr parserKW);
private:
std::map<std::string, ParserKWConstPtr> keywords;
};
typedef boost::shared_ptr<Parser> ParserPtr;
} // namespace Opm
#endif /* PARSER_H */

View File

@@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#ifndef PARSER_ENUMS_H
#define PARSER_ENUMS_H
@@ -27,11 +27,11 @@ namespace Opm {
enum ParserRecordSizeEnum {
UNDEFINED = 0,
FIXED = 1,
BOX = 2,
GRID = 3
FIXED = 1,
BOX = 2,
GRID = 3
};
}
#endif

View File

@@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include <string>
#include <stdexcept>
@@ -25,31 +25,26 @@
#include <opm/parser/eclipse/Parser/ParserKW.hpp>
namespace Opm {
ParserKW::ParserKW() {
m_name.assign("");
}
}
ParserKW::ParserKW(const std::string& name , ParserRecordSizeConstPtr recordSize) {
ParserKW::ParserKW(const std::string& name, ParserRecordSizeConstPtr recordSize) {
if (name.length() > ParserConst::maxKWLength)
throw std::invalid_argument("Given keyword name is too long - max 8 characters.");
for (unsigned int i=0; i < name.length(); i++)
for (unsigned int i = 0; i < name.length(); i++)
if (islower(name[i]))
throw std::invalid_argument("Keyword must be all upper case - mixed case not allowed:" + name);
m_name.assign( name );
m_name.assign(name);
this->recordSize = recordSize;
}
ParserKW::~ParserKW() {
}
//-----------------------------------------------------------------//
const std::string& ParserKW::getName() const {
return m_name;
}

View File

@@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#ifndef PARSER_KW_H
#define PARSER_KW_H
@@ -25,20 +25,17 @@
#include <opm/parser/eclipse/Parser/ParserRecordSize.hpp>
namespace Opm {
class ParserKW {
public:
ParserKW();
ParserKW(const std::string& name , ParserRecordSizeConstPtr recordSize);
ParserKW();
ParserKW(const std::string& name, ParserRecordSizeConstPtr recordSize);
~ParserKW();
const std::string& getName() const;
private:
std::string m_name;
std::string m_name;
ParserRecordSizeConstPtr recordSize;
};
typedef boost::shared_ptr<ParserKW> ParserKWPtr;
typedef boost::shared_ptr<const ParserKW> ParserKWConstPtr;
}

View File

@@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include <string>
#include <stdexcept>
@@ -26,35 +26,27 @@
namespace Opm {
ParserRecordSize::ParserRecordSize() {
recordSizeType = UNDEFINED;
fixedSize = 0;
}
ParserRecordSize::ParserRecordSize(size_t fixedSize) {
recordSizeType = FIXED;
this->fixedSize = fixedSize;
}
size_t ParserRecordSize::recordSize( ) {
size_t ParserRecordSize::recordSize() {
if (recordSizeType == FIXED) {
return fixedSize;
} else
throw std::logic_error("Only the FIXED recordSize is supported.\n");
}
ParserRecordSize::~ParserRecordSize() {
}
}

View File

@@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#ifndef PARSER_RECORD_SIZE_H
#define PARSER_RECORD_SIZE_H
@@ -28,19 +28,18 @@
#include <opm/parser/eclipse/Parser/ParserEnums.hpp>
namespace Opm {
class ParserRecordSize {
public:
ParserRecordSize();
ParserRecordSize(size_t fixedSize);
~ParserRecordSize();
size_t recordSize();
private:
enum ParserRecordSizeEnum recordSizeType;
enum ParserRecordSizeEnum recordSizeType;
size_t fixedSize;
};