Added name() property to section objects.

This commit is contained in:
Joakim Hove
2014-06-02 09:06:09 +02:00
committed by Andreas Lauser
parent 6b29eb5176
commit 7269924543
3 changed files with 10 additions and 2 deletions

View File

@@ -25,7 +25,7 @@
#include <opm/parser/eclipse/Deck/Section.hpp>
namespace Opm {
Section::Section(DeckConstPtr deck, const std::string& startKeyword, const std::vector<std::string>& stopKeywords ) {
Section::Section(DeckConstPtr deck, const std::string& startKeyword, const std::vector<std::string>& 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);
}

View File

@@ -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<std::string>& stopKeywords);
};

View File

@@ -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) {