Commit 7a933184 authored by Enrico Bothmann's avatar Enrico Bothmann Committed by Frank Siegert

Modify yaml-cpp to reverse precedence for non-unique keys

Before, a key-value setting further to the top won when the same key was
used, now, a key-value setting further below wins. E.g. if the
configuration reads:

```
ALPHAS:
  USE_PDF: true
...
ALPHAS:
  USE_PDF: false
```
then the ALPHAS:USE_PDF setting used in Sherpa will be `false`.
parent 5e3dc907
......@@ -58,8 +58,8 @@ void Command_Line_Interface::Parse(int argc, char* argv[])
// parse parameters; order matters here, we want to give options precedence
// over non-options
bool success(true);
success = (ParseOptions(options) && success);
success = (ParseNoneOptions(parser) && success);
success = (ParseOptions(options) && success);
if (!success) {
PrintUsageAndExit();
......@@ -109,7 +109,7 @@ bool Command_Line_Interface::ParseNoneOptions(Option_Parser::Parser& parser)
{
String_Map legacysyntaxtags;
auto didfinddyamltags = false;
for (int i {parser.nonOptionsCount()-1}; i >= 0; --i) {
for (int i = 0; i < parser.nonOptionsCount(); ++i) {
auto nonOption = StringTrim(parser.nonOption(i));
// find legacy-syntax tag specifications
......
......@@ -200,7 +200,7 @@ node* node_data::get(node& key, shared_memory_holder /* pMemory */) const {
return NULL;
}
for (node_map::const_iterator it = m_map.begin(); it != m_map.end(); ++it) {
for (node_map::const_reverse_iterator it = m_map.rbegin(); it != m_map.rend(); ++it) {
if (it->first->is(key))
return it->second;
}
......@@ -221,7 +221,7 @@ node& node_data::get(node& key, shared_memory_holder pMemory) {
throw BadSubscript();
}
for (node_map::const_iterator it = m_map.begin(); it != m_map.end(); ++it) {
for (node_map::const_reverse_iterator it = m_map.rbegin(); it != m_map.rend(); ++it) {
if (it->first->is(key))
return *it->second;
}
......@@ -235,9 +235,9 @@ bool node_data::remove(node& key, shared_memory_holder /* pMemory */) {
if (m_type != NodeType::Map)
return false;
for (node_map::iterator it = m_map.begin(); it != m_map.end(); ++it) {
for (node_map::reverse_iterator it = m_map.rbegin(); it != m_map.rend(); ++it) {
if (it->first->is(key)) {
m_map.erase(it);
m_map.erase(std::next(it).base());
return true;
}
}
......
......@@ -87,7 +87,7 @@ inline node* node_data::get(const Key& key,
throw BadSubscript();
}
for (node_map::const_iterator it = m_map.begin(); it != m_map.end(); ++it) {
for (node_map::const_reverse_iterator it = m_map.rbegin(); it != m_map.rend(); ++it) {
if (it->first->equals(key, pMemory)) {
return it->second;
}
......@@ -115,7 +115,7 @@ inline node& node_data::get(const Key& key, shared_memory_holder pMemory) {
throw BadSubscript();
}
for (node_map::const_iterator it = m_map.begin(); it != m_map.end(); ++it) {
for (node_map::const_reverse_iterator it = m_map.rbegin(); it != m_map.rend(); ++it) {
if (it->first->equals(key, pMemory)) {
return *it->second;
}
......@@ -140,9 +140,9 @@ inline bool node_data::remove(const Key& key, shared_memory_holder pMemory) {
it = jt;
}
for (node_map::iterator it = m_map.begin(); it != m_map.end(); ++it) {
for (node_map::reverse_iterator it = m_map.rbegin(); it != m_map.rend(); ++it) {
if (it->first->equals(key, pMemory)) {
m_map.erase(it);
m_map.erase(std::next(it).base());
return true;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment