Handle exceptions in int conversions (#2092)

* RageUtil: Add exception-safe wrappers around std::stoi, stol, stoll

* Replace use of std::stoi with exception-safe StringToInt
This commit is contained in:
Gareth Francis
2021-02-15 20:36:51 +00:00
committed by GitHub
parent c7c54bb013
commit aeb5c7598f
25 changed files with 124 additions and 73 deletions
+2 -2
View File
@@ -50,9 +50,9 @@ void XNode::Free()
}
void XNodeStringValue::GetValue( RString &out ) const { out = m_sValue; }
void XNodeStringValue::GetValue( int &out ) const { out = std::stoi(m_sValue); }
void XNodeStringValue::GetValue( int &out ) const { out = StringToInt(m_sValue); }
void XNodeStringValue::GetValue( float &out ) const { out = StringToFloat(m_sValue); }
void XNodeStringValue::GetValue( bool &out ) const { out = std::stoi(m_sValue) != 0; }
void XNodeStringValue::GetValue( bool &out ) const { out = StringToInt(m_sValue) != 0; }
void XNodeStringValue::GetValue( unsigned &out ) const { out = strtoul(m_sValue,nullptr,0); }
void XNodeStringValue::PushValue( lua_State *L ) const
{