C++11
- Converted one source file to use an actual C++11 feature. If no one notices we can move forward and start using supported featues. If it's a problem, this commit gets rolled back. GCC 4.6 (released March 2011), and Clang 3.0 (releasd November 2011) both support N2930 (range-based for) which is the feature being tried here.
This commit is contained in:
@@ -163,29 +163,27 @@ void Command::factory (std::map <std::string, Command*>& all)
|
|||||||
|
|
||||||
// Instantiate a command object for each custom report.
|
// Instantiate a command object for each custom report.
|
||||||
std::vector <std::string> reports;
|
std::vector <std::string> reports;
|
||||||
Config::const_iterator i;
|
for (auto &i : context.config)
|
||||||
for (i = context.config.begin (); i != context.config.end (); ++i)
|
|
||||||
{
|
{
|
||||||
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");
|
std::string::size_type columns = report.find (".columns");
|
||||||
if (columns != std::string::npos)
|
if (columns != std::string::npos)
|
||||||
reports.push_back (report.substr (0, columns));
|
reports.push_back (report.substr (0, columns));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector <std::string>::iterator report;
|
for (auto &report : reports)
|
||||||
for (report = reports.begin (); report != reports.end (); ++report)
|
|
||||||
{
|
{
|
||||||
// Make sure a custom report does not clash with a built-in command.
|
// Make sure a custom report does not clash with a built-in command.
|
||||||
if (all.find (*report) != all.end ())
|
if (all.find (report) != all.end ())
|
||||||
throw format (STRING_CMD_CONFLICT, *report);
|
throw format (STRING_CMD_CONFLICT, report);
|
||||||
|
|
||||||
c = new CmdCustom (
|
c = new CmdCustom (
|
||||||
*report,
|
report,
|
||||||
"task <filter> " + *report,
|
"task <filter> " + report,
|
||||||
context.config.get ("report." + *report + ".description"));
|
context.config.get ("report." + report + ".description"));
|
||||||
|
|
||||||
all[c->keyword ()] = c;
|
all[c->keyword ()] = c;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user