diff --git a/opm/parser/eclipse/Deck/Section.cpp b/opm/parser/eclipse/Deck/Section.cpp index 037a962af..6287416a4 100644 --- a/opm/parser/eclipse/Deck/Section.cpp +++ b/opm/parser/eclipse/Deck/Section.cpp @@ -25,7 +25,7 @@ #include namespace Opm { - Section::Section(DeckConstPtr deck, const std::string& startKeyword, const std::vector& stopKeywords ) { + Section::Section(DeckConstPtr deck, const std::string& startKeyword, const std::vector& stopKeywords ) : m_name( startKeyword ) { populateKeywords(deck, startKeyword, stopKeywords); } @@ -41,6 +41,10 @@ namespace Opm { } } + const std::string& Section::name() const { + return m_name; + } + bool Section::hasKeyword( const std::string& keyword ) const { return m_keywords.hasKeyword(keyword); } diff --git a/opm/parser/eclipse/Deck/Section.hpp b/opm/parser/eclipse/Deck/Section.hpp index 5f6b0ae7d..42ba9bf35 100644 --- a/opm/parser/eclipse/Deck/Section.hpp +++ b/opm/parser/eclipse/Deck/Section.hpp @@ -35,9 +35,10 @@ namespace Opm { DeckKeywordConstPtr getKeyword(const std::string& keyword, size_t index) const; DeckKeywordConstPtr getKeyword(const std::string& keyword) const; DeckKeywordConstPtr getKeyword(size_t index) const; + const std::string& name() const; static bool hasSCHEDULE(DeckConstPtr deck) { return hasSection( deck , "SCHEDULE" ); } - static bool hasSOLUTIONS(DeckConstPtr deck) { return hasSection( deck , "SOLUTIONS" ); } + static bool hasSOLUTION(DeckConstPtr deck) { return hasSection( deck , "SOLUTION" ); } static bool hasREGIONS(DeckConstPtr deck) { return hasSection( deck , "REGIONS" ); } static bool hasPROPS(DeckConstPtr deck) { return hasSection( deck , "PROPS" ); } static bool hasEDIT(DeckConstPtr deck) { return hasSection( deck , "EDIT" ); } @@ -45,6 +46,7 @@ namespace Opm { static bool hasRUNSPEC(DeckConstPtr deck) { return hasSection( deck , "RUNSPEC" ); } private: KeywordContainer m_keywords; + std::string m_name; static bool hasSection(DeckConstPtr deck, const std::string& startKeyword); void populateKeywords(DeckConstPtr deck, const std::string& startKeyword, const std::vector& stopKeywords); }; diff --git a/opm/parser/eclipse/Deck/tests/SectionTests.cpp b/opm/parser/eclipse/Deck/tests/SectionTests.cpp index 39a089c71..ba2723ff1 100644 --- a/opm/parser/eclipse/Deck/tests/SectionTests.cpp +++ b/opm/parser/eclipse/Deck/tests/SectionTests.cpp @@ -43,6 +43,8 @@ BOOST_AUTO_TEST_CASE(SectionTest) { BOOST_CHECK_EQUAL(true, section.hasKeyword("TEST2")); BOOST_CHECK_EQUAL(false, section.hasKeyword("TEST3")); BOOST_CHECK_EQUAL(false, section.hasKeyword("TEST4")); + + BOOST_CHECK_EQUAL( section.name() , "TEST1" ); } BOOST_AUTO_TEST_CASE(IteratorTest) {