[clang-tidy] Replace C style casts with C++ ones

Found with google-readability-casting

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev
2019-09-27 20:42:34 -07:00
committed by Paul Beckingham
parent 55d103c491
commit 13e1bf7204
14 changed files with 86 additions and 86 deletions

View File

@@ -1181,7 +1181,7 @@ Variant& Variant::operator^= (const Variant& other)
switch (other._type)
{
case type_boolean: throw std::string (STRING_VARIANT_EXP_BOOL);
case type_integer: _integer = (int) pow (static_cast<double>(_integer), static_cast<double>(other._integer)); break;
case type_integer: _integer = static_cast<int>(pow (static_cast<double>(_integer), static_cast<double>(other._integer))); break;
case type_real: throw std::string (STRING_VARIANT_EXP_NON_INT);
case type_string: throw std::string (STRING_VARIANT_EXP_STRING);
case type_date: throw std::string (STRING_VARIANT_EXP_DATE);
@@ -1285,7 +1285,7 @@ Variant& Variant::operator-= (const Variant& other)
{
case type_boolean: right.cast (type_integer); _date -= right._integer; break;
case type_integer: _date -= right._integer; break;
case type_real: _date -= (int) right._real; break;
case type_real: _date -= static_cast<int>(right._real); break;
case type_string: throw std::string (STRING_VARIANT_SUB_STRING);
case type_date: cast (type_duration); _duration -= right._date; break;
case type_duration: _date -= right._duration; break;
@@ -1297,7 +1297,7 @@ Variant& Variant::operator-= (const Variant& other)
{
case type_boolean: right.cast (type_integer); _duration -= right._integer; break;
case type_integer: _duration -= right._integer; break;
case type_real: _duration -= (int) right._real; break;
case type_real: _duration -= static_cast<int>(right._real); break;
case type_string: throw std::string (STRING_VARIANT_SUB_STRING);
case type_date: throw std::string (STRING_VARIANT_SUB_DATE);
case type_duration: _duration -= right._duration; break;
@@ -1367,18 +1367,18 @@ Variant& Variant::operator+= (const Variant& other)
case type_date:
_type = type_date;
_date = (unsigned) (int) _real + right._date;
_date = static_cast<unsigned>(static_cast<int>(_real)) + right._date;
break;
case type_duration:
_type = type_duration;
_duration = (unsigned) (int) _real + right._duration;
_duration = static_cast<unsigned>(static_cast<int>(_real)) + right._duration;
break;
}
break;
case type_string:
_string += (std::string) right;
_string += std::string(right);
break;
case type_date:
@@ -1386,7 +1386,7 @@ Variant& Variant::operator+= (const Variant& other)
{
case type_boolean: right.cast (type_date); _date += right._date; break;
case type_integer: _date += right._integer; break;
case type_real: _date += (int) right._real; break;
case type_real: _date += static_cast<int>(right._real); break;
case type_string: cast (type_string); _string += right._string; break;
case type_date: throw std::string (STRING_VARIANT_ADD_DATE);
case type_duration: _date += right._duration; break;
@@ -1398,7 +1398,7 @@ Variant& Variant::operator+= (const Variant& other)
{
case type_boolean: right.cast (type_duration); _duration += right._duration; break;
case type_integer: _duration += right._integer; break;
case type_real: _duration += (int) right._real; break;
case type_real: _duration += static_cast<int>(right._real); break;
case type_string: cast (type_string); _string += right._string; break;
case type_date: cast (type_date); _date += right._date; break;
case type_duration: _duration += right._duration; break;
@@ -1478,7 +1478,7 @@ Variant& Variant::operator*= (const Variant& other)
case type_duration:
_type = type_duration;
_duration = (time_t) (unsigned) (int) (_real * static_cast<double>(right._duration));
_duration = static_cast<time_t>(static_cast<unsigned>(static_cast<int>(_real * static_cast<double>(right._duration))));
}
break;
@@ -1511,7 +1511,7 @@ Variant& Variant::operator*= (const Variant& other)
case type_boolean: right.cast (type_duration); _duration *= right._duration; break;
case type_integer: _duration *= right._integer; break;
case type_real:
_duration = (time_t) (unsigned) (int) (static_cast<double>(_duration) * right._real);
_duration = static_cast<time_t>(static_cast<unsigned>(static_cast<int>(static_cast<double>(_duration) * right._real)));
break;
case type_string: throw std::string (STRING_VARIANT_MUL_DUR_STR);
case type_date: throw std::string (STRING_VARIANT_MUL_DUR_DATE);
@@ -1571,7 +1571,7 @@ Variant& Variant::operator/= (const Variant& other)
if (right._duration == 0)
throw std::string (STRING_VARIANT_DIV_ZERO);
_type = type_duration;
_duration = (time_t) (unsigned) (int) (_integer / right._duration);
_duration = static_cast<time_t>(static_cast<unsigned>(static_cast<int>(_integer / right._duration)));
break;
}
break;
@@ -1604,7 +1604,7 @@ Variant& Variant::operator/= (const Variant& other)
if (right._duration == 0)
throw std::string (STRING_VARIANT_DIV_ZERO);
_type = type_duration;
_duration = (time_t) (unsigned) (int) (_real / right._duration);
_duration = static_cast<time_t>(static_cast<unsigned>(static_cast<int>(_real / right._duration)));
break;
}
break;
@@ -1631,7 +1631,7 @@ Variant& Variant::operator/= (const Variant& other)
case type_real:
if (right._real == 0)
throw std::string (STRING_VARIANT_DIV_ZERO);
_duration = (time_t) (unsigned) (int) (static_cast<double>(_duration) / right._real);
_duration = static_cast<time_t>(static_cast<unsigned>(static_cast<int>(static_cast<double>(_duration) / right._real)));
break;
case type_string:
@@ -1830,8 +1830,8 @@ void Variant::cast (const enum type new_type)
_string = temp;
}
break;
case type_date: _date = (time_t) _integer; break;
case type_duration: _duration = (time_t) _integer; break;
case type_date: _date = static_cast<time_t>(_integer); break;
case type_duration: _duration = static_cast<time_t>(_integer); break;
}
break;
@@ -1839,7 +1839,7 @@ void Variant::cast (const enum type new_type)
switch (new_type)
{
case type_boolean: _bool = _real == 0.0 ? false : true; break;
case type_integer: _integer = (int) _real; break;
case type_integer: _integer = static_cast<int>(_real); break;
case type_real: break;
case type_string:
{
@@ -1848,8 +1848,8 @@ void Variant::cast (const enum type new_type)
_string = temp;
}
break;
case type_date: _date = (time_t) (int) _real; break;
case type_duration: _duration = (time_t) (int) _real; break;
case type_date: _date = static_cast<time_t>(static_cast<int>(_real)); break;
case type_duration: _duration = static_cast<time_t>(static_cast<int>(_real)); break;
}
break;
@@ -1863,7 +1863,7 @@ void Variant::cast (const enum type new_type)
_string == "0.0") ? false : true;
break;
case type_integer:
_integer = (int) strtol (_string.c_str (), nullptr, (_string.substr (0, 2) == "0x" ? 16 : 10));
_integer = static_cast<int>(strtol (_string.c_str (), nullptr, (_string.substr (0, 2) == "0x" ? 16 : 10)));
break;
case type_real: _real = strtod (_string.c_str (), nullptr); break;
case type_string: break;
@@ -1914,9 +1914,9 @@ void Variant::cast (const enum type new_type)
switch (new_type)
{
case type_boolean: _bool = _date != 0 ? true : false; break;
case type_integer: _integer = (int) _date; break;
case type_integer: _integer = static_cast<int>(_date); break;
case type_real: _real = static_cast<double>(_date); break;
case type_string: _string = (std::string) *this; break;
case type_string: _string = std::string(*this); break;
case type_date: break;
case type_duration: _duration = _date; break;
}
@@ -1926,9 +1926,9 @@ void Variant::cast (const enum type new_type)
switch (new_type)
{
case type_boolean: _bool = _duration != 0 ? true : false; break;
case type_integer: _integer = (int) _duration; break;
case type_integer: _integer = static_cast<int>(_duration); break;
case type_real: _real = static_cast<double>(_duration); break;
case type_string: _string = (std::string) *this; break;
case type_string: _string = std::string(*this); break;
case type_date: _date = _duration; break;
case type_duration: break;
}