Added warning capabilities to the Deck
This commit is contained in:
@@ -59,6 +59,24 @@ namespace Opm {
|
||||
return m_keywords->size();
|
||||
}
|
||||
|
||||
size_t Deck::numWarnings() const {
|
||||
return m_warnings.size();
|
||||
}
|
||||
|
||||
void Deck::addWarning(const std::string& warningText , const std::string& filename , size_t lineNR) {
|
||||
std::pair<std::string,size_t> location(filename , lineNR);
|
||||
std::pair<std::string , std::pair<std::string,size_t> > warning(warningText , location);
|
||||
|
||||
m_warnings.push_back( warning );
|
||||
}
|
||||
|
||||
const std::pair<std::string , std::pair<std::string,size_t> >& Deck::getWarning( size_t index ) const {
|
||||
if (index < m_warnings.size())
|
||||
return m_warnings[index];
|
||||
else
|
||||
throw std::invalid_argument("Index out of range");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -40,8 +40,12 @@ namespace Opm {
|
||||
size_t numKeywords(const std::string& keyword);
|
||||
const std::vector<DeckKeywordConstPtr>& getKeywordList(const std::string& keyword);
|
||||
size_t size() const;
|
||||
size_t numWarnings() const;
|
||||
void addWarning(const std::string& warningText , const std::string& filename , size_t lineNR);
|
||||
const std::pair<std::string , std::pair<std::string,size_t> >& getWarning( size_t index ) const;
|
||||
private:
|
||||
KeywordContainerPtr m_keywords;
|
||||
std::vector<std::pair<std::string , std::pair<std::string,size_t> > > m_warnings; //<"Warning Text" , <"Filename" , LineNR>>
|
||||
};
|
||||
|
||||
typedef boost::shared_ptr<Deck> DeckPtr;
|
||||
|
||||
@@ -118,3 +118,27 @@ BOOST_AUTO_TEST_CASE(size_twokeyword_return2) {
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(DECKWARNING_EMPTYOK) {
|
||||
Deck deck;
|
||||
BOOST_CHECK_EQUAL(0U, deck.numWarnings());
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(DECKAddWarning) {
|
||||
Deck deck;
|
||||
deck.addWarning("WARNING" , "FILE" , 100U);
|
||||
BOOST_CHECK_EQUAL(1U, deck.numWarnings());
|
||||
|
||||
deck.addWarning("WARNING2" , "FILE2" , 200U);
|
||||
BOOST_CHECK_EQUAL(2U, deck.numWarnings());
|
||||
|
||||
const std::pair<std::string,std::pair<std::string,size_t> >& warning = deck.getWarning( 0 );
|
||||
const std::pair<std::string,size_t>& location = warning.second;
|
||||
|
||||
BOOST_CHECK_EQUAL( warning.first , "WARNING" );
|
||||
BOOST_CHECK_EQUAL( location.first , "FILE" );
|
||||
BOOST_CHECK_EQUAL( location.second , 100U );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user