Use range-based loops when possible.

This commit is contained in:
Jim Evins
2017-12-30 22:09:48 -05:00
parent 9a135f8971
commit ff003e5b17
8 changed files with 48 additions and 48 deletions
+8 -8
View File
@@ -114,9 +114,9 @@ namespace glbarcode
*/
bool BarcodeCode39::validate( const std::string& rawData )
{
for ( unsigned int i = 0; i < rawData.size(); i++ )
for (char r : rawData)
{
char c = toupper( rawData[i] );
char c = toupper( r );
if ( alphabet.find(c) == std::string::npos )
{
@@ -140,9 +140,9 @@ namespace glbarcode
code += "i";
int sum = 0;
for ( unsigned int i=0; i < cookedData.size(); i++ )
for (char c : cookedData)
{
size_t cValue = alphabet.find( toupper( cookedData[i] ) );
size_t cValue = alphabet.find( toupper( c ) );
code += symbols[cValue];
code += "i";
@@ -170,9 +170,9 @@ namespace glbarcode
{
std::string displayText;
for ( unsigned int i = 0; i < rawData.size(); i++ )
for (char c : rawData)
{
displayText += toupper( rawData[i] );
displayText += toupper( c );
}
return displayText;
@@ -230,11 +230,11 @@ namespace glbarcode
/* Now traverse the code string and draw each bar */
double x1 = xQuiet;
for ( unsigned int i=0; i < codedData.size(); i++ )
for (char c : codedData)
{
double lwidth;
switch ( codedData[i] )
switch ( c )
{
case 'i':