Remove implicit conversion operator from RString to const char*

This is required for the RString to std::string migration.

Mostly automated from https://github.com/aeubanks/rewriter/blob/main/c_str.cc, with some manual intervention required for fixing up `a + b.c_str()` to `(a + b).c_str()`.

Added some overloads for some common global functions like sm_crash to reduce the number of changes required here.
This commit is contained in:
Arthur Eubanks
2025-04-26 17:30:36 -07:00
committed by teejusb
parent 6a981ac5f7
commit ecfcb11a00
110 changed files with 458 additions and 426 deletions
+16 -16
View File
@@ -52,7 +52,7 @@ static RString ClearMachineEdits()
PROFILEMAN->LoadMachineProfile();
int errorCount = editCount - removedCount;
return ssprintf(MACHINE_EDITS_CLEARED.GetValue(), editCount, errorCount);
return ssprintf(MACHINE_EDITS_CLEARED.GetValue().c_str(), editCount, errorCount);
}
static PlayerNumber GetFirstReadyMemoryCard()
@@ -90,7 +90,7 @@ static RString ClearMemoryCardEdits()
MEMCARDMAN->UnmountCard(pn);
return ssprintf(EDITS_CLEARED.GetValue(), editCount, editCount - removedCount);
return ssprintf(EDITS_CLEARED.GetValue().c_str(), editCount, editCount - removedCount);
}
@@ -114,9 +114,9 @@ static RString TransferStatsMachineToMemoryCard()
MEMCARDMAN->UnmountCard(pn);
if( bSaved )
return ssprintf(MACHINE_STATS_SAVED.GetValue(),pn+1);
return ssprintf(MACHINE_STATS_SAVED.GetValue().c_str(),pn+1);
else
return ssprintf(ERROR_SAVING_MACHINE_STATS.GetValue(),pn+1);
return ssprintf(ERROR_SAVING_MACHINE_STATS.GetValue().c_str(),pn+1);
}
static LocalizedString STATS_NOT_LOADED ( "ScreenServiceAction", "Stats not loaded - No memory cards ready." );
@@ -142,15 +142,15 @@ static RString TransferStatsMemoryCardToMachine()
switch( lr )
{
case ProfileLoadResult_Success:
s = ssprintf(MACHINE_STATS_LOADED.GetValue(),pn+1);
s = ssprintf(MACHINE_STATS_LOADED.GetValue().c_str(),pn+1);
break;
case ProfileLoadResult_FailedNoProfile:
*PROFILEMAN->GetMachineProfile() = backup;
s = ssprintf(THERE_IS_NO_PROFILE.GetValue(),pn+1);
s = ssprintf(THERE_IS_NO_PROFILE.GetValue().c_str(),pn+1);
break;
case ProfileLoadResult_FailedTampered:
*PROFILEMAN->GetMachineProfile() = backup;
s = ssprintf(PROFILE_CORRUPT.GetValue(),pn+1);
s = ssprintf(PROFILE_CORRUPT.GetValue().c_str(),pn+1);
break;
default:
FAIL_M(ssprintf("Invalid profile load result: %i", lr));
@@ -235,11 +235,11 @@ static RString CopyEdits( const RString &sFromProfileDir, const RString &sToProf
std::vector<RString> vs;
vs.push_back( sDisplayDir );
vs.push_back( ssprintf( COPIED.GetValue(), iNumSucceeded ) + ", " + ssprintf( OVERWRITTEN.GetValue(), iNumOverwritten ) );
vs.push_back( ssprintf( COPIED.GetValue().c_str(), iNumSucceeded ) + ", " + ssprintf( OVERWRITTEN.GetValue().c_str(), iNumOverwritten ) );
if( iNumIgnored )
vs.push_back( ssprintf( IGNORED.GetValue(), iNumIgnored ) );
vs.push_back( ssprintf( IGNORED.GetValue().c_str(), iNumIgnored ) );
if( iNumErrored )
vs.push_back( ssprintf( FAILED.GetValue(), iNumErrored ) );
vs.push_back( ssprintf( FAILED.GetValue().c_str(), iNumErrored ) );
return join( "\n", vs );
}
@@ -309,7 +309,7 @@ static RString CopyEditsMachineToMemoryCard()
RString sToDir = MEM_CARD_MOUNT_POINT[pn] + (RString)PREFSMAN->m_sMemoryCardProfileSubdir + "/";
std::vector<RString> vs;
vs.push_back( ssprintf( COPIED_TO_CARD.GetValue(), pn+1 ) );
vs.push_back( ssprintf( COPIED_TO_CARD.GetValue().c_str(), pn+1 ) );
RString s = CopyEdits( sFromDir, sToDir, PREFSMAN->m_sMemoryCardProfileSubdir );
vs.push_back( s );
@@ -338,12 +338,12 @@ static RString SyncEditsMachineToMemoryCard()
MEMCARDMAN->UnmountCard(pn);
RString sRet = ssprintf( COPIED_TO_CARD.GetValue(), pn+1 ) + " ";
sRet += ssprintf( ADDED.GetValue(), iNumAdded ) + ", " + ssprintf( OVERWRITTEN.GetValue(), iNumOverwritten );
RString sRet = ssprintf( COPIED_TO_CARD.GetValue().c_str(), pn+1 ) + " ";
sRet += ssprintf( ADDED.GetValue().c_str(), iNumAdded ) + ", " + ssprintf( OVERWRITTEN.GetValue().c_str(), iNumOverwritten );
if( iNumDeleted )
sRet += RString(" ") + ssprintf( DELETED.GetValue(), iNumDeleted );
sRet += RString(" ") + ssprintf( DELETED.GetValue().c_str(), iNumDeleted );
if( iNumFailed )
sRet += RString("; ") + ssprintf( FAILED.GetValue(), iNumFailed );
sRet += RString("; ") + ssprintf( FAILED.GetValue().c_str(), iNumFailed );
return sRet;
}
@@ -361,7 +361,7 @@ static RString CopyEditsMemoryCardToMachine()
ProfileManager::GetMemoryCardProfileDirectoriesToTry( vsSubDirs );
std::vector<RString> vs;
vs.push_back( ssprintf( COPIED_FROM_CARD.GetValue(), pn+1 ) );
vs.push_back( ssprintf( COPIED_FROM_CARD.GetValue().c_str(), pn+1 ) );
for (RString const &sSubDir : vsSubDirs)
{