C++11: Cleaned up program framework with range-based for

This commit is contained in:
Paul Beckingham 2015-05-11 17:50:53 -04:00
parent 5a57dfd70d
commit e74c6963a9
28 changed files with 937 additions and 1221 deletions

View file

@ -119,10 +119,9 @@ Color::Color (const std::string& spec)
bool bg = false;
int index;
std::string word;
std::vector <std::string>::iterator it;
for (it = words.begin (); it != words.end (); ++it)
for (auto& it : words)
{
word = lowerCase (trim (*it));
word = lowerCase (trim (it));
if (word == "bold") fg_value |= _COLOR_BOLD;
else if (word == "bright") bg_value |= _COLOR_BRIGHT;
@ -154,7 +153,7 @@ Color::Color (const std::string& spec)
{
index = atoi (word.substr (4).c_str ());
if (index < 0 || index > 23)
throw format (STRING_COLOR_UNRECOGNIZED, *it);
throw format (STRING_COLOR_UNRECOGNIZED, it);
if (bg)
{
@ -176,7 +175,7 @@ Color::Color (const std::string& spec)
index = atoi (word.substr (3).c_str ());
if (word.length () != 6 ||
index < 0 || index > 555)
throw format (STRING_COLOR_UNRECOGNIZED, *it);
throw format (STRING_COLOR_UNRECOGNIZED, it);
int r = atoi (word.substr (3, 1).c_str ());
int g = atoi (word.substr (4, 1).c_str ());
@ -184,7 +183,7 @@ Color::Color (const std::string& spec)
if (r < 0 || r > 5 ||
g < 0 || g > 5 ||
b < 0 || b > 5)
throw format (STRING_COLOR_UNRECOGNIZED, *it);
throw format (STRING_COLOR_UNRECOGNIZED, it);
index = 16 + r*36 + g*6 + b;
@ -207,7 +206,7 @@ Color::Color (const std::string& spec)
{
index = atoi (word.substr (5).c_str ());
if (index < 0 || index > 255)
throw format (STRING_COLOR_UNRECOGNIZED, *it);
throw format (STRING_COLOR_UNRECOGNIZED, it);
upgrade ();
@ -225,7 +224,7 @@ Color::Color (const std::string& spec)
}
}
else if (word != "")
throw format (STRING_COLOR_UNRECOGNIZED, *it);
throw format (STRING_COLOR_UNRECOGNIZED, it);
}
// Now combine the fg and bg into a single color.