C++11: Cleaned up column code wiht range-based for

This commit is contained in:
Paul Beckingham
2015-05-11 17:33:20 -04:00
parent 5b675ea834
commit bd3d58484a
7 changed files with 48 additions and 69 deletions

View File

@@ -149,24 +149,22 @@ void Column::uda (std::map <std::string, Column*>& all)
// For each UDA, instantiate and initialize ColumnUDA().
std::map <std::string, int> udas;
Config::const_iterator i;
for (i = context.config.begin (); i != context.config.end (); ++i)
for (auto& i : context.config)
{
if (i->first.substr (0, 4) == "uda.")
if (i.first.substr (0, 4) == "uda.")
{
std::string::size_type period = 4;
if ((period = i->first.find ('.', period)) != std::string::npos)
udas[i->first.substr (4, period - 4)] = 0;
if ((period = i.first.find ('.', period)) != std::string::npos)
udas[i.first.substr (4, period - 4)] = 0;
}
}
std::map <std::string, int>::iterator uda;
for (uda = udas.begin (); uda != udas.end (); ++uda)
for (auto& uda : udas)
{
if (all.find (uda->first) != all.end ())
throw format (STRING_UDA_COLLISION, uda->first);
if (all.find (uda.first) != all.end ())
throw format (STRING_UDA_COLLISION, uda.first);
Column* c = Column::uda (uda->first);
Column* c = Column::uda (uda.first);
all[c->_name] = c;
}
}