make the parsing stage pass even if non-defaultable items have been defaulted

... but throw later when trying to access the data of the item in
question.

Note that this was demanded by [at] joakim-hove and that I do not want
to be held responsible for any issues which are caused by this
approach. (read: please direct your barks to Joakim if you fell on
your nose because of this...)
This commit is contained in:
Andreas Lauser
2014-12-15 15:20:27 +01:00
parent 0262b333fd
commit 231cf39d47
15 changed files with 157 additions and 10 deletions

View File

@@ -35,6 +35,9 @@ namespace Opm {
}
void DeckIntItem::push_back(std::deque<int> data, size_t items) {
if (m_dataPointDefaulted.size() != m_data.size())
throw std::logic_error("To add a value to an item, no \"pseudo defaults\" can be added before");
for (size_t i = 0; i < items; i++) {
m_data.push_back(data[i]);
m_dataPointDefaulted.push_back(false);
@@ -42,21 +45,40 @@ namespace Opm {
}
void DeckIntItem::push_back(std::deque<int> data) {
if (m_dataPointDefaulted.size() != m_data.size())
throw std::logic_error("To add a value to an item, no \"pseudo defaults\" can be added before");
push_back(data, data.size());
m_dataPointDefaulted.push_back(false);
}
void DeckIntItem::push_back(int data) {
if (m_dataPointDefaulted.size() != m_data.size())
throw std::logic_error("To add a value to an item, no \"pseudo defaults\" can be added before");
m_data.push_back(data);
m_dataPointDefaulted.push_back(false);
}
void DeckIntItem::push_backDefault(int data) {
if (m_dataPointDefaulted.size() != m_data.size())
throw std::logic_error("To add a value to an item, no \"pseudo defaults\" can be added before");
m_data.push_back( data );
m_dataPointDefaulted.push_back(true);
}
void DeckIntItem::push_backDummyDefault() {
if (m_dataPointDefaulted.size() != 0)
throw std::logic_error("Pseudo defaults can only be specified for empty items");
m_dataPointDefaulted.push_back(true);
}
void DeckIntItem::push_backMultiple(int value, size_t numValues) {
if (m_dataPointDefaulted.size() != m_data.size())
throw std::logic_error("To add a value to an item, no \"pseudo defaults\" can be added before");
for (size_t i = 0; i < numValues; i++) {
m_data.push_back( value );
m_dataPointDefaulted.push_back(false);