Replace 'atoi' with the C++11 equivalent: 'stoi'.

This commit is contained in:
Stephen Anthony 2019-12-24 17:58:46 -03:30
parent eeb8363df6
commit 198ab08647
6 changed files with 12 additions and 12 deletions

View File

@ -113,7 +113,7 @@ Console::Console(OSystem& osystem, unique_ptr<Cartridge>& cart,
myCart->setStartBankFromPropsFunc([this]() { myCart->setStartBankFromPropsFunc([this]() {
const string& startbank = myProperties.get(PropType::Cart_StartBank); const string& startbank = myProperties.get(PropType::Cart_StartBank);
return (startbank == EmptyString || BSPF::equalsIgnoreCase(startbank, "AUTO")) return (startbank == EmptyString || BSPF::equalsIgnoreCase(startbank, "AUTO"))
? -1 : atoi(startbank.c_str()); ? -1 : stoi(startbank);
}); });
// We can only initialize after all the devices/components have been created // We can only initialize after all the devices/components have been created
@ -531,7 +531,7 @@ void Console::togglePhosphor()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::changePhosphor(int direction) void Console::changePhosphor(int direction)
{ {
int blend = atoi(myProperties.get(PropType::Display_PPBlend).c_str()); int blend = stoi(myProperties.get(PropType::Display_PPBlend));
if(direction == +1) // increase blend if(direction == +1) // increase blend
{ {
@ -692,7 +692,7 @@ void Console::updateVcenter(Int32 vcenter)
void Console::setTIAProperties() void Console::setTIAProperties()
{ {
Int32 vcenter = BSPF::clamp( Int32 vcenter = BSPF::clamp(
static_cast<Int32>(atoi(myProperties.get(PropType::Display_VCenter).c_str())), TIAConstants::minVcenter, TIAConstants::maxVcenter static_cast<Int32>(stoi(myProperties.get(PropType::Display_VCenter))), TIAConstants::minVcenter, TIAConstants::maxVcenter
); );
if(myDisplayFormat == "NTSC" || myDisplayFormat == "PAL60" || if(myDisplayFormat == "NTSC" || myDisplayFormat == "PAL60" ||

View File

@ -1095,7 +1095,7 @@ void EventHandler::setComboMap()
// If it isn't, then we treat the entire list as invalid // If it isn't, then we treat the entire list as invalid
string key; string key;
buf >> key; buf >> key;
if(atoi(key.c_str()) == COMBO_SIZE) if(stoi(key) == COMBO_SIZE)
{ {
// Fill the combomap table with events for as long as they exist // Fill the combomap table with events for as long as they exist
int combocount = 0; int combocount = 0;
@ -1108,7 +1108,7 @@ void EventHandler::setComboMap()
int eventcount = 0; int eventcount = 0;
while(buf2 >> key && eventcount < EVENTS_PER_COMBO) while(buf2 >> key && eventcount < EVENTS_PER_COMBO)
{ {
myComboTable[combocount][eventcount] = Event::Type(atoi(key.c_str())); myComboTable[combocount][eventcount] = Event::Type(stoi(key));
++eventcount; ++eventcount;
} }
++combocount; ++combocount;
@ -1392,7 +1392,7 @@ void EventHandler::setComboListForEvent(Event::Type event, const StringList& eve
int combo = event - Event::Combo1; int combo = event - Event::Combo1;
for(uInt32 i = 0; i < 8; ++i) for(uInt32 i = 0; i < 8; ++i)
{ {
uInt32 idx = atoi(events[i].c_str()); uInt32 idx = stoi(events[i]);
if(idx < ourEmulActionList.size()) if(idx < ourEmulActionList.size())
myComboTable[combo][i] = EventHandler::ourEmulActionList[idx].event; myComboTable[combo][i] = EventHandler::ourEmulActionList[idx].event;
else else

View File

@ -69,7 +69,7 @@ ProfilingRunner::ProfilingRunner(int argc, char* argv[])
if (splitPoint == string::npos) run.runtime = RUNTIME_DEFAULT; if (splitPoint == string::npos) run.runtime = RUNTIME_DEFAULT;
else { else {
int runtime = atoi(arg.substr(splitPoint+1, string::npos).c_str()); int runtime = stoi(arg.substr(splitPoint+1, string::npos));
run.runtime = runtime > 0 ? runtime : RUNTIME_DEFAULT; run.runtime = runtime > 0 ? runtime : RUNTIME_DEFAULT;
} }
} }

View File

@ -63,7 +63,7 @@ void Properties::set(PropType key, const string& value)
case PropType::Display_PPBlend: case PropType::Display_PPBlend:
{ {
int blend = atoi(myProperties[pos].c_str()); int blend = stoi(myProperties[pos]);
if(blend < 0 || blend > 100) if(blend < 0 || blend > 100)
myProperties[pos] = ourDefaultProperties[pos]; myProperties[pos] = ourDefaultProperties[pos];
break; break;

View File

@ -98,7 +98,7 @@ void TIASurface::initialize(const Console& console,
} }
else else
{ {
p_blend = atoi(console.properties().get(PropType::Display_PPBlend).c_str()); p_blend = stoi(console.properties().get(PropType::Display_PPBlend));
enable = console.properties().get(PropType::Display_Phosphor) == "YES"; enable = console.properties().get(PropType::Display_Phosphor) == "YES";
} }
enablePhosphor(enable, p_blend); enablePhosphor(enable, p_blend);

View File

@ -455,10 +455,10 @@ void GameInfoDialog::loadEmulationProperties(const Properties& props)
myPPBlend->setEnabled(!alwaysPhosphor && usePhosphor); myPPBlend->setEnabled(!alwaysPhosphor && usePhosphor);
const string& blend = props.get(PropType::Display_PPBlend); const string& blend = props.get(PropType::Display_PPBlend);
myPPBlend->setValue(atoi(blend.c_str())); myPPBlend->setValue(stoi(blend));
// set vertical center // set vertical center
Int32 vcenter = atoi(props.get(PropType::Display_VCenter).c_str()); Int32 vcenter = stoi(props.get(PropType::Display_VCenter));
myVCenter->setValueLabel(vcenter); myVCenter->setValueLabel(vcenter);
myVCenter->setValue(vcenter); myVCenter->setValue(vcenter);
myVCenter->setValueUnit(vcenter ? "px" : ""); myVCenter->setValueUnit(vcenter ? "px" : "");
@ -507,7 +507,7 @@ void GameInfoDialog::loadControllerProperties(const Properties& props)
myMouseY->setEnabled(!autoAxis); myMouseY->setEnabled(!autoAxis);
if(m_axis >> m_range) if(m_axis >> m_range)
{ {
myMouseRange->setValue(atoi(m_range.c_str())); myMouseRange->setValue(stoi(m_range));
} }
else else
{ {