DialogDriver *DialogDriver::Create() { std::string sDrivers = "win32,macosx,null"; auto asDriversToTry = Rage::split( sDrivers, ",", Rage::EmptyEntries::skip ); ASSERT( asDriversToTry.size() != 0 ); for (auto const &Driver: asDriversToTry) { auto iter = RegisterDialogDriver::g_pRegistrees->find( Rage::ci_ascii_string{Driver.c_str()} ); if( iter == RegisterDialogDriver::g_pRegistrees->end() ) { continue; } DialogDriver *pRet = (iter->second)(); DEBUG_ASSERT( pRet ); const std::string sError = pRet->Init(); if( sError.empty() ) { return pRet; } if( LOG ) { LOG->Info( "Couldn't load driver %s: %s", Driver.c_str(), sError.c_str() ); } Rage::safe_delete( pRet ); } return nullptr; }
DialogDriver *DialogDriver::Create() { RString sDrivers = "win32,macosx,null"; vector<RString> asDriversToTry; split( sDrivers, ",", asDriversToTry, true ); ASSERT( asDriversToTry.size() != 0 ); FOREACH_CONST( RString, asDriversToTry, Driver ) { map<istring, CreateDialogDriverFn>::const_iterator iter = RegisterDialogDriver::g_pRegistrees->find( istring(*Driver) ); if( iter == RegisterDialogDriver::g_pRegistrees->end() ) continue; DialogDriver *pRet = (iter->second)(); DEBUG_ASSERT( pRet ); const RString sError = pRet->Init(); if( sError.empty() ) return pRet; if( LOG ) LOG->Info( "Couldn't load driver %s: %s", Driver->c_str(), sError.c_str() ); SAFE_DELETE( pRet ); }