Code Cleanup

- Removed many more uses of the 'foreach' macro.
This commit is contained in:
Paul Beckingham 2011-06-04 23:02:18 -04:00
parent f9c1820740
commit 61e549c80c
5 changed files with 32 additions and 15 deletions

View file

@ -164,7 +164,8 @@ int Context::run ()
// Dump all debug messages, controlled by rc.debug.
if (config.getBoolean ("debug"))
{
foreach (d, debugMessages)
std::vector <std::string>::iterator d;
for (d = debugMessages.begin (); d != debugMessages.end (); ++d)
if (color ())
std::cout << colorizeDebug (*d) << "\n";
else
@ -175,22 +176,28 @@ int Context::run ()
// Dump all headers, controlled by 'header' verbosity token.
if (verbose ("header"))
foreach (h, headers)
{
std::vector <std::string>::iterator h;
for (h = headers.begin (); h != headers.end (); ++h)
if (color ())
std::cout << colorizeHeader (*h) << "\n";
else
std::cout << *h << "\n";
}
// Dump the report output.
std::cout << output;
// Dump all footnotes, controlled by 'footnote' verbosity token.
if (verbose ("footnote"))
foreach (f, footnotes)
{
std::vector <std::string>::iterator f;
for (f = footnotes.begin (); f != footnotes.end (); ++f)
if (color ())
std::cout << colorizeFootnote (*f) << "\n";
else
std::cout << *f << "\n";
}
hooks.trigger ("on-exit");
return rc;
@ -453,7 +460,8 @@ void Context::autoFilter (Att& a, Filter& f)
{
std::vector <std::string> words;
split (words, a.value (), ' ');
foreach (word, words)
std::vector <std::string>::iterator word;
for (word = words.begin (); word != words.end (); ++word)
{
f.push_back (Att ("description", "has", *word));
debug ("auto filter: " + a.name () + ".has:" + *word);
@ -537,14 +545,15 @@ void Context::autoFilter (Filter& f)
// modifiers. See bug #293.
// Include tagAdditions.
foreach (tag, tagAdditions)
std::vector <std::string>::iterator tag;
for (tag = tagAdditions.begin (); tag != tagAdditions.end (); ++tag)
{
f.push_back (Att ("tags", "word", *tag));
debug ("auto filter: +" + *tag);
}
// Include tagRemovals.
foreach (tag, tagRemovals)
for (tag = tagRemovals.begin (); tag != tagRemovals.end (); ++tag)
{
f.push_back (Att ("tags", "noword", *tag));
debug ("auto filter: -" + *tag);

View file

@ -78,7 +78,8 @@ bool Task::operator== (const Task& other)
if (size () != other.size ())
return false;
foreach (att, *this)
std::map <std::string, Att>::iterator att;
for (att = this->begin (); att != this->end (); ++att)
if (att->second.name () != "uuid")
if (att->second.value () != other.get (att->second.name ()))
return false;
@ -423,14 +424,16 @@ std::string Task::composeYAML () const
// Only include non-trivial attributes.
std::string value;
foreach (name, names)
std::vector <std::string>::iterator name;
for (name = names.begin (); name != names.end (); ++name)
if ((value = get (*name)) != "")
out << " " << *name << ": " << value << "\n";
// Now the annotations, which are not listed by the Att::allNames call.
std::vector <Att> annotations;
getAnnotations (annotations);
foreach (a, annotations)
std::vector <Att>::iterator a;
for (a = annotations.begin (); a != annotations.end (); ++a)
out << " annotation:\n"
<< " entry: " << a->name().substr (11) << "\n"
<< " description: " << a->value () << "\n";
@ -1045,7 +1048,8 @@ float Task::urgency ()
std::vector <std::string> all;
context.config.all (all);
foreach (var, all)
std::vector <std::string>::iterator var;
for (var = all.begin (); var != all.end (); ++var)
{
if (var->substr (0, 13) == "urgency.user.")
{

View file

@ -121,11 +121,11 @@ void TransportCurl::recv(std::string target)
split (splitted, toSplit.substr(0, pos), ',');
target = "";
foreach (file, splitted)
{
std::vector <std::string>::iterator file;
for (file = splitted.begin (); file != splitted.end (); ++file)
target += " -o " + prefix + *file + suffix;
}
}
else
{
target = "-o " + target;

View file

@ -93,7 +93,8 @@ int CmdLog::execute (std::string& output)
}
// Include tags.
foreach (tag, context.tagAdditions)
std::vector <std::string>::iterator tag;
for (tag = tagAdditions.begin 90; tag != tagAdditions.end (); ++tag)
context.task.addTag (*tag);
// Only valid tasks can be added.

View file

@ -85,7 +85,9 @@ std::string getFullDescription (Task& task, const std::string& report)
desc += "\n" + when + " " + anno.value ();
}
else
foreach (anno, annotations)
{
std::vector <Att>::iterator anno;
for (anno = annotations.begin (); anno != annotations.end (); ++anno)
{
Date dt (atoi (anno->name ().substr (11).c_str ()));
std::string format = context.config.get ("dateformat.annotation");
@ -95,6 +97,7 @@ std::string getFullDescription (Task& task, const std::string& report)
desc += "\n" + when + " " + anno->value ();
}
}
}
return desc;
}