Code Cleanup
- Further attemps at removing 'foreach'.
This commit is contained in:
15
src/Cmd.cpp
15
src/Cmd.cpp
@@ -185,7 +185,8 @@ void Cmd::load ()
|
|||||||
std::vector <std::string> all;
|
std::vector <std::string> all;
|
||||||
context.config.all (all);
|
context.config.all (all);
|
||||||
|
|
||||||
foreach (i, all)
|
std::vector <std::string>::iterator i;
|
||||||
|
for (i = all.begin (); i != all.end (); ++i)
|
||||||
{
|
{
|
||||||
if (i->substr (0, 7) == "report.")
|
if (i->substr (0, 7) == "report.")
|
||||||
{
|
{
|
||||||
@@ -209,8 +210,9 @@ void Cmd::load ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now load the aliases.
|
// Now load the aliases.
|
||||||
foreach (i, context.aliases)
|
std::map <std::string, std::string>::iterator it;
|
||||||
commands.push_back (i->first);
|
for (it = context.aliases.begin (); it != context.aliases.end (); ++it)
|
||||||
|
commands.push_back (it->first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,9 +226,10 @@ void Cmd::allCustomReports (std::vector <std::string>& all) const
|
|||||||
void Cmd::allCommands (std::vector <std::string>& all) const
|
void Cmd::allCommands (std::vector <std::string>& all) const
|
||||||
{
|
{
|
||||||
all.clear ();
|
all.clear ();
|
||||||
foreach (command, commands)
|
std::vector <std::string>::const_iterator c;
|
||||||
if (command->substr (0, 1) != "_")
|
for (c = commands.begin (); c != commands.end (); ++c)
|
||||||
all.push_back (*command);
|
if (c->substr (0, 1) != "_")
|
||||||
|
all.push_back (*c);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -59,7 +59,8 @@ void handleRecurrence ()
|
|||||||
std::vector <Task> modified;
|
std::vector <Task> modified;
|
||||||
|
|
||||||
// Look at all tasks and find any recurring ones.
|
// Look at all tasks and find any recurring ones.
|
||||||
foreach (t, tasks)
|
std::vector <Task>::iterator t;
|
||||||
|
for (t = tasks.begin (); t != tasks.end (); ++t)
|
||||||
{
|
{
|
||||||
if (t->getStatus () == Task::recurring)
|
if (t->getStatus () == Task::recurring)
|
||||||
{
|
{
|
||||||
@@ -87,7 +88,8 @@ void handleRecurrence ()
|
|||||||
// Iterate over the due dates, and check each against the mask.
|
// Iterate over the due dates, and check each against the mask.
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
foreach (d, due)
|
std::vector <Date>::iterator d;
|
||||||
|
for (d = due.begin (); d != due.end (); ++d)
|
||||||
{
|
{
|
||||||
if (mask.length () <= i)
|
if (mask.length () <= i)
|
||||||
{
|
{
|
||||||
@@ -453,7 +455,8 @@ bool nag (Task& task)
|
|||||||
char pri = ' ';
|
char pri = ' ';
|
||||||
|
|
||||||
// Scan all pending tasks.
|
// Scan all pending tasks.
|
||||||
foreach (t, tasks)
|
std::vector <Task>::iterator t;
|
||||||
|
for (t = tasks.begin (); t != tasks.end (); ++t)
|
||||||
{
|
{
|
||||||
if (t->id == task.id)
|
if (t->id == task.id)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -400,7 +400,8 @@ int handleInfo (std::string& outs)
|
|||||||
|
|
||||||
// Find the task.
|
// Find the task.
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
foreach (task, tasks)
|
std::vector <Task>::iterator task;
|
||||||
|
for (task = tasks.begin (); task != tasks.end (); ++task)
|
||||||
{
|
{
|
||||||
Table table;
|
Table table;
|
||||||
table.setTableWidth (context.getWidth ());
|
table.setTableWidth (context.getWidth ());
|
||||||
@@ -776,7 +777,8 @@ int handleReportSummary (std::string& outs)
|
|||||||
|
|
||||||
// Generate unique list of project names from all pending tasks.
|
// Generate unique list of project names from all pending tasks.
|
||||||
std::map <std::string, bool> allProjects;
|
std::map <std::string, bool> allProjects;
|
||||||
foreach (task, tasks)
|
std::vector <Task>::iterator task;
|
||||||
|
for (task = tasks.begin (); task != tasks.end (); ++task)
|
||||||
if (task->getStatus () == Task::pending)
|
if (task->getStatus () == Task::pending)
|
||||||
allProjects[task->get ("project")] = false;
|
allProjects[task->get ("project")] = false;
|
||||||
|
|
||||||
@@ -797,7 +799,7 @@ int handleReportSummary (std::string& outs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Count the various tasks.
|
// Count the various tasks.
|
||||||
foreach (task, tasks)
|
for (task = tasks.begin (); task != tasks.end (); ++task)
|
||||||
{
|
{
|
||||||
std::string project = task->get ("project");
|
std::string project = task->get ("project");
|
||||||
++counter[project];
|
++counter[project];
|
||||||
@@ -984,7 +986,8 @@ int handleReportTimesheet (std::string& outs)
|
|||||||
completed.setColumnJustification (2, Table::right);
|
completed.setColumnJustification (2, Table::right);
|
||||||
completed.setColumnJustification (3, Table::left);
|
completed.setColumnJustification (3, Table::left);
|
||||||
|
|
||||||
foreach (task, tasks)
|
std::vector <Task>::iterator task;
|
||||||
|
for (task = tasks.begin (); task != tasks.end (); ++task)
|
||||||
{
|
{
|
||||||
// If task completed within range.
|
// If task completed within range.
|
||||||
if (task->getStatus () == Task::completed)
|
if (task->getStatus () == Task::completed)
|
||||||
@@ -1042,7 +1045,7 @@ int handleReportTimesheet (std::string& outs)
|
|||||||
started.setColumnJustification (1, Table::left);
|
started.setColumnJustification (1, Table::left);
|
||||||
started.setColumnJustification (2, Table::right);
|
started.setColumnJustification (2, Table::right);
|
||||||
started.setColumnJustification (3, Table::left);
|
started.setColumnJustification (3, Table::left);
|
||||||
foreach (task, tasks)
|
for (task = tasks.begin (); task != tasks.end (); ++task)
|
||||||
{
|
{
|
||||||
// If task started within range, but not completed withing range.
|
// If task started within range, but not completed withing range.
|
||||||
if (task->getStatus () == Task::pending &&
|
if (task->getStatus () == Task::pending &&
|
||||||
@@ -1443,7 +1446,8 @@ int handleReportCalendar (std::string& outs)
|
|||||||
if (getpendingdate == true) {
|
if (getpendingdate == true) {
|
||||||
// Find the oldest pending due date.
|
// Find the oldest pending due date.
|
||||||
Date oldest (12,31,2037);
|
Date oldest (12,31,2037);
|
||||||
foreach (task, tasks)
|
std::vector <Task>::iterator task;
|
||||||
|
for (task = tasks.begin (); task != tasks.end (); ++task)
|
||||||
{
|
{
|
||||||
if (task->getStatus () == Task::pending)
|
if (task->getStatus () == Task::pending)
|
||||||
{
|
{
|
||||||
@@ -1931,7 +1935,8 @@ void gatherNextTasks (std::vector <Task>& tasks)
|
|||||||
int limit = context.config.getInteger ("next");
|
int limit = context.config.getInteger ("next");
|
||||||
|
|
||||||
// due:< 1wk, pri:*
|
// due:< 1wk, pri:*
|
||||||
foreach (task, tasks)
|
std::vector <Task>::iterator task;
|
||||||
|
for (task = tasks.begin (); task != tasks.end (); ++task)
|
||||||
{
|
{
|
||||||
if (task->has ("due"))
|
if (task->has ("due"))
|
||||||
{
|
{
|
||||||
@@ -1950,7 +1955,7 @@ void gatherNextTasks (std::vector <Task>& tasks)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// blocking, not blocked
|
// blocking, not blocked
|
||||||
foreach (task, tasks)
|
for (task = tasks.begin (); task != tasks.end (); ++task)
|
||||||
{
|
{
|
||||||
if (dependencyIsBlocking (*task) &&
|
if (dependencyIsBlocking (*task) &&
|
||||||
! dependencyIsBlocked (*task))
|
! dependencyIsBlocked (*task))
|
||||||
@@ -1966,7 +1971,7 @@ void gatherNextTasks (std::vector <Task>& tasks)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// due:*, pri:H
|
// due:*, pri:H
|
||||||
foreach (task, tasks)
|
for (task = tasks.begin (); task != tasks.end (); ++task)
|
||||||
{
|
{
|
||||||
if (task->has ("due"))
|
if (task->has ("due"))
|
||||||
{
|
{
|
||||||
@@ -1985,7 +1990,7 @@ void gatherNextTasks (std::vector <Task>& tasks)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// pri:H
|
// pri:H
|
||||||
foreach (task, tasks)
|
for (task = tasks.begin (); task != tasks.end (); ++task)
|
||||||
{
|
{
|
||||||
std::string priority = task->get ("priority");
|
std::string priority = task->get ("priority");
|
||||||
if (priority == "H")
|
if (priority == "H")
|
||||||
@@ -2001,7 +2006,7 @@ void gatherNextTasks (std::vector <Task>& tasks)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// due:*, pri:M
|
// due:*, pri:M
|
||||||
foreach (task, tasks)
|
for (task = tasks.begin (); task != tasks.end (); ++task)
|
||||||
{
|
{
|
||||||
if (task->has ("due"))
|
if (task->has ("due"))
|
||||||
{
|
{
|
||||||
@@ -2020,7 +2025,7 @@ void gatherNextTasks (std::vector <Task>& tasks)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// pri:M
|
// pri:M
|
||||||
foreach (task, tasks)
|
for (task = tasks.begin (); task != tasks.end (); ++task)
|
||||||
{
|
{
|
||||||
std::string priority = task->get ("priority");
|
std::string priority = task->get ("priority");
|
||||||
if (priority == "M")
|
if (priority == "M")
|
||||||
@@ -2036,7 +2041,7 @@ void gatherNextTasks (std::vector <Task>& tasks)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// due:*, pri:L
|
// due:*, pri:L
|
||||||
foreach (task, tasks)
|
for (task = tasks.begin (); task != tasks.end (); ++task)
|
||||||
{
|
{
|
||||||
if (task->has ("due"))
|
if (task->has ("due"))
|
||||||
{
|
{
|
||||||
@@ -2055,7 +2060,7 @@ void gatherNextTasks (std::vector <Task>& tasks)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// pri:L
|
// pri:L
|
||||||
foreach (task, tasks)
|
for (task = tasks.begin (); task != tasks.end (); ++task)
|
||||||
{
|
{
|
||||||
std::string priority = task->get ("priority");
|
std::string priority = task->get ("priority");
|
||||||
if (priority == "L")
|
if (priority == "L")
|
||||||
@@ -2071,7 +2076,7 @@ void gatherNextTasks (std::vector <Task>& tasks)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// due:, pri:
|
// due:, pri:
|
||||||
foreach (task, tasks)
|
for (task = tasks.begin (); task != tasks.end (); ++task)
|
||||||
{
|
{
|
||||||
if (task->has ("due"))
|
if (task->has ("due"))
|
||||||
{
|
{
|
||||||
@@ -2090,7 +2095,7 @@ void gatherNextTasks (std::vector <Task>& tasks)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Filler.
|
// Filler.
|
||||||
foreach (task, tasks)
|
for (task = tasks.begin (); task != tasks.end (); ++task)
|
||||||
{
|
{
|
||||||
std::string project = task->get ("project");
|
std::string project = task->get ("project");
|
||||||
if (countByProject[project] < limit && matching.find (task->id) == matching.end ())
|
if (countByProject[project] < limit && matching.find (task->id) == matching.end ())
|
||||||
|
|||||||
@@ -189,7 +189,8 @@ int autoComplete (
|
|||||||
unsigned int length = partial.length ();
|
unsigned int length = partial.length ();
|
||||||
if (length)
|
if (length)
|
||||||
{
|
{
|
||||||
foreach (item, list)
|
std::vector <std::string>::const_iterator item;
|
||||||
|
for (item = list.begin (); item != list.end (); ++item)
|
||||||
{
|
{
|
||||||
// An exact match is a special case. Assume there is only one exact match
|
// An exact match is a special case. Assume there is only one exact match
|
||||||
// and return immediately.
|
// and return immediately.
|
||||||
|
|||||||
Reference in New Issue
Block a user