Added subdirectory Parser/ + added ParserRecordSize as element in ParserKW
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
|
||||
add_library(Parser Parser.cpp data/RawDeck.cpp data/RawKeyword.cpp data/RawRecord.cpp ParserKW.cpp)
|
||||
add_library(Parser data/RawDeck.cpp data/RawKeyword.cpp data/RawRecord.cpp Parser/Parser.cpp Parser/ParserRecordSize.cpp Parser/ParserKW.cpp)
|
||||
add_library(Logger Logger.cpp)
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Parser)
|
||||
|
||||
|
||||
@@ -23,9 +23,9 @@
|
||||
#include <fstream>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include "Logger.hpp"
|
||||
#include "data/RawKeyword.hpp"
|
||||
#include "data/RawDeck.hpp"
|
||||
#include <opm/parser/eclipse/Logger.hpp>
|
||||
#include <opm/parser/eclipse/data/RawKeyword.hpp>
|
||||
#include <opm/parser/eclipse/data/RawDeck.hpp>
|
||||
|
||||
|
||||
namespace Opm {
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
Copyright 2013 Statoil ASA.
|
||||
|
||||
This file is part of the Open Porous Media project (OPM).
|
||||
|
||||
OPM is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OPM is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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
|
||||
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
enum ParserRecordSizeEnum {
|
||||
UNDEFINED = 0,
|
||||
FIXED = 1,
|
||||
BOX = 2,
|
||||
GRID = 3
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -20,8 +20,9 @@
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <opm/parser/eclipse/ParserKW.hpp>
|
||||
#include <opm/parser/eclipse/ParserConst.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserConst.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserRecordSize.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKW.hpp>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
@@ -31,7 +32,7 @@ namespace Opm {
|
||||
|
||||
|
||||
|
||||
ParserKW::ParserKW(const std::string& name) {
|
||||
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.");
|
||||
|
||||
@@ -40,13 +41,11 @@ namespace Opm {
|
||||
throw std::invalid_argument("Keyword must be all upper case - mixed case not allowed:" + name);
|
||||
|
||||
m_name.assign( name );
|
||||
this->recordSize = recordSize;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ParserKW::~ParserKW() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------//
|
||||
@@ -20,21 +20,21 @@
|
||||
#define PARSER_KW_H
|
||||
|
||||
#include <string>
|
||||
#include <opm/parser/eclipse/Parser/ParserRecordSize.hpp>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
class ParserKW {
|
||||
|
||||
public:
|
||||
ParserKW();
|
||||
ParserKW(const std::string& name);
|
||||
ParserKW();
|
||||
ParserKW(const std::string& name , ParserRecordSizeConstPtr recordSize);
|
||||
~ParserKW();
|
||||
|
||||
const std::string& getName();
|
||||
|
||||
|
||||
private:
|
||||
std::string m_name;
|
||||
ParserRecordSizeConstPtr recordSize;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
Copyright 2013 Statoil ASA.
|
||||
|
||||
This file is part of the Open Porous Media project (OPM).
|
||||
|
||||
OPM is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OPM is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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>
|
||||
|
||||
#include <opm/parser/eclipse/Parser/ParserConst.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserEnums.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserRecordSize.hpp>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
|
||||
ParserRecordSize::ParserRecordSize() {
|
||||
recordSizeType = UNDEFINED;
|
||||
fixedSize = 0;
|
||||
}
|
||||
|
||||
|
||||
ParserRecordSize::ParserRecordSize(size_t fixedSize) {
|
||||
recordSizeType = FIXED;
|
||||
this->fixedSize = fixedSize;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
size_t ParserRecordSize::recordSize( ) {
|
||||
if (recordSizeType == FIXED) {
|
||||
return fixedSize;
|
||||
} else
|
||||
throw std::logic_error("Only the FIXED recordSize is supported.\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
ParserRecordSize::~ParserRecordSize() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
Copyright 2013 Statoil ASA.
|
||||
|
||||
This file is part of the Open Porous Media project (OPM).
|
||||
|
||||
OPM is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OPM is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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
|
||||
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/Parser/ParserConst.hpp>
|
||||
#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;
|
||||
size_t fixedSize;
|
||||
};
|
||||
|
||||
typedef boost::shared_ptr<ParserRecordSize> ParserRecordSizePtr;
|
||||
typedef boost::shared_ptr<const ParserRecordSize> ParserRecordSizeConstPtr;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
#ifndef RAWDECK_HPP
|
||||
#define RAWDECK_HPP
|
||||
#define RAWDECK_HPP
|
||||
#include <list>
|
||||
#include <iostream>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
@@ -28,9 +28,9 @@ namespace Opm {
|
||||
bool looksLikeData(const std::string& line);
|
||||
void checkInputFile(const std::string& inputPath);
|
||||
};
|
||||
|
||||
|
||||
typedef boost::shared_ptr<RawDeck> RawDeckPtr;
|
||||
}
|
||||
|
||||
#endif /* RAWDECK_HPP */
|
||||
#endif /* RAWDECK_HPP */
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
#ifndef RAWKEYWORD_HPP
|
||||
#define RAWKEYWORD_HPP
|
||||
#define RAWKEYWORD_HPP
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
@@ -37,5 +37,5 @@ namespace Opm {
|
||||
};
|
||||
typedef boost::shared_ptr<RawKeyword> RawKeywordPtr;
|
||||
}
|
||||
#endif /* RAWKEYWORD_HPP */
|
||||
#endif /* RAWKEYWORD_HPP */
|
||||
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
add_executable(runParserTests ParserTests.cpp)
|
||||
add_executable(runRawDataTests RawDataStructuresTests.cpp)
|
||||
add_executable(runParserKWTests ParserKWTests.cpp)
|
||||
add_executable(runParserRecordSizeTests ParserRecordSizeTests.cpp)
|
||||
|
||||
target_link_libraries(runParserTests Parser Logger ${Boost_LIBRARIES})
|
||||
target_link_libraries(runRawDataTests Parser Logger ${Boost_LIBRARIES})
|
||||
target_link_libraries(runParserKWTests Parser Logger ${Boost_LIBRARIES})
|
||||
target_link_libraries(runParserRecordSizeTests Parser Logger ${Boost_LIBRARIES})
|
||||
|
||||
|
||||
add_test(NAME runParserTests WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} COMMAND ${EXECUTABLE_OUTPUT_PATH}/runParserTests )
|
||||
add_test(NAME runRawDataTests WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} COMMAND ${EXECUTABLE_OUTPUT_PATH}/runRawDataTests )
|
||||
add_test(NAME runParserKWTests COMMAND ${EXECUTABLE_OUTPUT_PATH}/runParserKWTests )
|
||||
add_test(NAME runParserRecordSizeTests COMMAND ${EXECUTABLE_OUTPUT_PATH}/runParserRecordSizeTests )
|
||||
|
||||
+10
-6
@@ -21,7 +21,7 @@
|
||||
#define BOOST_TEST_MODULE ParserTests
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include "opm/parser/eclipse/ParserKW.hpp"
|
||||
#include "opm/parser/eclipse/Parser/ParserKW.hpp"
|
||||
|
||||
|
||||
using namespace Opm;
|
||||
@@ -37,20 +37,24 @@ BOOST_AUTO_TEST_CASE(Initialize) {
|
||||
|
||||
BOOST_AUTO_TEST_CASE(NamedInit) {
|
||||
std::string keyword("KEYWORD");
|
||||
ParserKW parserKW( keyword );
|
||||
|
||||
ParserRecordSizeConstPtr recordSize( new ParserRecordSize( 100 ));
|
||||
ParserKW parserKW( keyword , recordSize);
|
||||
BOOST_REQUIRE_EQUAL( parserKW.getName( ) , keyword );
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(NameTooLong) {
|
||||
std::string keyword("KEYWORDTOOLONG");
|
||||
|
||||
BOOST_REQUIRE_THROW( ParserKW parserKW( keyword ) , std::invalid_argument );
|
||||
ParserRecordSizeConstPtr recordSize( new ParserRecordSize( 100 ));
|
||||
BOOST_REQUIRE_THROW( ParserKW parserKW( keyword , recordSize ) , std::invalid_argument );
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(MixedCase) {
|
||||
std::string keyword("KeyWord");
|
||||
|
||||
BOOST_REQUIRE_THROW( ParserKW parserKW( keyword ) , std::invalid_argument );
|
||||
|
||||
ParserRecordSizeConstPtr recordSize( new ParserRecordSize( 100 ));
|
||||
BOOST_REQUIRE_THROW( ParserKW parserKW( keyword , recordSize ) , std::invalid_argument );
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
Copyright 2013 Statoil ASA.
|
||||
|
||||
This file is part of the Open Porous Media project (OPM).
|
||||
|
||||
OPM is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OPM is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#define BOOST_TEST_MODULE ParserTests
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include "opm/parser/eclipse/Parser/ParserRecordSize.hpp"
|
||||
|
||||
|
||||
using namespace Opm;
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Initialize) {
|
||||
BOOST_REQUIRE_NO_THROW( ParserRecordSize recordSize );
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(DynamicSize) {
|
||||
ParserRecordSize recordSize;
|
||||
BOOST_REQUIRE_THROW( recordSize.recordSize() , std::logic_error );
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(FixedSize) {
|
||||
BOOST_REQUIRE_NO_THROW( ParserRecordSize recordSize(100) );
|
||||
ParserRecordSize recordSize(100);
|
||||
|
||||
BOOST_REQUIRE_EQUAL( recordSize.recordSize() , (size_t) 100 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#define BOOST_TEST_MODULE ParserTests
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include "opm/parser/eclipse/Parser.hpp"
|
||||
#include "opm/parser/eclipse/Parser/Parser.hpp"
|
||||
#include "opm/parser/eclipse/data/RawDeck.hpp"
|
||||
using namespace Opm;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user