C++11: Cleaned up commands code with range-based for
This commit is contained in:
@@ -51,12 +51,11 @@ int CmdReports::execute (std::string& output)
|
||||
std::vector <std::string> reports;
|
||||
|
||||
// Add custom reports.
|
||||
Config::const_iterator i;
|
||||
for (i = context.config.begin (); i != context.config.end (); ++i)
|
||||
for (auto& i : context.config)
|
||||
{
|
||||
if (i->first.substr (0, 7) == "report.")
|
||||
if (i.first.substr (0, 7) == "report.")
|
||||
{
|
||||
std::string report = i->first.substr (7);
|
||||
std::string report = i.first.substr (7);
|
||||
std::string::size_type columns = report.find (".columns");
|
||||
if (columns != std::string::npos)
|
||||
reports.push_back (report.substr (0, columns));
|
||||
@@ -96,12 +95,11 @@ int CmdReports::execute (std::string& output)
|
||||
view.intraColorOdd (alternate);
|
||||
}
|
||||
|
||||
std::vector <std::string>::iterator report;
|
||||
for (report = reports.begin (); report != reports.end (); ++report)
|
||||
for (auto& report : reports)
|
||||
{
|
||||
int row = view.addRow ();
|
||||
view.set (row, 0, *report);
|
||||
view.set (row, 1, context.commands[*report]->description ());
|
||||
view.set (row, 0, report);
|
||||
view.set (row, 1, context.commands[report]->description ());
|
||||
}
|
||||
|
||||
out << optionalBlankLine ()
|
||||
|
||||
Reference in New Issue
Block a user