Use range-based loops when possible.
This commit is contained in:
@@ -43,9 +43,9 @@ namespace glabels
|
||||
|
||||
bool Base::isAscii( const std::string& data ) const
|
||||
{
|
||||
for ( unsigned int i = 0; i < data.size(); i++ )
|
||||
for (char c : data)
|
||||
{
|
||||
if ( (data[i] & 0x80) != 0 )
|
||||
if ( (c & 0x80) != 0 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -61,9 +61,9 @@ namespace glabels
|
||||
{
|
||||
unsigned int n = 0;
|
||||
|
||||
for ( unsigned int i = 0; i < data.size(); i++ )
|
||||
for (char c : data)
|
||||
{
|
||||
if ( isdigit(data[i]) )
|
||||
if ( isdigit(c) )
|
||||
{
|
||||
n++;
|
||||
}
|
||||
|
||||
@@ -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':
|
||||
|
||||
@@ -78,9 +78,9 @@ namespace glbarcode
|
||||
*/
|
||||
bool BarcodeCode39Ext::validate( const std::string& rawData )
|
||||
{
|
||||
for ( unsigned int i = 0; i < rawData.size(); i++ )
|
||||
for (char c : rawData)
|
||||
{
|
||||
if ( (rawData[i] < 0) || (rawData[i] > 0x7F) )
|
||||
if ( (c < 0) || (c > 0x7F) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -97,9 +97,9 @@ namespace glbarcode
|
||||
{
|
||||
std::string cookedData;
|
||||
|
||||
for ( unsigned int i = 0; i < rawData.size(); i++ )
|
||||
for (char c : rawData)
|
||||
{
|
||||
cookedData += asciiMap[ int(rawData[i]) ];
|
||||
cookedData += asciiMap[ int(c) ];
|
||||
}
|
||||
|
||||
return cookedData;
|
||||
|
||||
@@ -61,11 +61,11 @@ namespace glbarcode
|
||||
{
|
||||
std::string cookedData;
|
||||
|
||||
for ( unsigned int i = 0; i < rawData.size(); i++ )
|
||||
for (char c : rawData)
|
||||
{
|
||||
if ( isdigit( rawData[i] ) )
|
||||
if ( isdigit( c ) )
|
||||
{
|
||||
cookedData += rawData[i];
|
||||
cookedData += c;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -300,9 +300,9 @@ namespace
|
||||
public:
|
||||
Int104( )
|
||||
{
|
||||
for ( int i = 0; i < 13; i++ )
|
||||
for (unsigned char& c : mByteArray)
|
||||
{
|
||||
mByteArray[i] = 0;
|
||||
c = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -334,11 +334,11 @@ namespace
|
||||
uint32_t divUint( uint32_t y )
|
||||
{
|
||||
uint32_t carry = 0;
|
||||
for ( int i = 0; i < 13; i++ )
|
||||
for (unsigned char& c : mByteArray)
|
||||
{
|
||||
uint32_t temp = mByteArray[i] + (carry << 8);
|
||||
uint32_t temp = c + (carry << 8);
|
||||
|
||||
mByteArray[i] = (uint8_t)(temp / y);
|
||||
c = (uint8_t)(temp / y);
|
||||
carry = temp % y;
|
||||
}
|
||||
return carry;
|
||||
@@ -375,9 +375,9 @@ namespace glbarcode
|
||||
return false;
|
||||
}
|
||||
|
||||
for ( unsigned int i = 0; i < rawData.size(); i++ )
|
||||
for (char c : rawData)
|
||||
{
|
||||
if ( !isdigit( rawData[i] ) )
|
||||
if ( !isdigit( c ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -493,10 +493,10 @@ namespace glbarcode
|
||||
/*-----------------------------------------------------------*/
|
||||
std::string code;
|
||||
|
||||
for ( int i = 0; i < 65; i++ )
|
||||
for (auto b : barMap)
|
||||
{
|
||||
int d = (character[ barMap[i].descender.i ] & barMap[i].descender.mask) != 0 ? 1 : 0;
|
||||
int a = (character[ barMap[i].ascender.i ] & barMap[i].ascender.mask) != 0 ? 1 : 0;
|
||||
int d = (character[ b.descender.i ] & b.descender.mask) != 0 ? 1 : 0;
|
||||
int a = (character[ b.ascender.i ] & b.ascender.mask) != 0 ? 1 : 0;
|
||||
|
||||
code += tdafTable[ (a<<1) + d ];
|
||||
}
|
||||
@@ -516,12 +516,12 @@ namespace glbarcode
|
||||
double& h )
|
||||
{
|
||||
double x = ONECODE_HORIZ_MARGIN;
|
||||
for ( unsigned int i = 0; i < codedData.size(); i++ )
|
||||
for (char c : codedData)
|
||||
{
|
||||
double y = ONECODE_VERT_MARGIN;
|
||||
double length = 0;
|
||||
|
||||
switch ( codedData[i] )
|
||||
switch ( c )
|
||||
{
|
||||
case 'T':
|
||||
y += ONECODE_TRACKER_OFFSET;
|
||||
|
||||
@@ -91,13 +91,13 @@ namespace glbarcode
|
||||
bool BarcodePostnet::validate( const std::string& rawData )
|
||||
{
|
||||
int nDigits = 0;
|
||||
for ( unsigned int i = 0; i < rawData.size(); i++ )
|
||||
for (char c : rawData)
|
||||
{
|
||||
if ( isdigit( rawData[i] ) )
|
||||
if ( isdigit( c ) )
|
||||
{
|
||||
nDigits++;
|
||||
}
|
||||
else if ( (rawData[i] != '-') && (rawData[i] != ' ') )
|
||||
else if ( (c != '-') && (c != ' ') )
|
||||
{
|
||||
/* Only allow digits, dashes, and spaces. */
|
||||
return false;
|
||||
@@ -120,12 +120,12 @@ namespace glbarcode
|
||||
|
||||
/* process each digit, adding approptiate symbol */
|
||||
int sum = 0;
|
||||
for ( unsigned int i = 0; i < cookedData.size(); i++ )
|
||||
for (char c : cookedData)
|
||||
{
|
||||
if ( isdigit( cookedData[i] ) )
|
||||
if ( isdigit( c ) )
|
||||
{
|
||||
/* Only translate the digits (0-9) */
|
||||
int d = cookedData[i] - '0';
|
||||
int d = c - '0';
|
||||
code += symbols[d];
|
||||
sum += d;
|
||||
}
|
||||
@@ -151,12 +151,12 @@ namespace glbarcode
|
||||
double& h )
|
||||
{
|
||||
double x = POSTNET_HORIZ_MARGIN;
|
||||
for ( unsigned int i=0; i < codedData.size(); i++ )
|
||||
for (char c : codedData)
|
||||
{
|
||||
double y = POSTNET_VERT_MARGIN;
|
||||
|
||||
double length = 0;
|
||||
switch ( codedData[i] )
|
||||
switch ( c )
|
||||
{
|
||||
case '0':
|
||||
y += POSTNET_FULLBAR_HEIGHT - POSTNET_HALFBAR_HEIGHT;
|
||||
|
||||
@@ -61,11 +61,11 @@ namespace glbarcode
|
||||
{
|
||||
std::string cookedData;
|
||||
|
||||
for ( unsigned int i = 0; i < rawData.size(); i++ )
|
||||
for (char c : rawData)
|
||||
{
|
||||
if ( isdigit( rawData[i] ) )
|
||||
if ( isdigit( c ) )
|
||||
{
|
||||
cookedData += rawData[i];
|
||||
cookedData += c;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -99,13 +99,13 @@ namespace glbarcode
|
||||
{
|
||||
int nDigits = 0;
|
||||
|
||||
for ( unsigned int i = 0; i < rawData.size(); i++ )
|
||||
for (char c : rawData)
|
||||
{
|
||||
if ( isdigit( rawData[i] ) )
|
||||
if ( isdigit( c ) )
|
||||
{
|
||||
nDigits++;
|
||||
}
|
||||
else if ( rawData[i] != ' ')
|
||||
else if ( c != ' ')
|
||||
{
|
||||
/* Only allow digits and spaces -- ignoring spaces. */
|
||||
return false;
|
||||
@@ -192,11 +192,11 @@ namespace glbarcode
|
||||
{
|
||||
std::string displayText;
|
||||
|
||||
for ( unsigned int i = 0; i < rawData.size(); i++ )
|
||||
for (char c : rawData)
|
||||
{
|
||||
if ( isdigit( rawData[i] ) )
|
||||
if ( isdigit( c ) )
|
||||
{
|
||||
displayText += rawData[i];
|
||||
displayText += c;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user