diff --git a/src/cheat/CheatManager.cxx b/src/cheat/CheatManager.cxx index ba02d8f3c..698d8adf1 100644 --- a/src/cheat/CheatManager.cxx +++ b/src/cheat/CheatManager.cxx @@ -298,7 +298,7 @@ void CheatManager::saveCheats(string_view md5sum) cheats << ","; } - const bool changed = cheats.str() != myCurrentCheat; + const bool changed = cheats.view() != myCurrentCheat; // Only update the list if absolutely necessary if(changed) @@ -310,8 +310,8 @@ void CheatManager::saveCheats(string_view md5sum) myCheatMap.erase(iter); // Add new entry only if there are any cheats defined - if(!cheats.str().empty()) - myCheatMap.emplace(md5sum, cheats.str()); + if(!cheats.view().empty()) + myCheatMap.emplace(md5sum, cheats.view()); } // Update the dirty flag diff --git a/src/common/EventHandlerSDL2.cxx b/src/common/EventHandlerSDL2.cxx index 49e8b5238..4f6f4e041 100644 --- a/src/common/EventHandlerSDL2.cxx +++ b/src/common/EventHandlerSDL2.cxx @@ -33,7 +33,7 @@ EventHandlerSDL2::EventHandlerSDL2(OSystem& osystem) myQwertz = int{'y'} == static_cast (SDL_GetKeyFromScancode(static_cast(KBDK_Z))); buf << "Keyboard: " << (myQwertz ? "QWERTZ" : "QWERTY"); - Logger::debug(buf.str()); + Logger::debug(buf.view()); } #endif @@ -43,7 +43,7 @@ EventHandlerSDL2::EventHandlerSDL2(OSystem& osystem) ostringstream buf; buf << "ERROR: Couldn't initialize SDL joystick support: " << SDL_GetError() << '\n'; - Logger::error(buf.str()); + Logger::error(buf.view()); } Logger::debug("EventHandlerSDL2::EventHandlerSDL2 SDL_INIT_JOYSTICK"); #endif diff --git a/src/common/FBBackendSDL2.cxx b/src/common/FBBackendSDL2.cxx index efddd45cd..b9c3f396f 100644 --- a/src/common/FBBackendSDL2.cxx +++ b/src/common/FBBackendSDL2.cxx @@ -105,11 +105,11 @@ void FBBackendSDL2::queryHardware(vector& fullscreenRes, SDL_GetDisplayMode(i, m, &mode); res << std::setw(4) << mode.w << "x" << std::setw(4) << mode.h; - if(lastRes != res.str()) + if(lastRes != res.view()) { - Logger::debug(s.str()); + Logger::debug(s.view()); s.str(""); - lastRes = res.str(); + lastRes = res.view(); s << " " << lastRes << ": "; } s << mode.refresh_rate << "Hz"; @@ -118,7 +118,7 @@ void FBBackendSDL2::queryHardware(vector& fullscreenRes, else s << " "; } - Logger::debug(s.str()); + Logger::debug(s.view()); } // Now get the maximum windowed desktop resolution @@ -332,7 +332,7 @@ bool FBBackendSDL2::setVideoMode(const VideoModeHandler::Mode& mode, msg << "Display refresh rate changed to " << adaptedSdlMode.refresh_rate << " Hz " << "(" << adaptedSdlMode.w << "x" << adaptedSdlMode.h << ")"; - Logger::info(msg.str()); + Logger::info(msg.view()); SDL_DisplayMode setSdlMode; SDL_GetWindowDisplayMode(myWindow, &setSdlMode); diff --git a/src/common/HighScoresManager.cxx b/src/common/HighScoresManager.cxx index 052df28c9..2cfdce762 100644 --- a/src/common/HighScoresManager.cxx +++ b/src/common/HighScoresManager.cxx @@ -415,7 +415,7 @@ string HighScoresManager::md5Props() const buf << specialAddress(jprops) << specialBCD(jprops) << specialZeroBased(jprops); - return MD5::hash(buf.str()); + return MD5::hash(buf.view()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -571,7 +571,7 @@ string HighScoresManager::hash(const ScoresData& data) const << data.scores[r].date; } - return MD5::hash(buf.str()); + return MD5::hash(buf.view()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -658,7 +658,7 @@ void HighScoresManager::loadHighScores(ScoresData& data) clearHighScores(data); buf << "Error: Invalid high scores data for variation " << data.variation << "."; } - myOSystem.frameBuffer().showTextMessage(buf.str()); + myOSystem.frameBuffer().showTextMessage(buf.view()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/common/JoyMap.cxx b/src/common/JoyMap.cxx index 8e8e5fc46..623245e77 100644 --- a/src/common/JoyMap.cxx +++ b/src/common/JoyMap.cxx @@ -166,7 +166,7 @@ string JoyMap::getEventMappingDesc(int stick, const Event::Type event, const Eve { if (_event == event && _mapping.mode == mode) { - if(!buf.str().empty()) + if(!buf.view().empty()) buf << ", "; buf << "C" << stick << getDesc(event, _mapping); } diff --git a/src/common/KeyMap.cxx b/src/common/KeyMap.cxx index 3482d602c..d0a9c31d2 100644 --- a/src/common/KeyMap.cxx +++ b/src/common/KeyMap.cxx @@ -197,7 +197,7 @@ string KeyMap::getEventMappingDesc(const Event::Type event, const EventMode mode { if (_event == event && _mapping.mode == mode) { - if(!buf.str().empty()) + if(!buf.view().empty()) buf << ", "; buf << getDesc(_mapping); } diff --git a/src/common/MouseControl.cxx b/src/common/MouseControl.cxx index 0ece4d5aa..c221808de 100644 --- a/src/common/MouseControl.cxx +++ b/src/common/MouseControl.cxx @@ -106,7 +106,7 @@ MouseControl::MouseControl(Console& console, string_view mode) msg << ", Y-axis is "; MControlToController(yaxis, ytype, yid); - myModeList.emplace_back(xtype, xid, ytype, yid, msg.str()); + myModeList.emplace_back(xtype, xid, ytype, yid, msg.view()); } // Now consider the possible modes for the mouse based on the left @@ -173,7 +173,7 @@ void MouseControl::addLeftControllerModes(bool noswap) msg << "Mouse is left " << myLeftController.name() << " controller"; const Controller::Type type = myLeftController.type(); const int id = noswap ? 0 : 1; - myModeList.emplace_back(type, id, type, id, msg.str()); + myModeList.emplace_back(type, id, type, id, msg.view()); } } } @@ -194,7 +194,7 @@ void MouseControl::addRightControllerModes(bool noswap) msg << "Mouse is right " << myRightController.name() << " controller"; const Controller::Type type = myRightController.type(); const int id = noswap ? 1 : 0; - myModeList.emplace_back(type, id, type, id, msg.str()); + myModeList.emplace_back(type, id, type, id, msg.view()); } } } @@ -205,11 +205,11 @@ void MouseControl::addPaddleModes(int lport, int rport, int lname, int rname) const Controller::Type type = Controller::Type::Paddles; ostringstream msg; msg << "Mouse is Paddle " << lname << " controller"; - const MouseMode mode0(type, lport, type, lport, msg.str()); + const MouseMode mode0(type, lport, type, lport, msg.view()); msg.str(""); msg << "Mouse is Paddle " << rname << " controller"; - const MouseMode mode1(type, rport, type, rport, msg.str()); + const MouseMode mode1(type, rport, type, rport, msg.view()); if(BSPF::equalsIgnoreCase(myProps.get(PropType::Controller_SwapPaddles), "NO")) { diff --git a/src/common/PJoystickHandler.cxx b/src/common/PJoystickHandler.cxx index 7fd5e8eb2..b1aea8fcf 100644 --- a/src/common/PJoystickHandler.cxx +++ b/src/common/PJoystickHandler.cxx @@ -117,7 +117,7 @@ int PhysicalJoystickHandler::add(const PhysicalJoystickPtr& stick) { ostringstream name; name << stick->name << " #" << count+1; - stick->name = name.str(); + stick->name = name.view(); } stick->type = PhysicalJoystick::Type::REGULAR; } @@ -175,7 +175,7 @@ void PhysicalJoystickHandler::addToDatabase(const PhysicalJoystickPtr& stick) ostringstream buf; buf << "Added joystick " << stick->ID << ":\n" << " " << stick->about() << '\n'; - Logger::info(buf.str()); + Logger::info(buf.view()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -196,7 +196,7 @@ bool PhysicalJoystickHandler::remove(int id) ostringstream buf; buf << "Removed joystick " << mySticks[id]->ID << ":\n" << " " << mySticks[id]->about() << '\n'; - Logger::info(buf.str()); + Logger::info(buf.view()); // Remove joystick, but remember mapping it->second.mapping = stick->getMap(); @@ -264,7 +264,7 @@ bool PhysicalJoystickHandler::mapStelladaptors(string_view saport, int ID) ostringstream buf; buf << "Erased joystick " << _stick->ID << ":\n" << " " << _stick->about() << '\n'; - Logger::info(buf.str()); + Logger::info(buf.view()); _stick->name.erase(pos); erased = true; @@ -809,7 +809,7 @@ string PhysicalJoystickHandler::getMappingDesc(Event::Type event, EventMode mode //Joystick mapping / labeling if(!_joyptr->joyMap.getEventMapping(event, evMode).empty()) { - if(!buf.str().empty()) + if(!buf.view().empty()) buf << ", "; buf << _joyptr->joyMap.getEventMappingDesc(_id, event, evMode); } @@ -1134,7 +1134,7 @@ void PhysicalJoystickHandler::changeDigitalDeadZone(int direction) ss << std::round(Controller::digitalDeadZoneValue(deadZone) * 100.F / 32768) << "%"; myOSystem.frameBuffer().showGaugeMessage( - "Digital controller dead zone", ss. str(), deadZone, + "Digital controller dead zone", ss.view(), deadZone, Controller::MIN_DIGITAL_DEADZONE, Controller::MAX_DIGITAL_DEADZONE); } @@ -1152,7 +1152,7 @@ void PhysicalJoystickHandler::changeAnalogPaddleDeadZone(int direction) ss << std::round(Controller::analogDeadZoneValue(deadZone) * 100.F / 32768) << "%"; myOSystem.frameBuffer().showGaugeMessage( - "Analog controller dead zone", ss.str(), deadZone, + "Analog controller dead zone", ss.view(), deadZone, Controller::MIN_ANALOG_DEADZONE, Controller::MAX_ANALOG_DEADZONE); } @@ -1170,7 +1170,7 @@ void PhysicalJoystickHandler::changeAnalogPaddleSensitivity(int direction) ss << std::round(Paddles::analogSensitivityValue(sense) * 100.F) << "%"; myOSystem.frameBuffer().showGaugeMessage( - "Analog paddle sensitivity", ss.str(), sense, + "Analog paddle sensitivity", ss.view(), sense, Paddles::MIN_ANALOG_SENSE, Paddles::MAX_ANALOG_SENSE); } @@ -1191,7 +1191,7 @@ void PhysicalJoystickHandler::changeAnalogPaddleLinearity(int direction) ss << "Off"; myOSystem.frameBuffer().showGaugeMessage( - "Analog paddle linearity", ss.str(), linear, + "Analog paddle linearity", ss.view(), linear, Paddles::MIN_ANALOG_LINEARITY, Paddles::MAX_ANALOG_LINEARITY); } @@ -1212,7 +1212,7 @@ void PhysicalJoystickHandler::changePaddleDejitterAveraging(int direction) ss << "Off"; myOSystem.frameBuffer().showGaugeMessage( - "Analog paddle dejitter averaging", ss.str(), dejitter, + "Analog paddle dejitter averaging", ss.view(), dejitter, Paddles::MIN_DEJITTER, Paddles::MAX_DEJITTER); } @@ -1233,7 +1233,7 @@ void PhysicalJoystickHandler::changePaddleDejitterReaction(int direction) ss << "Off"; myOSystem.frameBuffer().showGaugeMessage( - "Analog paddle dejitter reaction", ss.str(), dejitter, + "Analog paddle dejitter reaction", ss.view(), dejitter, Paddles::MIN_DEJITTER, Paddles::MAX_DEJITTER); } @@ -1254,7 +1254,7 @@ void PhysicalJoystickHandler::changeDigitalPaddleSensitivity(int direction) ss << "Off"; myOSystem.frameBuffer().showGaugeMessage( - "Digital sensitivity", ss.str(), sense, + "Digital sensitivity", ss.view(), sense, Paddles::MIN_DIGITAL_SENSE, Paddles::MAX_DIGITAL_SENSE); } @@ -1272,7 +1272,7 @@ void PhysicalJoystickHandler::changeMousePaddleSensitivity(int direction) ss << sense * 10 << "%"; myOSystem.frameBuffer().showGaugeMessage( - "Mouse paddle sensitivity", ss.str(), sense, + "Mouse paddle sensitivity", ss.view(), sense, Controller::MIN_MOUSE_SENSE, Controller::MAX_MOUSE_SENSE); } @@ -1290,7 +1290,7 @@ void PhysicalJoystickHandler::changeMouseTrackballSensitivity(int direction) ss << sense * 10 << "%"; myOSystem.frameBuffer().showGaugeMessage( - "Mouse trackball sensitivity", ss.str(), sense, + "Mouse trackball sensitivity", ss.view(), sense, PointingDevice::MIN_SENSE, PointingDevice::MAX_SENSE); } @@ -1308,7 +1308,7 @@ void PhysicalJoystickHandler::changeDrivingSensitivity(int direction) ss << sense * 10 << "%"; myOSystem.frameBuffer().showGaugeMessage( - "Driving controller sensitivity", ss.str(), sense, + "Driving controller sensitivity", ss.view(), sense, Driving::MIN_SENSE, Driving::MAX_SENSE); } diff --git a/src/common/PKeyboardHandler.cxx b/src/common/PKeyboardHandler.cxx index f4effceae..c12c609be 100644 --- a/src/common/PKeyboardHandler.cxx +++ b/src/common/PKeyboardHandler.cxx @@ -614,7 +614,7 @@ void PhysicalKeyboardHandler::toggleModKeys(bool toggle) ostringstream ss; ss << "Modifier key combos "; ss << (modCombo ? "enabled" : "disabled"); - myOSystem.frameBuffer().showTextMessage(ss.str()); + myOSystem.frameBuffer().showTextMessage(ss.view()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/common/PNGLibrary.cxx b/src/common/PNGLibrary.cxx index 4ff22f4e3..e3bc9c7aa 100644 --- a/src/common/PNGLibrary.cxx +++ b/src/common/PNGLibrary.cxx @@ -273,7 +273,7 @@ void PNGLibrary::toggleContinuousSnapshots(bool perFrame) buf << "Enabling snapshots in " << interval << " second intervals"; interval *= static_cast(myOSystem.frameRate()); } - myOSystem.frameBuffer().showTextMessage(buf.str()); + myOSystem.frameBuffer().showTextMessage(buf.view()); setContinuousSnapInterval(interval); } else @@ -282,7 +282,7 @@ void PNGLibrary::toggleContinuousSnapshots(bool perFrame) buf << "Disabling snapshots, generated " << (mySnapCounter / mySnapInterval) << " files"; - myOSystem.frameBuffer().showTextMessage(buf.str()); + myOSystem.frameBuffer().showTextMessage(buf.view()); setContinuousSnapInterval(0); } } @@ -313,7 +313,7 @@ void PNGLibrary::takeSnapshot(uInt32 number) ostringstream buf; buf << sspath << "_" << std::hex << std::setw(8) << std::setfill('0') << number << ".png"; - filename = buf.str(); + filename = buf.view(); } else if(!myOSystem.settings().getBool("sssingle")) { @@ -328,11 +328,11 @@ void PNGLibrary::takeSnapshot(uInt32 number) { buf.str(""); buf << sspath << "_" << i << ".png"; - const FSNode next(buf.str()); + const FSNode next(buf.view()); if(!next.exists()) break; } - filename = buf.str(); + filename = buf.view(); } } else @@ -344,7 +344,7 @@ void PNGLibrary::takeSnapshot(uInt32 number) VarList::push_back(metaData, "Title", "Snapshot"); version << "Stella " << STELLA_VERSION << " (Build " << STELLA_BUILD << ") [" << BSPF::ARCH << "]"; - VarList::push_back(metaData, "Software", version.str()); + VarList::push_back(metaData, "Software", version.view()); const string& name = (myOSystem.settings().getString("snapname") == "int") ? myOSystem.console().properties().get(PropType::Cart_Name) : myOSystem.romFile().getName(); diff --git a/src/common/PaletteHandler.cxx b/src/common/PaletteHandler.cxx index 6d021cf98..6e39ce590 100644 --- a/src/common/PaletteHandler.cxx +++ b/src/common/PaletteHandler.cxx @@ -112,7 +112,7 @@ void PaletteHandler::showAdjustableMessage() myOSystem.console().timing() == ConsoleTiming::pal ? myPhasePAL : myPhaseNTSC; buf << std::fixed << std::setprecision(1) << value << DEGREE; myOSystem.frameBuffer().showGaugeMessage( - "Palette phase shift", buf.str(), value, + "Palette phase shift", buf.view(), value, (isNTSC ? DEF_NTSC_SHIFT : DEF_PAL_SHIFT) - MAX_PHASE_SHIFT, (isNTSC ? DEF_NTSC_SHIFT : DEF_PAL_SHIFT) + MAX_PHASE_SHIFT); } @@ -122,7 +122,7 @@ void PaletteHandler::showAdjustableMessage() buf << std::fixed << std::setprecision(1) << value << DEGREE; myOSystem.frameBuffer().showGaugeMessage( - msg.str(), buf.str(), value, -MAX_RGB_SHIFT, +MAX_RGB_SHIFT); + msg.view(), buf.view(), value, -MAX_RGB_SHIFT, +MAX_RGB_SHIFT); } else { @@ -131,7 +131,7 @@ void PaletteHandler::showAdjustableMessage() : scaleTo100(*myAdjustables[myCurrentAdjustable].value); buf << value << "%"; myOSystem.frameBuffer().showGaugeMessage( - msg.str(), buf.str(), value); + msg.view(), buf.view(), value); } } diff --git a/src/common/RewindManager.cxx b/src/common/RewindManager.cxx index 6ba980b25..da5b4568f 100644 --- a/src/common/RewindManager.cxx +++ b/src/common/RewindManager.cxx @@ -239,7 +239,7 @@ string RewindManager::saveAllStates() << myOSystem.console().properties().get(PropType::Cart_Name) << ".sta"; - Serializer out(buf.str(), Serializer::Mode::ReadWriteTrunc); + Serializer out(buf.view(), Serializer::Mode::ReadWriteTrunc); if (!out) return "Can't save to all states file"; @@ -296,7 +296,7 @@ string RewindManager::loadAllStates() << ".sta"; // Make sure the file can be opened for reading - const Serializer in(buf.str(), Serializer::Mode::ReadOnly); + const Serializer in(buf.view(), Serializer::Mode::ReadOnly); if (!in) return "Can't load from all states file"; diff --git a/src/common/SoundSDL2.cxx b/src/common/SoundSDL2.cxx index 4061fafcf..ba825bb83 100644 --- a/src/common/SoundSDL2.cxx +++ b/src/common/SoundSDL2.cxx @@ -48,7 +48,7 @@ SoundSDL2::SoundSDL2(OSystem& osystem, AudioSettings& audioSettings) buf << "WARNING: Failed to initialize SDL audio system! \n" << " " << SDL_GetError() << '\n'; - Logger::error(buf.str()); + Logger::error(buf.view()); return; } @@ -83,7 +83,7 @@ void SoundSDL2::queryHardware(VariantList& devices) // log the available audio devices ostringstream s; s << "Supported audio devices (" << numDevices << "):"; - Logger::debug(s.str()); + Logger::debug(s.view()); VarList::push_back(devices, "Default", 0); for(int i = 0; i < numDevices; ++i) @@ -91,7 +91,7 @@ void SoundSDL2::queryHardware(VariantList& devices) ostringstream ss; ss << " " << i + 1 << ": " << SDL_GetAudioDeviceName(i, 0); - Logger::debug(ss.str()); + Logger::debug(ss.view()); VarList::push_back(devices, SDL_GetAudioDeviceName(i, 0), i + 1); } @@ -128,7 +128,7 @@ bool SoundSDL2::openDevice() buf << "WARNING: Couldn't open SDL audio device! \n" << " " << SDL_GetError() << '\n'; - Logger::error(buf.str()); + Logger::error(buf.view()); return myIsInitializedFlag = false; } @@ -253,7 +253,7 @@ void SoundSDL2::adjustVolume(int direction) // Now show an onscreen message ostringstream strval; (percent) ? strval << percent << "%" : strval << "Off"; - myOSystem.frameBuffer().showGaugeMessage("Volume", strval.str(), percent); + myOSystem.frameBuffer().showGaugeMessage("Volume", strval.view(), percent); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/common/StaggeredLogger.cxx b/src/common/StaggeredLogger.cxx index 42fdc35f1..ddaade8e8 100644 --- a/src/common/StaggeredLogger.cxx +++ b/src/common/StaggeredLogger.cxx @@ -85,7 +85,7 @@ void StaggeredLogger::logLine() << millisecondsSinceIntervalStart << " milliseconds" << ")"; - Logger::log(ss.str(), myLevel); + Logger::log(ss.view(), myLevel); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/common/StateManager.cxx b/src/common/StateManager.cxx index e80b508ab..599f6c5da 100644 --- a/src/common/StateManager.cxx +++ b/src/common/StateManager.cxx @@ -207,12 +207,12 @@ void StateManager::loadState(int slot) << ".st" << slot; // Make sure the file can be opened in read-only mode - Serializer in(buf.str(), Serializer::Mode::ReadOnly); + Serializer in(buf.view(), Serializer::Mode::ReadOnly); if(!in) { buf.str(""); buf << "Can't open/load from state file " << slot; - myOSystem.frameBuffer().showTextMessage(buf.str()); + myOSystem.frameBuffer().showTextMessage(buf.view()); return; } @@ -236,7 +236,7 @@ void StateManager::loadState(int slot) buf << "Invalid data in state " << slot << " file"; } - myOSystem.frameBuffer().showTextMessage(buf.str()); + myOSystem.frameBuffer().showTextMessage(buf.view()); } } @@ -253,12 +253,12 @@ void StateManager::saveState(int slot) << ".st" << slot; // Make sure the file can be opened for writing - Serializer out(buf.str(), Serializer::Mode::ReadWriteTrunc); + Serializer out(buf.view(), Serializer::Mode::ReadWriteTrunc); if(!out) { buf.str(""); buf << "Can't open/save to state file " << slot; - myOSystem.frameBuffer().showTextMessage(buf.str()); + myOSystem.frameBuffer().showTextMessage(buf.view()); return; } @@ -271,7 +271,7 @@ void StateManager::saveState(int slot) catch(...) { buf << "Error saving state " << slot; - myOSystem.frameBuffer().showTextMessage(buf.str()); + myOSystem.frameBuffer().showTextMessage(buf.view()); return; } @@ -289,7 +289,7 @@ void StateManager::saveState(int slot) else buf << "Error saving state " << slot; - myOSystem.frameBuffer().showTextMessage(buf.str()); + myOSystem.frameBuffer().showTextMessage(buf.view()); } } @@ -304,7 +304,7 @@ void StateManager::changeState(int direction) buf << "Changed to state slot " << myCurrentSlot; else buf << "State slot " << myCurrentSlot; - myOSystem.frameBuffer().showTextMessage(buf.str()); + myOSystem.frameBuffer().showTextMessage(buf.view()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -315,7 +315,7 @@ void StateManager::toggleAutoSlot() // Print appropriate message ostringstream buf; buf << "Automatic slot change " << (autoSlot ? "enabled" : "disabled"); - myOSystem.frameBuffer().showTextMessage(buf.str()); + myOSystem.frameBuffer().showTextMessage(buf.view()); myOSystem.settings().setValue("autoslot", autoSlot); } diff --git a/src/common/Variant.hxx b/src/common/Variant.hxx index 69df7e9e0..86abfde98 100644 --- a/src/common/Variant.hxx +++ b/src/common/Variant.hxx @@ -48,13 +48,13 @@ class Variant Variant(string_view s) : data{s} { } Variant(const char* s) : data{s} { } - Variant(Int32 i) { buf().str(""); buf() << i; data = buf().str(); } - Variant(uInt32 i) { buf().str(""); buf() << i; data = buf().str(); } - Variant(float f) { buf().str(""); buf() << f; data = buf().str(); } - Variant(double d) { buf().str(""); buf() << d; data = buf().str(); } - Variant(bool b) { buf().str(""); buf() << b; data = buf().str(); } - Variant(const Common::Size& s) { buf().str(""); buf() << s; data = buf().str(); } - Variant(const Common::Point& s) { buf().str(""); buf() << s; data = buf().str(); } + Variant(Int32 i) { buf().str(""); buf() << i; data = buf().view(); } + Variant(uInt32 i) { buf().str(""); buf() << i; data = buf().view(); } + Variant(float f) { buf().str(""); buf() << f; data = buf().view(); } + Variant(double d) { buf().str(""); buf() << d; data = buf().view(); } + Variant(bool b) { buf().str(""); buf() << b; data = buf().view(); } + Variant(const Common::Size& s) { buf().str(""); buf() << s; data = buf().view(); } + Variant(const Common::Point& s) { buf().str(""); buf() << s; data = buf().view(); } // Conversion methods const string& toString() const { return data; } diff --git a/src/common/VideoModeHandler.cxx b/src/common/VideoModeHandler.cxx index 172588980..2cd520208 100644 --- a/src/common/VideoModeHandler.cxx +++ b/src/common/VideoModeHandler.cxx @@ -54,7 +54,7 @@ const VideoModeHandler::Mode& // Overscan is not applicable in this mode myMode = Mode(myImage.w, myImage.h, Mode::Stretch::Fill, myFSIndex, - desc.str(), zoom, bezelInfo); + desc.view(), zoom, bezelInfo); } else { diff --git a/src/common/bspf.hxx b/src/common/bspf.hxx index 4fd5fd3b0..9ac400217 100644 --- a/src/common/bspf.hxx +++ b/src/common/bspf.hxx @@ -47,6 +47,7 @@ using uInt64 = uint64_t; #include #include #include +#include #include #include #include @@ -116,8 +117,8 @@ static const string EmptyString(""); namespace BSPF { - static constexpr float PI_f = 3.141592653589793238462643383279502884F; - static constexpr double PI_d = 3.141592653589793238462643383279502884; + static constexpr float PI_f = std::numbers::pi_v; + static constexpr double PI_d = std::numbers::pi_v; // CPU architecture type // This isn't complete yet, but takes care of all the major platforms diff --git a/src/common/repository/CompositeKVRJsonAdapter.cxx b/src/common/repository/CompositeKVRJsonAdapter.cxx index a1691ae41..7ef54ec6e 100644 --- a/src/common/repository/CompositeKVRJsonAdapter.cxx +++ b/src/common/repository/CompositeKVRJsonAdapter.cxx @@ -41,7 +41,7 @@ namespace { if (!KeyValueRepositoryJsonFile::save(out, values)) return false; - return myKvr.save(myKey, out.str()); + return myKvr.save(myKey, out.view()); } private: diff --git a/src/common/tv_filters/NTSCFilter.cxx b/src/common/tv_filters/NTSCFilter.cxx index fe4fa71ff..dc509efc3 100644 --- a/src/common/tv_filters/NTSCFilter.cxx +++ b/src/common/tv_filters/NTSCFilter.cxx @@ -90,8 +90,8 @@ void NTSCFilter::selectAdjustable(int direction, msg << "Custom " << ourCustomAdjustables[myCurrentAdjustable].type; val << value << "%"; - text = msg.str(); - valueText = val.str(); + text = msg.view(); + valueText = val.view(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -121,8 +121,8 @@ void NTSCFilter::changeCurrentAdjustable(int direction, msg << "Custom " << ourCustomAdjustables[myCurrentAdjustable].type; val << newValue << "%"; - text = msg.str(); - valueText = val.str(); + text = msg.view(); + valueText = val.view(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/CartDebug.cxx b/src/debugger/CartDebug.cxx index e7714d89b..ed7842cb9 100644 --- a/src/debugger/CartDebug.cxx +++ b/src/debugger/CartDebug.cxx @@ -1378,7 +1378,7 @@ string CartDebug::saveDisassembly(string path) } // And finally, output the disassembly - out << buf.str(); + out << buf.view(); if(path.empty()) path = myOSystem.userDir().getPath() diff --git a/src/debugger/Debugger.cxx b/src/debugger/Debugger.cxx index 6da6256e1..d8cf34318 100644 --- a/src/debugger/Debugger.cxx +++ b/src/debugger/Debugger.cxx @@ -125,7 +125,7 @@ bool Debugger::start(string_view message, int address, bool read, buf << message; if(address > -1) buf << cartDebug().getLabel(address, read, 4); - myDialog->message().setText(buf.str()); + myDialog->message().setText(buf.view()); myDialog->message().setToolTip(toolTip); return true; } @@ -461,7 +461,7 @@ void Debugger::log(string_view triggerMsg) msg << "B/"; } msg << "Addr Code Disasm"; - Logger::log(msg.str()); + Logger::log(msg.view()); myFirstLog = false; } @@ -515,7 +515,7 @@ void Debugger::log(string_view triggerMsg) break; } } - Logger::log(msg.str()); + Logger::log(msg.view()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -628,7 +628,7 @@ void Debugger::nextScanline(int lines) } lockSystem(); - addState(buf.str()); + addState(buf.view()); myOSystem.console().tia().flushLineCache(); } @@ -651,7 +651,7 @@ void Debugger::nextFrame(int frames) } lockSystem(); - addState(buf.str()); + addState(buf.view()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/DebuggerParser.cxx b/src/debugger/DebuggerParser.cxx index 71e3e623b..5bb8d1380 100644 --- a/src/debugger/DebuggerParser.cxx +++ b/src/debugger/DebuggerParser.cxx @@ -597,7 +597,7 @@ void DebuggerParser::printTimer(uInt32 idx, bool showHeader) if(!debugger.cartDebug().getLabel(buf, timer.from.addr, true)) buf << " $" << setw(4) << Base::HEX4 << timer.from.addr; - string labelFrom = buf.str(); + string labelFrom{buf.view()}; labelFrom = labelFrom.substr(0, (banked ? 12 : 15) - (timer.mirrors ? 1 : 0)); labelFrom += (timer.mirrors ? "+" : ""); labelFrom = (labelFrom + " ").substr(0, banked ? 12 : 15); @@ -605,7 +605,7 @@ void DebuggerParser::printTimer(uInt32 idx, bool showHeader) buf.str(""); if(!debugger.cartDebug().getLabel(buf, timer.to.addr, true)) buf << " $" << setw(4) << Base::HEX4 << timer.to.addr; - string labelTo = buf.str(); + string labelTo{buf.view()}; labelTo = labelTo.substr(0, (banked ? 12 : 15) - (timer.mirrors ? 1 : 0)); labelTo += (timer.mirrors ? "+" : ""); labelTo = (labelTo + " ").substr(0, banked ? 12 : 15); @@ -778,7 +778,7 @@ string DebuggerParser::saveScriptFile(string file) const FSNode node(file); - if(node.exists() || !out.str().empty()) + if(node.exists() || !out.view().empty()) { try { @@ -1369,11 +1369,11 @@ void DebuggerParser::executeDump() // So we pass a copy of its contents, then re-create the // stream inside the lambda // Maybe this will change in a future version - const string outStr = out.str(); - const string resultStr = commandResult.str(); + const string outStr{out.view()}; + const string resultStr{commandResult.view()}; DebuggerDialog* dlg = debugger.myDialog; - BrowserDialog::show(dlg, "Save Dump as", path.str(), + BrowserDialog::show(dlg, "Save Dump as", path.view(), BrowserDialog::Mode::FileSave, [dlg, outStr, resultStr] (bool OK, const FSNode& node) @@ -1392,7 +1392,7 @@ void DebuggerParser::executeDump() commandResult.str("_NO_PROMPT"); } else - saveDump(FSNode(path.str()), out, commandResult); + saveDump(FSNode(path.view()), out, commandResult); } } @@ -1415,7 +1415,7 @@ void DebuggerParser::executeExec() ostringstream prefix; prefix << std::hex << std::setw(8) << std::setfill('0') << static_cast(TimerManager::getTicks()/1000); - execPrefix = prefix.str(); + execPrefix = prefix.view(); } // make sure the commands are added to prompt history @@ -1665,7 +1665,7 @@ void DebuggerParser::executeListBreaks() } } if(count) - commandResult << "breaks:\n" << buf.str(); + commandResult << "breaks:\n" << buf.view(); StringList conds = debugger.m6502().getCondBreakNames(); @@ -1681,7 +1681,7 @@ void DebuggerParser::executeListBreaks() } } - if(commandResult.str().empty()) + if(commandResult.view().empty()) commandResult << "no breakpoints set"; } @@ -1723,7 +1723,7 @@ void DebuggerParser::executeListSaveStateIfs() } } - if(commandResult.str().empty()) + if(commandResult.view().empty()) commandResult << "no savestateifs defined"; } @@ -1836,7 +1836,7 @@ void DebuggerParser::executePc() debugger.cpuDebug().setPC(args[0]); msg << "Set PC @ " << Base::HEX4 << args[0]; - debugger.addState(msg.str()); + debugger.addState(msg.view()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1973,7 +1973,7 @@ void DebuggerParser::executeRunTo() buf << "runTo searching through " << max_iterations << " disassembled instructions" << progress.ELLIPSIS; - progress.setMessage(buf.str()); + progress.setMessage(buf.view()); progress.setRange(0, static_cast(max_iterations), 5); progress.open(); @@ -2021,7 +2021,7 @@ void DebuggerParser::executeRunToPc() ProgressDialog progress(debugger.baseDialog(), debugger.lfont()); buf << " runTo PC running" << progress.ELLIPSIS << " "; - progress.setMessage(buf.str()); + progress.setMessage(buf.view()); progress.setRange(0, 100000, 5); progress.open(); @@ -2044,7 +2044,7 @@ void DebuggerParser::executeRunToPc() << "Set PC to $" << Base::HEX4 << args[0] << " in " << dec << count << " instructions"; msg << "RunTo PC @ " << Base::HEX4 << args[0]; - debugger.addState(msg.str()); + debugger.addState(msg.view()); } else commandResult @@ -2198,9 +2198,9 @@ void DebuggerParser::executeSaveSes() if(argCount) path << argStrings[0]; else - path << debugger.myOSystem.userDir() << filename.str(); + path << debugger.myOSystem.userDir() << filename.view(); - commandResult << debugger.prompt().saveBuffer(FSNode(path.str())); + commandResult << debugger.prompt().saveBuffer(FSNode(path.view())); } } @@ -2290,7 +2290,7 @@ void DebuggerParser::executeStepWhile() buf << "stepWhile running through disassembled instructions" << progress.ELLIPSIS; - progress.setMessage(buf.str()); + progress.setMessage(buf.view()); progress.setRange(0, 100000, 5); progress.open(); @@ -2541,7 +2541,7 @@ void DebuggerParser::executeTraps(bool read, bool write, string_view command, if(hasCond) conditionBuf << ")"; - const string condition = conditionBuf.str(); + const string condition{conditionBuf.view()}; const int res = YaccParser::parse(condition); if(res == 0) diff --git a/src/debugger/DiStella.cxx b/src/debugger/DiStella.cxx index bf491a73a..63d83b6ac 100644 --- a/src/debugger/DiStella.cxx +++ b/src/debugger/DiStella.cxx @@ -83,7 +83,7 @@ DiStella::DiStella(const CartDebug& dbg, CartDebug::DisassemblyList& list, if (CartDebug::addressType(k + myOffset) == CartDebug::AddrType::ROM) { reservedLabel.str(""); reservedLabel << "L" << Base::HEX4 << (k + myOffset); - myReserved.Label.emplace(k + myOffset, reservedLabel.str()); + myReserved.Label.emplace(k + myOffset, reservedLabel.view()); } } } @@ -227,7 +227,7 @@ void DiStella::disasm(uInt32 distart, int pass) nextLine << ".byte $" << Base::HEX2 << static_cast(opcode) << " ;"; nextLine << ourLookup[opcode].mnemonic; - myDisasmBuf << nextLine.str() << "'" << ";" + myDisasmBuf << nextLine.view() << "'" << ";" << std::dec << static_cast(ourLookup[opcode].cycles) << "-" << std::dec << static_cast(ourLookup[nextOpcode].cycles) << " " << "'= " << std::setw(3) << std::setfill(' ') << std::dec << cycles; @@ -603,7 +603,7 @@ void DiStella::disasm(uInt32 distart, int pass) if(pass == 3) { cycles += static_cast(ourLookup[opcode].cycles); // A complete line of disassembly (text, cycle count, and bytes) - myDisasmBuf << nextLine.str() << "'" + myDisasmBuf << nextLine.view() << "'" << ";" << std::dec << static_cast(ourLookup[opcode].cycles) << (addrMode == AddressingMode::RELATIVE ? (ad & 0xf00) != ((myPC + myOffset) & 0xf00) ? "/3!" : "/3 " : " "); if((opcode == 0x40 || opcode == 0x60 || opcode == 0x4c || opcode == 0x00 // code block end @@ -617,7 +617,7 @@ void DiStella::disasm(uInt32 distart, int pass) else { myDisasmBuf << "' "; } - myDisasmBuf << "'" << nextLineBytes.str(); + myDisasmBuf << "'" << nextLineBytes.view(); addEntry(Device::CODE); if(opcode == 0x40 || opcode == 0x60 || opcode == 0x4c || opcode == 0x00) { diff --git a/src/debugger/gui/AudioWidget.cxx b/src/debugger/gui/AudioWidget.cxx index e76b1885b..3e2c2795d 100644 --- a/src/debugger/gui/AudioWidget.cxx +++ b/src/debugger/gui/AudioWidget.cxx @@ -152,7 +152,7 @@ void AudioWidget::handleVolume() stringstream s; s << getEffectiveVolume() << "% (eff. volume)"; - myAudEffV->setLabel(s.str()); + myAudEffV->setLabel(s.view()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/gui/Cart3EPlusWidget.cxx b/src/debugger/gui/Cart3EPlusWidget.cxx index d3b7d6181..e46ed2180 100644 --- a/src/debugger/gui/Cart3EPlusWidget.cxx +++ b/src/debugger/gui/Cart3EPlusWidget.cxx @@ -79,7 +79,7 @@ void Cartridge3EPlusWidget::bankSelect(int& ypos) label << "Set segment " << seg << " as "; - new StaticTextWidget(_boss, _font, xpos, ypos, label.str()); + new StaticTextWidget(_boss, _font, xpos, ypos, label.view()); ypos += myLineHeight + VGAP * 2; xpos += _font.getMaxCharWidth() * 2; @@ -120,7 +120,7 @@ void Cartridge3EPlusWidget::bankSelect(int& ypos) label.str(""); label << "$" << Common::Base::HEX4 << addr1 << "-$" << Common::Base::HEX4 << (addr1 + 0x1FF); - auto* t = new StaticTextWidget(_boss, _font, xpos_s, ypos_s + 2, label.str()); + auto* t = new StaticTextWidget(_boss, _font, xpos_s, ypos_s + 2, label.view()); const int xoffset = t->getRight() + _font.getMaxCharWidth(); const size_t bank_off = static_cast(seg) * 2; @@ -131,7 +131,7 @@ void Cartridge3EPlusWidget::bankSelect(int& ypos) label.str(""); label << "$" << Common::Base::HEX4 << addr2 << "-$" << Common::Base::HEX4 << (addr2 + 0x1FF); - new StaticTextWidget(_boss, _font, xpos_s, ypos_s + 2, label.str()); + new StaticTextWidget(_boss, _font, xpos_s, ypos_s + 2, label.view()); myBankState[bank_off + 1] = new EditTextWidget(_boss, _font, xoffset, ypos_s, _w - xoffset - 10, myLineHeight, ""); @@ -209,12 +209,12 @@ void Cartridge3EPlusWidget::updateUIState() buf << "RAM @ $" << Common::Base::HEX4 << (ramBank << myCart3EP.myBankShift) << " (R)"; - myBankState[bank_off]->setText(buf.str()); + myBankState[bank_off]->setText(buf.view()); buf.str(""); buf << "RAM @ $" << Common::Base::HEX4 << ((ramBank << myCart3EP.myBankShift) + myCart3EP.myBankSize) << " (W)"; - myBankState[bank_off + 1]->setText(buf.str()); + myBankState[bank_off + 1]->setText(buf.view()); myBankWidgets[seg]->setSelectedIndex(ramBank); myBankType[seg]->setSelected("RAM"); @@ -223,12 +223,12 @@ void Cartridge3EPlusWidget::updateUIState() { buf << "ROM @ $" << Common::Base::HEX4 << ((bank << myCart3EP.myBankShift)); - myBankState[bank_off]->setText(buf.str()); + myBankState[bank_off]->setText(buf.view()); buf.str(""); buf << "ROM @ $" << Common::Base::HEX4 << ((bank << myCart3EP.myBankShift) + myCart3EP.myBankSize); - myBankState[bank_off + 1]->setText(buf.str()); + myBankState[bank_off + 1]->setText(buf.view()); myBankWidgets[seg]->setSelectedIndex(bank); myBankType[seg]->setSelected("ROM"); diff --git a/src/debugger/gui/CartARMWidget.cxx b/src/debugger/gui/CartARMWidget.cxx index f0d9c1547..3a35ae3f9 100644 --- a/src/debugger/gui/CartARMWidget.cxx +++ b/src/debugger/gui/CartARMWidget.cxx @@ -242,7 +242,7 @@ void CartridgeARMWidget::handleChipType() << (chipProps.flashBanks > 1 ? "s" : "") << ", " << chipProps.MHz << " MHz, " << chipProps.flashCycles - 1 << " wait states"; - myChipType->setToolTip(buf.str()); + myChipType->setToolTip(buf.view()); } } diff --git a/src/debugger/gui/CartBUSInfoWidget.cxx b/src/debugger/gui/CartBUSInfoWidget.cxx index 431124f36..edfbcb69e 100644 --- a/src/debugger/gui/CartBUSInfoWidget.cxx +++ b/src/debugger/gui/CartBUSInfoWidget.cxx @@ -57,7 +57,7 @@ CartridgeBUSInfoWidget::CartridgeBUSInfoWidget( } #endif - addBaseInformation(size, "AtariAge", info.str()); + addBaseInformation(size, "AtariAge", info.view()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/gui/CartCDFInfoWidget.cxx b/src/debugger/gui/CartCDFInfoWidget.cxx index c4f702d65..516c343b3 100644 --- a/src/debugger/gui/CartCDFInfoWidget.cxx +++ b/src/debugger/gui/CartCDFInfoWidget.cxx @@ -53,7 +53,7 @@ CartridgeCDFInfoWidget::CartridgeCDFInfoWidget( } #endif - addBaseInformation(cart.romSize(), "AtariAge", info.str()); + addBaseInformation(cart.romSize(), "AtariAge", info.view()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/gui/CartDPCPlusWidget.cxx b/src/debugger/gui/CartDPCPlusWidget.cxx index ce12a3da9..045405b15 100644 --- a/src/debugger/gui/CartDPCPlusWidget.cxx +++ b/src/debugger/gui/CartDPCPlusWidget.cxx @@ -50,7 +50,7 @@ CartridgeDPCPlusWidget::CartridgeDPCPlusWidget( #endif int xpos = 2, - ypos = addBaseInformation(size, "Activision (Pitfall II)", info.str()) + + ypos = addBaseInformation(size, "Activision (Pitfall II)", info.view()) + myLineHeight; VariantList items; diff --git a/src/debugger/gui/CartDPCWidget.cxx b/src/debugger/gui/CartDPCWidget.cxx index 3db9b1d14..f1544aefc 100644 --- a/src/debugger/gui/CartDPCWidget.cxx +++ b/src/debugger/gui/CartDPCWidget.cxx @@ -48,7 +48,7 @@ CartridgeDPCWidget::CartridgeDPCWidget( } int xpos = 2, - ypos = addBaseInformation(size, "Activision (Pitfall II)", info.str()) + + ypos = addBaseInformation(size, "Activision (Pitfall II)", info.view()) + myLineHeight; VariantList items; @@ -57,7 +57,7 @@ CartridgeDPCWidget::CartridgeDPCWidget( ostringstream buf; buf << "#" << std::dec << bank << " ($" << Common::Base::HEX4 << (0xFFF8 + bank) << ")"; - VarList::push_back(items, buf.str()); + VarList::push_back(items, buf.view()); } myBank = diff --git a/src/debugger/gui/CartDebugWidget.cxx b/src/debugger/gui/CartDebugWidget.cxx index 3d88b72c5..5ba81db7f 100644 --- a/src/debugger/gui/CartDebugWidget.cxx +++ b/src/debugger/gui/CartDebugWidget.cxx @@ -56,7 +56,7 @@ int CartDebugWidget::addBaseInformation(size_t bytes, string_view manufacturer, buf << " / " << (bytes/1024) << "KB"; w = new EditTextWidget(_boss, _nfont, x+lwidth, y - 1, - fwidth, myLineHeight, buf.str()); + fwidth, myLineHeight, buf.view()); w->setEditable(false); y += myLineHeight + 4; diff --git a/src/debugger/gui/CartE7Widget.cxx b/src/debugger/gui/CartE7Widget.cxx index 8053497fe..ebd711228 100644 --- a/src/debugger/gui/CartE7Widget.cxx +++ b/src/debugger/gui/CartE7Widget.cxx @@ -66,7 +66,7 @@ void CartridgeE7Widget::initialize(GuiObject* boss, const uInt32 size = cart.romBankCount() * CartridgeE7::BANK_SIZE; constexpr int xpos = 2; - int ypos = addBaseInformation(size, "M Network", info.str(), 15) + myLineHeight; + int ypos = addBaseInformation(size, "M Network", info.view(), 15) + myLineHeight; VariantList items0, items1; for(int i = 0; i < cart.romBankCount(); ++i) diff --git a/src/debugger/gui/CartEnhancedWidget.cxx b/src/debugger/gui/CartEnhancedWidget.cxx index 18ccf6138..06ee13c97 100644 --- a/src/debugger/gui/CartEnhancedWidget.cxx +++ b/src/debugger/gui/CartEnhancedWidget.cxx @@ -197,8 +197,8 @@ void CartridgeEnhancedWidget::bankList(uInt16 bankCount, int seg, VariantList& i if(myCart.hotspot() != 0 && myHotspotDelta > 0) buf << " " << hotspotStr(bank, seg); - VarList::push_back(items, buf.str()); - width = std::max(width, _font.getStringWidth(buf.str())); + VarList::push_back(items, buf.view()); + width = std::max(width, _font.getStringWidth(buf.view())); } } @@ -229,7 +229,7 @@ void CartridgeEnhancedWidget::bankSelect(int& ypos) buf << " "; // align with info myBankWidgets[seg] = new PopUpWidget(_boss, _font, xpos, ypos - 2, - pw, myLineHeight, items, buf.str(), + pw, myLineHeight, items, buf.view(), 0, kBankChanged); myBankWidgets[seg]->setTarget(this); myBankWidgets[seg]->setID(seg); @@ -338,14 +338,14 @@ void CartridgeEnhancedWidget::loadConfig() for(auto i: arr) buf << Common::Base::HEX2 << static_cast(i) << " "; - myPlusROMSendWidget->setText(buf.str(), arr != myOldState.send); + myPlusROMSendWidget->setText(buf.view(), arr != myOldState.send); buf.str(""); arr = myCart.myPlusROM->getReceive(); for(auto i: arr) buf << Common::Base::HEX2 << static_cast(i) << " "; - myPlusROMReceiveWidget->setText(buf.str(), arr != myOldState.receive); + myPlusROMReceiveWidget->setText(buf.view(), arr != myOldState.receive); } if(myBankWidgets != nullptr) { diff --git a/src/debugger/gui/CartRamWidget.cxx b/src/debugger/gui/CartRamWidget.cxx index 9a4b52ccf..e68529479 100644 --- a/src/debugger/gui/CartRamWidget.cxx +++ b/src/debugger/gui/CartRamWidget.cxx @@ -55,7 +55,7 @@ CartRamWidget::CartRamWidget( buf << " / " << (ramsize/1024) << "KB"; etw = new EditTextWidget(boss, nfont, xpos+lwidth, ypos - 1, - fwidth, myLineHeight, buf.str()); + fwidth, myLineHeight, buf.view()); etw->setEditable(false); ypos += myLineHeight + 4; diff --git a/src/debugger/gui/CpuWidget.cxx b/src/debugger/gui/CpuWidget.cxx index 7ae8b892c..5d5791047 100644 --- a/src/debugger/gui/CpuWidget.cxx +++ b/src/debugger/gui/CpuWidget.cxx @@ -203,7 +203,7 @@ void CpuWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) // event the rest of the debugger widgets ostringstream command; command << "pc #" << value; - instance().debugger().run(command.str()); + instance().debugger().run(command.view()); break; } diff --git a/src/debugger/gui/DelayQueueWidget.cxx b/src/debugger/gui/DelayQueueWidget.cxx index f38433e99..7d7d6eb2f 100644 --- a/src/debugger/gui/DelayQueueWidget.cxx +++ b/src/debugger/gui/DelayQueueWidget.cxx @@ -85,10 +85,10 @@ void DelayQueueWidget::loadConfig() { break; } - if(line != ss.str()) + if(line != ss.view()) { setDirty(); - line = ss.str(); + line = ss.view(); } delayQueueIterator->next(); } diff --git a/src/debugger/gui/FlashWidget.cxx b/src/debugger/gui/FlashWidget.cxx index 1388b59df..58e101b1d 100644 --- a/src/debugger/gui/FlashWidget.cxx +++ b/src/debugger/gui/FlashWidget.cxx @@ -105,7 +105,7 @@ void FlashWidget::loadConfig() label << " "; label << ": " << Common::Base::HEX4 << from << "-" << Common::Base::HEX4 << to; } - myPage[useCount]->setLabel(label.str()); + myPage[useCount]->setLabel(label.view()); startPage = -1; if(++useCount == MAX_PAGES) diff --git a/src/debugger/gui/NullControlWidget.hxx b/src/debugger/gui/NullControlWidget.hxx index 51130e1a3..45ffd4a76 100644 --- a/src/debugger/gui/NullControlWidget.hxx +++ b/src/debugger/gui/NullControlWidget.hxx @@ -47,10 +47,10 @@ class NullControlWidget : public ControllerWidget { ostringstream buf; buf << getHeader(); - const int lwidth = std::max(font.getStringWidth(buf.str()), + const int lwidth = std::max(font.getStringWidth(buf.view()), font.getStringWidth("Controller input")); - new StaticTextWidget(boss, font, x, y + 2, lwidth, fontHeight, buf.str()); + new StaticTextWidget(boss, font, x, y + 2, lwidth, fontHeight, buf.view()); y += 2 + lineHeight * 2; new StaticTextWidget(boss, font, x, y, lwidth, fontHeight, "Controller input", TextAlign::Center); diff --git a/src/debugger/gui/RomWidget.cxx b/src/debugger/gui/RomWidget.cxx index 15a44a0a5..74f6bf3ea 100644 --- a/src/debugger/gui/RomWidget.cxx +++ b/src/debugger/gui/RomWidget.cxx @@ -181,7 +181,7 @@ void RomWidget::setPC(int disasm_line) { ostringstream command; command << "pc #" << address; - instance().debugger().run(command.str()); + instance().debugger().run(command.view()); } } @@ -194,7 +194,7 @@ void RomWidget::runtoPC(int disasm_line) { ostringstream command; command << "runtopc #" << address; - const string& msg = instance().debugger().run(command.str()); + const string& msg = instance().debugger().run(command.view()); instance().frameBuffer().showTextMessage(msg); } } @@ -208,7 +208,7 @@ void RomWidget::setTimer(int disasm_line) { ostringstream command; command << "timer #" << address << " " << instance().debugger().cartDebug().getBank(address); - const string& msg = instance().debugger().run(command.str()); + const string& msg = instance().debugger().run(command.view()); instance().frameBuffer().showTextMessage(msg); } } @@ -244,7 +244,7 @@ void RomWidget::patchROM(int disasm_line, string_view bytes, Common::Base::setFormat(base); command << "rom #" << address << " " << bytes; - instance().debugger().run(command.str()); + instance().debugger().run(command.view()); // Restore previous base Common::Base::setFormat(oldbase); diff --git a/src/debugger/gui/TiaOutputWidget.cxx b/src/debugger/gui/TiaOutputWidget.cxx index 2d6ef2bc6..01f322225 100644 --- a/src/debugger/gui/TiaOutputWidget.cxx +++ b/src/debugger/gui/TiaOutputWidget.cxx @@ -97,12 +97,12 @@ void TiaOutputWidget::saveSnapshot(int execDepth, string_view execPrefix, buf.str(""); suffix.str(""); suffix << "_" << i; - buf << sspath.str() << suffix.str() << ".png"; - const FSNode next(buf.str()); + buf << sspath.view() << suffix.view() << ".png"; + const FSNode next(buf.view()); if(!next.exists()) break; } - sspath << suffix.str(); + sspath << suffix.view(); } } sspath << ".png"; @@ -166,7 +166,7 @@ void TiaOutputWidget::handleCommand(CommandSender* sender, int cmd, int data, in if(lines > 0) { command << "scanLine #" << lines; - const string message = instance().debugger().parser().run(command.str()); + const string message = instance().debugger().parser().run(command.view()); instance().frameBuffer().showTextMessage(message); } } @@ -175,7 +175,7 @@ void TiaOutputWidget::handleCommand(CommandSender* sender, int cmd, int data, in ostringstream command; const int scanline = myClickY + startLine; command << "breakIf _scan==#" << scanline; - const string& message = instance().debugger().parser().run(command.str()); + const string& message = instance().debugger().parser().run(command.view()); instance().frameBuffer().showTextMessage(message); } else if(rmb == "zoom") diff --git a/src/debugger/gui/TiaZoomWidget.cxx b/src/debugger/gui/TiaZoomWidget.cxx index 14779e2e4..4b11b5fc3 100644 --- a/src/debugger/gui/TiaZoomWidget.cxx +++ b/src/debugger/gui/TiaZoomWidget.cxx @@ -255,7 +255,7 @@ void TiaZoomWidget::handleCommand(CommandSender* sender, int cmd, int data, int if(lines > 0) { command << "scanline #" << lines; - const string& message = instance().debugger().parser().run(command.str()); + const string& message = instance().debugger().parser().run(command.view()); instance().frameBuffer().showTextMessage(message); } } @@ -264,7 +264,7 @@ void TiaZoomWidget::handleCommand(CommandSender* sender, int cmd, int data, int ostringstream command; const int scanline = myClickY / myZoomLevel + myOffY + startLine; command << "breakif _scan==#" << scanline; - const string& message = instance().debugger().parser().run(command.str()); + const string& message = instance().debugger().parser().run(command.view()); instance().frameBuffer().showTextMessage(message); } else diff --git a/src/emucore/CartCreator.cxx b/src/emucore/CartCreator.cxx index 3cf5a3c46..72f9946a7 100644 --- a/src/emucore/CartCreator.cxx +++ b/src/emucore/CartCreator.cxx @@ -179,7 +179,7 @@ unique_ptr CartCreator::create(const FSNode& file, buf << " " << Bankswitch::typeToName(detectedType); buf << ") "; - cartridge->setAbout(buf.str(), Bankswitch::typeToName(type), id); + cartridge->setAbout(buf.view(), Bankswitch::typeToName(type), id); return cartridge; } @@ -207,7 +207,7 @@ CartCreator::createFromMultiCart(const ByteBuffer& image, size_t& size, md5 = MD5::hash(slice, size); ostringstream buf; buf << " [G" << (i+1) << "]"; - id = buf.str(); + id = buf.view(); // TODO: allow using ROM properties instead of autodetect only if(size <= 2_KB) diff --git a/src/emucore/CartDetector.cxx b/src/emucore/CartDetector.cxx index 523904a62..73165d12b 100755 --- a/src/emucore/CartDetector.cxx +++ b/src/emucore/CartDetector.cxx @@ -258,7 +258,7 @@ Bankswitch::Type CartDetector::autodetectType(const ByteBuffer& image, size_t si ostringstream ss; ss << "Bankswitching type '" << Bankswitch::typeToDesc(type) << "' detected"; - Logger::debug(ss.str()); + Logger::debug(ss.view()); return type; } diff --git a/src/emucore/CartEnhanced.cxx b/src/emucore/CartEnhanced.cxx index 0fd9c476d..ee5e98c6b 100644 --- a/src/emucore/CartEnhanced.cxx +++ b/src/emucore/CartEnhanced.cxx @@ -35,14 +35,14 @@ CartridgeEnhanced::CartridgeEnhanced(const ByteBuffer& image, size_t size, ostringstream buf; buf << "ROM larger than expected (" << size << " > " << bsSize << "), truncating " << (size - bsSize) << " bytes\n"; - Logger::info(buf.str()); + Logger::info(buf.view()); } else if(size < bsSize) { ostringstream buf; buf << "ROM smaller than expected (" << size << " < " << bsSize << "), appending " << (bsSize - size) << " bytes\n"; - Logger::info(buf.str()); + Logger::info(buf.view()); } mySize = bsSize; diff --git a/src/emucore/Console.cxx b/src/emucore/Console.cxx index cc7b636bc..3a0590959 100644 --- a/src/emucore/Console.cxx +++ b/src/emucore/Console.cxx @@ -130,7 +130,7 @@ Console::Console(OSystem& osystem, unique_ptr& cart, #ifdef DEBUG_BUILD ostringstream msg; msg << "Phosphor effect automatically " << (enable ? "enabled" : "disabled"); - frameBuffer.showTextMessage(msg.str()); + frameBuffer.showTextMessage(msg.view()); #endif }; myTIA = make_unique(*this, [this]() { return timing(); }, myOSystem.settings(), callback); @@ -576,7 +576,7 @@ void Console::toggleInter(bool toggle) ostringstream ss; ss << "Interpolation " << (enabled ? "enabled" : "disabled"); - myOSystem.frameBuffer().showTextMessage(ss.str()); + myOSystem.frameBuffer().showTextMessage(ss.view()); } else myOSystem.frameBuffer().showTextMessage( @@ -598,7 +598,7 @@ void Console::toggleTurbo() ostringstream ss; ss << "Turbo mode " << (!enabled ? "enabled" : "disabled"); - myOSystem.frameBuffer().showTextMessage(ss.str()); + myOSystem.frameBuffer().showTextMessage(ss.view()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -623,7 +623,7 @@ void Console::changeSpeed(int direction) ostringstream val; val << formatSpeed(speed) << "%"; - myOSystem.frameBuffer().showGaugeMessage("Emulation speed", val.str(), speed, MIN_SPEED, MAX_SPEED); + myOSystem.frameBuffer().showGaugeMessage("Emulation speed", val.view(), speed, MIN_SPEED, MAX_SPEED); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -646,7 +646,7 @@ void Console::togglePhosphor(bool toggle) ostringstream msg; msg << "Phosphor effect " << (enable ? "enabled" : "disabled"); - myOSystem.frameBuffer().showTextMessage(msg.str()); + myOSystem.frameBuffer().showTextMessage(msg.view()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -689,7 +689,7 @@ void Console::cyclePhosphorMode(int direction) } ostringstream msg; msg << "Phosphor mode " << MESSAGES[mode]; - myOSystem.frameBuffer().showTextMessage(msg.str()); + myOSystem.frameBuffer().showTextMessage(msg.view()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -705,7 +705,7 @@ void Console::changePhosphor(int direction) ostringstream val; val << blend; - myProperties.set(PropType::Display_PPBlend, val.str()); + myProperties.set(PropType::Display_PPBlend, val.view()); if(blend) val << "%"; else @@ -713,7 +713,7 @@ void Console::changePhosphor(int direction) val.str(""); val << "Off"; } - myOSystem.frameBuffer().showGaugeMessage("Phosphor blend", val.str(), blend); + myOSystem.frameBuffer().showGaugeMessage("Phosphor blend", val.view(), blend); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -802,11 +802,11 @@ void Console::changeVerticalCenter(int direction) ostringstream ss, val; ss << vcenter; - myProperties.set(PropType::Display_VCenter, ss.str()); + myProperties.set(PropType::Display_VCenter, ss.view()); if (vcenter != myTIA->vcenter()) myTIA->setVcenter(vcenter); val << (vcenter ? vcenter > 0 ? "+" : "" : " ") << vcenter << "px"; - myOSystem.frameBuffer().showGaugeMessage("V-Center", val.str(), vcenter, + myOSystem.frameBuffer().showGaugeMessage("V-Center", val.view(), vcenter, myTIA->minVcenter(), myTIA->maxVcenter()); } @@ -836,7 +836,7 @@ void Console::changeVSizeAdjust(int direction) val << (newAdjustVSize ? newAdjustVSize > 0 ? "+" : "" : " ") << newAdjustVSize << "%"; - myOSystem.frameBuffer().showGaugeMessage("V-Size", val.str(), newAdjustVSize, -5, 5); + myOSystem.frameBuffer().showGaugeMessage("V-Size", val.view(), newAdjustVSize, -5, 5); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -979,7 +979,7 @@ void Console::changeLeftController(int direction) ostringstream msg; msg << "Left controller " << Controller::getName(Controller::Type{type}); - myOSystem.frameBuffer().showTextMessage(msg.str()); + myOSystem.frameBuffer().showTextMessage(msg.view()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -996,7 +996,7 @@ void Console::changeRightController(int direction) ostringstream msg; msg << "Right controller " << Controller::getName(Controller::Type{type}); - myOSystem.frameBuffer().showTextMessage(msg.str()); + myOSystem.frameBuffer().showTextMessage(msg.view()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1152,7 +1152,7 @@ void Console::toggleSwapPorts(bool toggle) ostringstream msg; msg << "Swap ports " << (swapped ? "enabled" : "disabled"); - myOSystem.frameBuffer().showTextMessage(msg.str()); + myOSystem.frameBuffer().showTextMessage(msg.view()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1170,7 +1170,7 @@ void Console::toggleSwapPaddles(bool toggle) ostringstream msg; msg << "Swap paddles " << (swapped ? "enabled" : "disabled"); - myOSystem.frameBuffer().showTextMessage(msg.str()); + myOSystem.frameBuffer().showTextMessage(msg.view()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1184,7 +1184,7 @@ void Console::changePaddleCenterX(int direction) ostringstream val; val << (center ? center > 0 ? "+" : "" : " ") << center * 5 << "px"; - myOSystem.frameBuffer().showGaugeMessage("Paddles x-center ", val.str(), center, + myOSystem.frameBuffer().showGaugeMessage("Paddles x-center ", val.view(), center, Paddles::MIN_ANALOG_CENTER, Paddles::MAX_ANALOG_CENTER); } @@ -1199,7 +1199,7 @@ void Console::changePaddleCenterY(int direction) ostringstream val; val << (center ? center > 0 ? "+" : "" : " ") << center * 5 << "px"; - myOSystem.frameBuffer().showGaugeMessage("Paddles y-center ", val.str(), center, + myOSystem.frameBuffer().showGaugeMessage("Paddles y-center ", val.view(), center, Paddles::MIN_ANALOG_CENTER, Paddles::MAX_ANALOG_CENTER); } @@ -1221,13 +1221,13 @@ void Console::changePaddleAxesRange(int direction) control << mode; if(range != 100) control << " " << std::to_string(range); - myProperties.set(PropType::Controller_MouseAxis, control.str()); + myProperties.set(PropType::Controller_MouseAxis, control.view()); Paddles::setDigitalPaddleRange(range); ostringstream val; val << range << "%"; - myOSystem.frameBuffer().showGaugeMessage("Mouse axes range", val.str(), range); + myOSystem.frameBuffer().showGaugeMessage("Mouse axes range", val.view(), range); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1244,7 +1244,7 @@ void Console::toggleAutoFire(bool toggle) ostringstream ss; ss << "Autofire " << (enabled ? "enabled" : "disabled"); - myOSystem.frameBuffer().showTextMessage(ss.str()); + myOSystem.frameBuffer().showTextMessage(ss.view()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1271,7 +1271,7 @@ void Console::changeAutoFireRate(int direction) else val << "Off"; - myOSystem.frameBuffer().showGaugeMessage("Autofire rate", val.str(), rate, 0, isNTSC ? 30 : 25); + myOSystem.frameBuffer().showGaugeMessage("Autofire rate", val.view(), rate, 0, isNTSC ? 30 : 25); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1392,7 +1392,7 @@ void Console::changeJitterSense(int direction) const myTIA->setJitterSensitivity(sensitivity); myOSystem.settings().setValue(prefix + "tv.jitter_sense", sensitivity); val << sensitivity; - myOSystem.frameBuffer().showGaugeMessage("TV jitter sensitivity", val.str(), sensitivity, + myOSystem.frameBuffer().showGaugeMessage("TV jitter sensitivity", val.view(), sensitivity, 0, JitterEmulation::MAX_SENSITIVITY); } else @@ -1425,8 +1425,8 @@ void Console::changeJitterRecovery(int direction) const myTIA->setJitterRecoveryFactor(recovery); myOSystem.settings().setValue(prefix + "tv.jitter_recovery", recovery); val << recovery; - myOSystem.frameBuffer().showGaugeMessage("TV jitter roll", val.str(), recovery, - 0, JitterEmulation::MAX_RECOVERY); + myOSystem.frameBuffer().showGaugeMessage("TV jitter roll", val.view(), + recovery, 0, JitterEmulation::MAX_RECOVERY); } else { diff --git a/src/emucore/Control.hxx b/src/emucore/Control.hxx index 41e21beee..682845ed9 100644 --- a/src/emucore/Control.hxx +++ b/src/emucore/Control.hxx @@ -114,8 +114,8 @@ class Controller : public Serializable /** Callback type for general controller messages */ - using onMessageCallback = std::function; - using onMessageCallbackForced = std::function; + using onMessageCallback = std::function; + using onMessageCallbackForced = std::function; public: /** diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index b130e8ab7..61e88c695 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -205,7 +205,7 @@ void EventHandler::toggleAllow4JoyDirections(bool toggle) ostringstream ss; ss << "Allow all 4 joystick directions "; ss << (joyAllow4 ? "enabled" : "disabled"); - myOSystem.frameBuffer().showTextMessage(ss.str()); + myOSystem.frameBuffer().showTextMessage(ss.view()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -2351,7 +2351,7 @@ VariantList EventHandler::getComboList() if(event < Event::Combo1 || event > Event::Combo16) { buf << i; - VarList::push_back(l, EventHandler::ourEmulActionList[i].action, buf.str()); + VarList::push_back(l, EventHandler::ourEmulActionList[i].action, buf.view()); buf.str(""); } } @@ -2594,7 +2594,7 @@ void EventHandler::changeMouseControllerMode(int direction) ostringstream ss; ss << "Mouse controls " << MSG[i] << " devices"; - myOSystem.frameBuffer().showTextMessage(ss.str()); + myOSystem.frameBuffer().showTextMessage(ss.view()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -2609,7 +2609,7 @@ void EventHandler::changeMouseCursor(int direction) ss << "Mouse cursor visibilility: " << ((cursor & 2) ? "+" : "-") << "UI, " << ((cursor & 1) ? "+" : "-") << "Emulation"; - myOSystem.frameBuffer().showTextMessage(ss.str()); + myOSystem.frameBuffer().showTextMessage(ss.view()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index f6b80e353..c5ffe4cb9 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -721,7 +721,7 @@ void FrameBuffer::drawFrameStats(float framesPerSecond) << "Hz => " << info.DisplayFormat; - myStatsMsg.surface->drawString(f, ss.str(), xPos, yPos, + myStatsMsg.surface->drawString(f, ss.view(), xPos, yPos, myStatsMsg.w, color, TextAlign::Left, 0, true, kBGColor); yPos += dy; @@ -736,7 +736,7 @@ void FrameBuffer::drawFrameStats(float framesPerSecond) : myOSystem.settings().getFloat("speed")) << "% speed"; - myStatsMsg.surface->drawString(f, ss.str(), xPos, yPos, + myStatsMsg.surface->drawString(f, ss.view(), xPos, yPos, myStatsMsg.w, myStatsMsg.color, TextAlign::Left, 0, true, kBGColor); yPos += dy; @@ -744,7 +744,7 @@ void FrameBuffer::drawFrameStats(float framesPerSecond) ss << info.BankSwitch; int xPosEnd = - myStatsMsg.surface->drawString(f, ss.str(), xPos, yPos, + myStatsMsg.surface->drawString(f, ss.view(), xPos, yPos, myStatsMsg.w, myStatsMsg.color, TextAlign::Left, 0, true, kBGColor); if(myOSystem.settings().getBool("dev.settings")) @@ -760,7 +760,7 @@ void FrameBuffer::drawFrameStats(float framesPerSecond) color = kDbgColorRed; ss << "VSYNC!"; } - myStatsMsg.surface->drawString(f, ss.str(), xPosEnd, yPos, + myStatsMsg.surface->drawString(f, ss.view(), xPosEnd, yPos, myStatsMsg.w, color, TextAlign::Left, 0, true, kBGColor); } @@ -1174,7 +1174,7 @@ void FrameBuffer::toggleFullscreen(bool toggle) else msg << "disabled"; } - showTextMessage(msg.str()); + showTextMessage(msg.view()); } break; } @@ -1207,7 +1207,7 @@ void FrameBuffer::toggleAdaptRefresh(bool toggle) msg << (isAdaptRefresh ? "enabled" : "disabled"); msg << " (" << myBackend->refreshRate() << " Hz)"; - showTextMessage(msg.str()); + showTextMessage(msg.view()); } } #endif @@ -1233,7 +1233,7 @@ void FrameBuffer::changeOverscan(int direction) val << (overscan > 0 ? "+" : "" ) << overscan << "%"; else val << "Off"; - myOSystem.frameBuffer().showGaugeMessage("Overscan", val.str(), overscan, 0, 10); + myOSystem.frameBuffer().showGaugeMessage("Overscan", val.view(), overscan, 0, 10); } } diff --git a/src/emucore/KidVid.cxx b/src/emucore/KidVid.cxx index 6fefbdb0a..36d2f504c 100644 --- a/src/emucore/KidVid.cxx +++ b/src/emucore/KidVid.cxx @@ -118,8 +118,8 @@ void KidVid::update() } if(myTape) { - static constexpr uInt32 gameNumber[4] = { 3, 1, 2, 3 }; - static constexpr string_view gameName[6] = { + static constexpr std::array gameNumber = { 3, 1, 2, 3 }; + static constexpr std::array gameName = { "Harmony Smurf", "Handy Smurf", "Greedy Smurf", "Big Number Hunt", "Great Letter Roundup", "Spooky Spelling Bee" }; @@ -132,7 +132,7 @@ void KidVid::update() ostringstream msg; msg << "Game #" << gameNumber[myTape - 1] << " - \"" << gameName[gameNumber[myTape - 1] + (myGame == Game::Smurfs ? -1 : 2)] << "\""; - myCallback(msg.str(), true); + myCallback(msg.view(), true); } } @@ -239,9 +239,9 @@ bool KidVid::load(Serializer& in) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const char* KidVid::getFileName() const +string KidVid::getFileName() const { - static constexpr const char* const fileNames[6] = { + static constexpr std::array fileNames = { "KVS3.WAV", "KVS1.WAV", "KVS2.WAV", "KVB3.WAV", "KVB1.WAV", "KVB2.WAV" }; @@ -256,7 +256,7 @@ const char* KidVid::getFileName() const void KidVid::openSampleFiles() { #ifdef SOUND_SUPPORT - static constexpr uInt32 firstSongPointer[6] = { + static constexpr std::array firstSongPointer = { 44 + 38, 0, 44, @@ -302,7 +302,7 @@ void KidVid::setNextSong() ourSongStart[temp], mySongLength); ostringstream msg; msg << "Read song #" << mySongPointer << " (" << fileName << ")"; - myCallback(msg.str(), false); + myCallback(msg.view(), false); #ifdef DEBUG_BUILD cerr << fileName << ": " << (ourSongPositions[mySongPointer] & 0x7f) << '\n'; diff --git a/src/emucore/KidVid.hxx b/src/emucore/KidVid.hxx index 54439e088..5141f5200 100644 --- a/src/emucore/KidVid.hxx +++ b/src/emucore/KidVid.hxx @@ -93,7 +93,7 @@ class KidVid : public Controller private: // Get name of the current sample file - const char* getFileName() const; + string getFileName() const; // Open/close a WAV sample file void openSampleFiles(); diff --git a/src/emucore/M6502.cxx b/src/emucore/M6502.cxx index 21c3b59c9..b7bc92533 100644 --- a/src/emucore/M6502.cxx +++ b/src/emucore/M6502.cxx @@ -131,7 +131,7 @@ inline uInt8 M6502::peek(uInt16 address, Device::AccessFlags flags) stringstream msg; msg << "RTrap" << (flags == DISASM_NONE ? "G[" : "[") << Common::Base::HEX2 << cond << "]" << (myTrapCondNames[cond].empty() ? ": " : "If: {" + myTrapCondNames[cond] + "} "); - myHitTrapInfo.message = msg.str(); + myHitTrapInfo.message = msg.view(); myHitTrapInfo.address = address; } } @@ -166,7 +166,7 @@ inline void M6502::poke(uInt16 address, uInt8 value, Device::AccessFlags flags) myJustHitWriteTrapFlag = true; stringstream msg; msg << "WTrap[" << Common::Base::HEX2 << cond << "]" << (myTrapCondNames[cond].empty() ? ":" : "If: {" + myTrapCondNames[cond] + "}"); - myHitTrapInfo.message = msg.str(); + myHitTrapInfo.message = msg.view(); myHitTrapInfo.address = address; } } @@ -289,7 +289,7 @@ inline void M6502::_execute(uInt64 cycles, DispatchResult& result) msg << "BP: $" << Common::Base::HEX4 << PC << ", bank #" << std::dec << static_cast(bank); - result.setDebugger(currentCycles, msg.str(), "Breakpoint"); + result.setDebugger(currentCycles, msg.view(), "Breakpoint"); return; } } @@ -309,12 +309,12 @@ inline void M6502::_execute(uInt64 cycles, DispatchResult& result) if(myLogBreaks) { msg << "CBP[" << Common::Base::HEX2 << cond << "]:"; - myDebugger->log(msg.str()); + myDebugger->log(msg.view()); } else { msg << "CBP[" << Common::Base::HEX2 << cond << "]: " << myCondBreakNames[cond]; - result.setDebugger(currentCycles, msg.str(), "Conditional breakpoint"); + result.setDebugger(currentCycles, msg.view(), "Conditional breakpoint"); return; } } @@ -333,7 +333,7 @@ inline void M6502::_execute(uInt64 cycles, DispatchResult& result) { ostringstream msg; msg << "conditional savestate [" << Common::Base::HEX2 << cond << "]"; - myDebugger->addState(msg.str()); + myDebugger->addState(msg.view()); } mySystem->cart().clearAllRAMAccesses(); @@ -376,7 +376,7 @@ inline void M6502::_execute(uInt64 cycles, DispatchResult& result) { ostringstream msg; msg << "RWP[@ $" << Common::Base::HEX4 << rwpAddr << "]: "; - result.setDebugger(currentCycles, msg.str(), "Read from write port", oldPC); + result.setDebugger(currentCycles, msg.view(), "Read from write port", oldPC); return; } } @@ -388,7 +388,7 @@ inline void M6502::_execute(uInt64 cycles, DispatchResult& result) { ostringstream msg; msg << "WRP[@ $" << Common::Base::HEX4 << wrpAddr << "]: "; - result.setDebugger(currentCycles, msg.str(), "Write to read port", oldPC); + result.setDebugger(currentCycles, msg.view(), "Write to read port", oldPC); return; } } diff --git a/src/emucore/MD5.hxx b/src/emucore/MD5.hxx index 388186786..b3f404fbc 100644 --- a/src/emucore/MD5.hxx +++ b/src/emucore/MD5.hxx @@ -68,13 +68,6 @@ class MD5 */ static string hash(const ByteBuffer& buffer, size_t length); static string hash(const uInt8* buffer, size_t length); - /** - Ditto. - - @param buffer The message to compute the digest of - - @return The message - digest - */ static string hash(string_view buffer); public: diff --git a/src/emucore/OSystem.cxx b/src/emucore/OSystem.cxx index 92c6d5898..f5aee6402 100644 --- a/src/emucore/OSystem.cxx +++ b/src/emucore/OSystem.cxx @@ -96,7 +96,7 @@ OSystem::OSystem() ostringstream info; info << "Build " << STELLA_BUILD << ", using " << MediaFactory::backendName() << " [" << BSPF::ARCH << "]"; - myBuildInfo = info.str(); + myBuildInfo = info.view(); mySettings = MediaFactory::createSettings(); @@ -138,7 +138,7 @@ bool OSystem::initialize(const Settings::Options& options) << myCheatFile.getShortPath() << "'\n" << "Palette file: '" << myPaletteFile.getShortPath() << "'\n"; - Logger::info(buf.str()); + Logger::info(buf.view()); // NOTE: The framebuffer MUST be created before any other object!!! // Get relevant information about the video hardware @@ -470,7 +470,7 @@ string OSystem::createConsole(const FSNode& rom, string_view md5sum, bool newrom catch(const runtime_error& e) { buf << "ERROR: " << e.what(); - Logger::error(buf.str()); + Logger::error(buf.view()); return buf.str(); } @@ -517,7 +517,7 @@ string OSystem::createConsole(const FSNode& rom, string_view md5sum, bool newrom if(propsFile.exists()) buf << " PRO file: " << propsFile.getShortPath() << '\n'; buf << '\n' << getROMInfo(*myConsole); - Logger::info(buf.str()); + Logger::info(buf.view()); myFrameBuffer->setCursorState(); @@ -539,14 +539,14 @@ string OSystem::createConsole(const FSNode& rom, string_view md5sum, bool newrom << " - " << myConsole->cartridge().detectedType() << (myConsole->cartridge().isPlusROM() ? " PlusROM " : "") << " - " << myConsole->getFormatString(); - myFrameBuffer->showTextMessage(msg.str()); + myFrameBuffer->showTextMessage(msg.view()); } else if(!myLauncherUsed) { ostringstream msg; msg << "Stella " << STELLA_VERSION; - myFrameBuffer->showTextMessage(msg.str()); + myFrameBuffer->showTextMessage(msg.view()); } } diff --git a/src/emucore/PlusROM.cxx b/src/emucore/PlusROM.cxx index 3680d2c87..fb4d75815 100644 --- a/src/emucore/PlusROM.cxx +++ b/src/emucore/PlusROM.cxx @@ -91,7 +91,7 @@ class PlusROMRequest { httplib::Client client(myDestination.host); const httplib::Headers headers = { - {"PlusROM-Info", content.str()} + {"PlusROM-Info", content.str()} // httplib can't accept string_view }; client.set_connection_timeout(milliseconds(CONNECTION_TIMEOUT_MSEC)); @@ -115,7 +115,7 @@ class PlusROMRequest { << myDestination.path << ": failed"; - Logger::error(ss.str()); + Logger::error(ss.view()); myState = State::failed; @@ -132,7 +132,7 @@ class PlusROMRequest { << ": failed with HTTP status " << response->status; - Logger::error(ss.str()); + Logger::error(ss.view()); myState = State::failed; @@ -143,7 +143,7 @@ class PlusROMRequest { ostringstream ss; ss << "PlusCart: request to " << myDestination.host << "/" << myDestination.path << ": invalid response"; - Logger::error(ss.str()); + Logger::error(ss.view()); myState = State::failed; diff --git a/src/emucore/Settings.cxx b/src/emucore/Settings.cxx index cdafa49b4..09a20c219 100644 --- a/src/emucore/Settings.cxx +++ b/src/emucore/Settings.cxx @@ -824,7 +824,7 @@ void Settings::usage() // // if(NULL != GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi)) // height = csbi.srWindow.Bottom - csbi.srWindow.Top + 1; - cout << buf.str() << std::flush; + cout << buf.view() << std::flush; #endif #if defined(BSPF_UNIX) || defined(BSPF_MACOS) diff --git a/src/emucore/TIASurface.cxx b/src/emucore/TIASurface.cxx index fcab48c53..678265278 100644 --- a/src/emucore/TIASurface.cxx +++ b/src/emucore/TIASurface.cxx @@ -164,7 +164,7 @@ void TIASurface::setNTSC(NTSCFilter::Preset preset, bool show) } myOSystem.settings().setValue("tv.filter", static_cast(preset)); - if(show) myFB.showTextMessage(buf.str()); + if(show) myFB.showTextMessage(buf.view()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -247,7 +247,7 @@ void TIASurface::changeScanlineIntensity(int direction) buf << intensity << "%"; else buf << "Off"; - myFB.showGaugeMessage("Scanline intensity", buf.str(), intensity); + myFB.showGaugeMessage("Scanline intensity", buf.view(), intensity); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -299,7 +299,7 @@ void TIASurface::cycleScanlineMask(int direction) ostringstream msg; msg << "Scanline data '" << Names[i] << "'"; - myOSystem.frameBuffer().showTextMessage(msg.str()); + myOSystem.frameBuffer().showTextMessage(msg.view()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/Thumbulator.cxx b/src/emucore/Thumbulator.cxx index c6a646110..03bf5ce33 100644 --- a/src/emucore/Thumbulator.cxx +++ b/src/emucore/Thumbulator.cxx @@ -191,7 +191,7 @@ string Thumbulator::doRun(uInt32& cycles, bool irqDrivenAudio) #endif #if defined(THUMB_DISS) || defined(THUMB_DBUG) dump_counters(); - cout << statusMsg.str() << '\n'; + cout << statusMsg.view() << '\n'; return statusMsg.str(); #else return ""; diff --git a/src/gui/DeveloperDialog.cxx b/src/gui/DeveloperDialog.cxx index 2df91e469..3e5a57873 100644 --- a/src/gui/DeveloperDialog.cxx +++ b/src/gui/DeveloperDialog.cxx @@ -324,7 +324,7 @@ void DeveloperDialog::addTiaTab(const GUI::Font& font) ostringstream ss; ss << "Delayed VDEL" << ELLIPSIS << " swap for"; - mySwapLabel = new StaticTextWidget(myTab, font, HBORDER + INDENT * 2, ypos + 1, ss.str()); + mySwapLabel = new StaticTextWidget(myTab, font, HBORDER + INDENT * 2, ypos + 1, ss.view()); mySwapLabel->setToolTip("VDELed objects react one color clock slower to updates."); wid.push_back(mySwapLabel); ypos += lineHeight + VGAP * 1; diff --git a/src/gui/EditableWidget.cxx b/src/gui/EditableWidget.cxx index ddce295ce..c857a490f 100644 --- a/src/gui/EditableWidget.cxx +++ b/src/gui/EditableWidget.cxx @@ -886,9 +886,9 @@ bool EditableWidget::pasteSelectedText() lastOk = false; } - _editString.insert(_caretPos, buf.str()); + _editString.insert(_caretPos, buf.view()); // position cursor at the end of pasted text - setCaretPos(_caretPos + static_cast(buf.str().length())); + setCaretPos(_caretPos + static_cast(buf.view().length())); if(selected || !pasted.empty()) { diff --git a/src/gui/EventMappingWidget.cxx b/src/gui/EventMappingWidget.cxx index c00dd5389..19c860816 100644 --- a/src/gui/EventMappingWidget.cxx +++ b/src/gui/EventMappingWidget.cxx @@ -205,7 +205,7 @@ void EventMappingWidget::startRemapping() << EventHandler::actionAtIndex(myActionSelected, myEventGroup) << "' event"; myKeyMapping->setTextColor(kTextColorEm); - myKeyMapping->setText(buf.str()); + myKeyMapping->setText(buf.view()); // Make sure that this widget receives all raw data, before any // pre-processing occurs diff --git a/src/gui/GameInfoDialog.cxx b/src/gui/GameInfoDialog.cxx index af8126297..51e6c63d7 100644 --- a/src/gui/GameInfoDialog.cxx +++ b/src/gui/GameInfoDialog.cxx @@ -947,12 +947,12 @@ void GameInfoDialog::loadHighScoresProperties(const Properties& props) ss.str(""); ss << hex << right // << setw(HSM::MAX_ADDR_CHARS) << setfill(' ') << uppercase << info.varsAddr; - myVarAddress->setText(ss.str()); + myVarAddress->setText(ss.view()); ss.str(""); ss << hex << right // << setw(HSM::MAX_ADDR_CHARS) << setfill(' ') << uppercase << info.specialAddr; - mySpecialAddress->setText(ss.str()); + mySpecialAddress->setText(ss.view()); for (uInt32 a = 0; a < HSM::MAX_SCORE_ADDR; ++a) @@ -963,7 +963,7 @@ void GameInfoDialog::loadHighScoresProperties(const Properties& props) ss << hex << right // << setw(HSM::MAX_ADDR_CHARS) << setfill(' ') << uppercase << info.scoreAddr[a]; } - myScoreAddress[a]->setText(ss.str()); + myScoreAddress[a]->setText(ss.view()); } updateHighScoresWidgets(); } @@ -1489,7 +1489,7 @@ void GameInfoDialog::setAddressVal(const EditTextWidget* addressWidget, EditText // ss << hex; ss << right // << setw(2) << setfill(' ') << uppercase << static_cast(val); - valWidget->setText(ss.str()); + valWidget->setText(ss.view()); } else valWidget->setText(""); diff --git a/src/gui/HighScoresDialog.cxx b/src/gui/HighScoresDialog.cxx index ad0457f8c..2a6dd05ea 100644 --- a/src/gui/HighScoresDialog.cxx +++ b/src/gui/HighScoresDialog.cxx @@ -235,7 +235,7 @@ void HighScoresDialog::loadConfig() { ostringstream buf; buf << std::setw(3) << std::setfill(' ') << i; - VarList::push_back(items, buf.str(), i); + VarList::push_back(items, buf.view(), i); } myVariationPopup->addItems(items); @@ -404,7 +404,7 @@ void HighScoresDialog::updateWidgets(bool init) if (myScores.scores[r].special > 0) buf << std::setw(HSM::MAX_SPECIAL_DIGITS) << std::setfill(' ') << myScores.scores[r].special; - mySpecialWidgets[r]->setLabel(buf.str()); + mySpecialWidgets[r]->setLabel(buf.view()); myNameWidgets[r]->setLabel(myScores.scores[r].name); myDateWidgets[r]->setLabel(myScores.scores[r].date); diff --git a/src/gui/JoystickDialog.cxx b/src/gui/JoystickDialog.cxx index 6db8f22d9..18acdf66d 100644 --- a/src/gui/JoystickDialog.cxx +++ b/src/gui/JoystickDialog.cxx @@ -140,7 +140,7 @@ void JoystickDialog::handleCommand(CommandSender* sender, int cmd, int data, int { ostringstream buf; buf << "C" << myJoyIDs[data]; - myJoyText->setText(buf.str()); + myJoyText->setText(buf.view()); myJoyPort->setSelected(myJoyPorts[data]); } else diff --git a/src/gui/LauncherDialog.cxx b/src/gui/LauncherDialog.cxx index b019b6695..e7e12f9fd 100644 --- a/src/gui/LauncherDialog.cxx +++ b/src/gui/LauncherDialog.cxx @@ -107,7 +107,7 @@ void LauncherDialog::addTitleWidget(int &ypos) ver << " for RetroN 77"; #endif new StaticTextWidget(this, _font, 1, ypos, _w - 2, fontHeight, - ver.str(), TextAlign::Center); + ver.view(), TextAlign::Center); ypos += fontHeight + VGAP; } @@ -551,7 +551,7 @@ void LauncherDialog::updateUI() ostringstream buf; buf << (myList->getList().size() - (currentDir().hasParent() ? 1 : 0)) << (myShortCount ? " items" : " items found"); - myRomCount->setLabel(buf.str()); + myRomCount->setLabel(buf.view()); loadRomInfo(); } diff --git a/src/gui/RomAuditDialog.cxx b/src/gui/RomAuditDialog.cxx index d47e7aeab..f6048a404 100644 --- a/src/gui/RomAuditDialog.cxx +++ b/src/gui/RomAuditDialog.cxx @@ -121,7 +121,7 @@ void RomAuditDialog::auditRoms() ProgressDialog progress(this, instance().frameBuffer().font()); buf << "Auditing ROM files" << ELLIPSIS; - progress.setMessage(buf.str()); + progress.setMessage(buf.view()); progress.setRange(0, static_cast(files.size()) - 1, 5); progress.open(); diff --git a/src/gui/RomImageWidget.cxx b/src/gui/RomImageWidget.cxx index 7055db5ea..9bced5563 100644 --- a/src/gui/RomImageWidget.cxx +++ b/src/gui/RomImageWidget.cxx @@ -574,13 +574,13 @@ void RomImageWidget::drawWidget(bool hilite) ostringstream buf; buf << myImageIdx + 1 << "/" << myImageList.size(); const int yText = _y + _h - _font.getFontHeight() * 10 / 8; - const int wText = _font.getStringWidth(buf.str()) + 8; + const int wText = _font.getStringWidth(buf.view()) + 8; s.fillRect(_x, yText, _w, _font.getFontHeight(), _bgcolor); if(!myLabel.empty()) s.drawString(_font, myLabel, _x + 8, yText, _w - wText - 16 - _font.getMaxCharWidth() * 2, _textcolor); if(!myImageList.empty()) - s.drawString(_font, buf.str(), _x + _w - wText, yText, wText, _textcolor); + s.drawString(_font, buf.view(), _x + _w - wText, yText, wText, _textcolor); // Draw the navigation icons myNavSurface->invalidate(); diff --git a/src/gui/VideoAudioDialog.cxx b/src/gui/VideoAudioDialog.cxx index 6dabd98de..932b22371 100644 --- a/src/gui/VideoAudioDialog.cxx +++ b/src/gui/VideoAudioDialog.cxx @@ -1147,7 +1147,7 @@ void VideoAudioDialog::handleShiftChanged(SliderWidget* widget) ss << std::setw(4) << std::fixed << std::setprecision(1) << (0.1 * (widget->getValue())) << DEGREE; - widget->setValueLabel(ss.str()); + widget->setValueLabel(ss.view()); handlePaletteUpdate(); } @@ -1384,14 +1384,14 @@ void VideoAudioDialog::handleCommand(CommandSender* sender, int cmd, { std::ostringstream ss; ss << std::fixed << std::setprecision(1) << (0.5 * myHeadroomSlider->getValue()) << " frames"; - myHeadroomSlider->setValueLabel(ss.str()); + myHeadroomSlider->setValueLabel(ss.view()); break; } case kBufferSizeChanged: { std::ostringstream ss; ss << std::fixed << std::setprecision(1) << (0.5 * myBufferSizeSlider->getValue()) << " frames"; - myBufferSizeSlider->setValueLabel(ss.str()); + myBufferSizeSlider->setValueLabel(ss.view()); break; } @@ -1445,7 +1445,7 @@ void VideoAudioDialog::colorPalette() const int color = order[type][idx]; ss << Common::Base::HEX1 << std::uppercase << color; - myColorLbl[idx]->setLabel(ss.str()); + myColorLbl[idx]->setLabel(ss.view()); for(int lum = 0; lum < NUM_LUMA; ++lum) myColor[idx][lum]->setColor(color * NUM_CHROMA + lum * 2); // skip grayscale colors }