Fixed -Wold-style-cast warnings from g++.
diff --git a/tinyxml2.cpp b/tinyxml2.cpp
index 1c74279..091efce 100755
--- a/tinyxml2.cpp
+++ b/tinyxml2.cpp
@@ -101,9 +101,9 @@
#endif
-static const char LINE_FEED = (char)0x0a; // all line endings are normalized to LF
+static const char LINE_FEED = static_cast<char>(0x0a); // all line endings are normalized to LF
static const char LF = LINE_FEED;
-static const char CARRIAGE_RETURN = (char)0x0d; // CR gets filtered out
+static const char CARRIAGE_RETURN = static_cast<char>(0x0d); // CR gets filtered out
static const char CR = CARRIAGE_RETURN;
static const char SINGLE_QUOTE = '\'';
static const char DOUBLE_QUOTE = '\"';
@@ -430,22 +430,22 @@
switch (*length) {
case 4:
--output;
- *output = (char)((input | BYTE_MARK) & BYTE_MASK);
+ *output = static_cast<char>((input | BYTE_MARK) & BYTE_MASK);
input >>= 6;
//fall through
case 3:
--output;
- *output = (char)((input | BYTE_MARK) & BYTE_MASK);
+ *output = static_cast<char>((input | BYTE_MARK) & BYTE_MASK);
input >>= 6;
//fall through
case 2:
--output;
- *output = (char)((input | BYTE_MARK) & BYTE_MASK);
+ *output = static_cast<char>((input | BYTE_MARK) & BYTE_MASK);
input >>= 6;
//fall through
case 1:
--output;
- *output = (char)(input | FIRST_BYTE_MARK[*length]);
+ *output = static_cast<char>(input | FIRST_BYTE_MARK[*length]);
break;
default:
TIXMLASSERT( false );
@@ -585,7 +585,7 @@
void XMLUtil::ToStr(int64_t v, char* buffer, int bufferSize)
{
// horrible syntax trick to make the compiler happy about %lld
- TIXML_SNPRINTF(buffer, bufferSize, "%lld", (long long)v);
+ TIXML_SNPRINTF(buffer, bufferSize, "%lld", static_cast<long long>(v));
}
@@ -646,7 +646,7 @@
{
long long v = 0; // horrible syntax trick to make the compiler happy about %lld
if (TIXML_SSCANF(str, "%lld", &v) == 1) {
- *value = (int64_t)v;
+ *value = static_cast<int64_t>(v);
return true;
}
return false;
@@ -2194,7 +2194,7 @@
struct LongFitsIntoSizeTMinusOne {
static bool Fits( unsigned long value )
{
- return value < (size_t)-1;
+ return value < static_cast<size_t>(-1);
}
};
@@ -2290,7 +2290,7 @@
SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );
return _errorID;
}
- if ( len == (size_t)(-1) ) {
+ if ( len == static_cast<size_t>(-1) ) {
len = strlen( p );
}
TIXMLASSERT( _charBuffer == 0 );
@@ -2424,13 +2424,13 @@
}
for( int i=0; i<NUM_ENTITIES; ++i ) {
const char entityValue = entities[i].value;
- const unsigned char flagIndex = (unsigned char)entityValue;
+ const unsigned char flagIndex = static_cast<unsigned char>(entityValue);
TIXMLASSERT( flagIndex < ENTITY_RANGE );
_entityFlag[flagIndex] = true;
}
- _restrictedEntityFlag[(unsigned char)'&'] = true;
- _restrictedEntityFlag[(unsigned char)'<'] = true;
- _restrictedEntityFlag[(unsigned char)'>'] = true; // not required, but consistency is nice
+ _restrictedEntityFlag[static_cast<unsigned char>('&')] = true;
+ _restrictedEntityFlag[static_cast<unsigned char>('<')] = true;
+ _restrictedEntityFlag[static_cast<unsigned char>('>')] = true; // not required, but consistency is nice
_buffer.Push( 0 );
}
@@ -2505,10 +2505,10 @@
// Check for entities. If one is found, flush
// the stream up until the entity, write the
// entity, and keep looking.
- if ( flag[(unsigned char)(*q)] ) {
+ if ( flag[static_cast<unsigned char>(*q)] ) {
while ( p < q ) {
const size_t delta = q - p;
- const int toPrint = ( INT_MAX < delta ) ? INT_MAX : (int)delta;
+ const int toPrint = ( INT_MAX < delta ) ? INT_MAX : static_cast<int>(delta);
Write( p, toPrint );
p += toPrint;
}
@@ -2536,7 +2536,7 @@
// string if an entity wasn't found.
if ( p < q ) {
const size_t delta = q - p;
- const int toPrint = ( INT_MAX < delta ) ? INT_MAX : (int)delta;
+ const int toPrint = ( INT_MAX < delta ) ? INT_MAX : static_cast<int>(delta);
Write( p, toPrint );
}
}