Merge pull request #753 from orbitcowboy/master
Fixed -Wold-style-cast warnings from g++.
This commit is contained in:
34
tinyxml2.cpp
34
tinyxml2.cpp
@@ -101,9 +101,9 @@ distribution.
|
|||||||
#endif
|
#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 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 CR = CARRIAGE_RETURN;
|
||||||
static const char SINGLE_QUOTE = '\'';
|
static const char SINGLE_QUOTE = '\'';
|
||||||
static const char DOUBLE_QUOTE = '\"';
|
static const char DOUBLE_QUOTE = '\"';
|
||||||
@@ -430,22 +430,22 @@ void XMLUtil::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length
|
|||||||
switch (*length) {
|
switch (*length) {
|
||||||
case 4:
|
case 4:
|
||||||
--output;
|
--output;
|
||||||
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
|
*output = static_cast<char>((input | BYTE_MARK) & BYTE_MASK);
|
||||||
input >>= 6;
|
input >>= 6;
|
||||||
//fall through
|
//fall through
|
||||||
case 3:
|
case 3:
|
||||||
--output;
|
--output;
|
||||||
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
|
*output = static_cast<char>((input | BYTE_MARK) & BYTE_MASK);
|
||||||
input >>= 6;
|
input >>= 6;
|
||||||
//fall through
|
//fall through
|
||||||
case 2:
|
case 2:
|
||||||
--output;
|
--output;
|
||||||
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
|
*output = static_cast<char>((input | BYTE_MARK) & BYTE_MASK);
|
||||||
input >>= 6;
|
input >>= 6;
|
||||||
//fall through
|
//fall through
|
||||||
case 1:
|
case 1:
|
||||||
--output;
|
--output;
|
||||||
*output = (char)(input | FIRST_BYTE_MARK[*length]);
|
*output = static_cast<char>(input | FIRST_BYTE_MARK[*length]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
TIXMLASSERT( false );
|
TIXMLASSERT( false );
|
||||||
@@ -585,7 +585,7 @@ void XMLUtil::ToStr( double v, char* buffer, int bufferSize )
|
|||||||
void XMLUtil::ToStr( int64_t v, char* buffer, int bufferSize )
|
void XMLUtil::ToStr( int64_t v, char* buffer, int bufferSize )
|
||||||
{
|
{
|
||||||
// horrible syntax trick to make the compiler happy about %lld
|
// 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));
|
||||||
}
|
}
|
||||||
|
|
||||||
void XMLUtil::ToStr( uint64_t v, char* buffer, int bufferSize )
|
void XMLUtil::ToStr( uint64_t v, char* buffer, int bufferSize )
|
||||||
@@ -658,7 +658,7 @@ bool XMLUtil::ToInt64(const char* str, int64_t* value)
|
|||||||
{
|
{
|
||||||
long long v = 0; // horrible syntax trick to make the compiler happy about %lld
|
long long v = 0; // horrible syntax trick to make the compiler happy about %lld
|
||||||
if (TIXML_SSCANF(str, "%lld", &v) == 1) {
|
if (TIXML_SSCANF(str, "%lld", &v) == 1) {
|
||||||
*value = (int64_t)v;
|
*value = static_cast<int64_t>(v);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -2264,7 +2264,7 @@ template
|
|||||||
struct LongFitsIntoSizeTMinusOne {
|
struct LongFitsIntoSizeTMinusOne {
|
||||||
static bool Fits( unsigned long value )
|
static bool Fits( unsigned long value )
|
||||||
{
|
{
|
||||||
return value < (size_t)-1;
|
return value < static_cast<size_t>(-1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2360,7 +2360,7 @@ XMLError XMLDocument::Parse( const char* p, size_t len )
|
|||||||
SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );
|
SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );
|
||||||
return _errorID;
|
return _errorID;
|
||||||
}
|
}
|
||||||
if ( len == (size_t)(-1) ) {
|
if ( len == static_cast<size_t>(-1) ) {
|
||||||
len = strlen( p );
|
len = strlen( p );
|
||||||
}
|
}
|
||||||
TIXMLASSERT( _charBuffer == 0 );
|
TIXMLASSERT( _charBuffer == 0 );
|
||||||
@@ -2494,13 +2494,13 @@ XMLPrinter::XMLPrinter( FILE* file, bool compact, int depth ) :
|
|||||||
}
|
}
|
||||||
for( int i=0; i<NUM_ENTITIES; ++i ) {
|
for( int i=0; i<NUM_ENTITIES; ++i ) {
|
||||||
const char entityValue = entities[i].value;
|
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 );
|
TIXMLASSERT( flagIndex < ENTITY_RANGE );
|
||||||
_entityFlag[flagIndex] = true;
|
_entityFlag[flagIndex] = true;
|
||||||
}
|
}
|
||||||
_restrictedEntityFlag[(unsigned char)'&'] = true;
|
_restrictedEntityFlag[static_cast<unsigned char>('&')] = true;
|
||||||
_restrictedEntityFlag[(unsigned char)'<'] = true;
|
_restrictedEntityFlag[static_cast<unsigned char>('<')] = true;
|
||||||
_restrictedEntityFlag[(unsigned char)'>'] = true; // not required, but consistency is nice
|
_restrictedEntityFlag[static_cast<unsigned char>('>')] = true; // not required, but consistency is nice
|
||||||
_buffer.Push( 0 );
|
_buffer.Push( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2575,10 +2575,10 @@ void XMLPrinter::PrintString( const char* p, bool restricted )
|
|||||||
// Check for entities. If one is found, flush
|
// Check for entities. If one is found, flush
|
||||||
// the stream up until the entity, write the
|
// the stream up until the entity, write the
|
||||||
// entity, and keep looking.
|
// entity, and keep looking.
|
||||||
if ( flag[(unsigned char)(*q)] ) {
|
if ( flag[static_cast<unsigned char>(*q)] ) {
|
||||||
while ( p < q ) {
|
while ( p < q ) {
|
||||||
const size_t delta = q - p;
|
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 );
|
Write( p, toPrint );
|
||||||
p += toPrint;
|
p += toPrint;
|
||||||
}
|
}
|
||||||
@@ -2606,7 +2606,7 @@ void XMLPrinter::PrintString( const char* p, bool restricted )
|
|||||||
// string if an entity wasn't found.
|
// string if an entity wasn't found.
|
||||||
if ( p < q ) {
|
if ( p < q ) {
|
||||||
const size_t delta = q - p;
|
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 );
|
Write( p, toPrint );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1722,7 +1722,7 @@ public:
|
|||||||
specified, TinyXML-2 will assume 'xml' points to a
|
specified, TinyXML-2 will assume 'xml' points to a
|
||||||
null terminated string.
|
null terminated string.
|
||||||
*/
|
*/
|
||||||
XMLError Parse( const char* xml, size_t nBytes=(size_t)(-1) );
|
XMLError Parse( const char* xml, size_t nBytes=static_cast<size_t>(-1) );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Load an XML file from disk.
|
Load an XML file from disk.
|
||||||
|
|||||||
Reference in New Issue
Block a user