mirror of https://github.com/stella-emu/stella.git
Convert 'const string&' to 'string_view', as per C++17 recommendations. WIP.
This commit is contained in:
parent
e1ef0045ac
commit
31cc0884db
|
@ -21,11 +21,11 @@
|
|||
#include "BankRomCheat.hxx"
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
BankRomCheat::BankRomCheat(OSystem& os, const string& name, const string& code)
|
||||
BankRomCheat::BankRomCheat(OSystem& os, string_view name, string_view code)
|
||||
: Cheat(os, name, code)
|
||||
{
|
||||
if(myCode.length() == 7)
|
||||
myCode = "0" + code;
|
||||
myCode = "0" + string{code};
|
||||
|
||||
bank = unhex(myCode.substr(0, 2));
|
||||
address = 0xf000 + unhex(myCode.substr(2, 3));
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
class BankRomCheat : public Cheat
|
||||
{
|
||||
public:
|
||||
BankRomCheat(OSystem& os, const string& name, const string& code);
|
||||
BankRomCheat(OSystem& os, string_view name, string_view code);
|
||||
~BankRomCheat() override = default;
|
||||
|
||||
bool enable() override;
|
||||
|
|
|
@ -25,7 +25,7 @@ class OSystem;
|
|||
class Cheat
|
||||
{
|
||||
public:
|
||||
Cheat(OSystem& osystem, const string& name, const string& code)
|
||||
Cheat(OSystem& osystem, string_view name, string_view code)
|
||||
: myOSystem{osystem},
|
||||
myName{name == "" ? code : name},
|
||||
myCode{code} { }
|
||||
|
@ -41,7 +41,7 @@ class Cheat
|
|||
virtual void evaluate() = 0;
|
||||
|
||||
protected:
|
||||
static uInt16 unhex(const string& hex)
|
||||
static uInt16 unhex(string_view hex)
|
||||
{
|
||||
int ret = 0;
|
||||
for(const auto c: hex)
|
||||
|
|
|
@ -33,7 +33,7 @@ CheatManager::CheatManager(OSystem& osystem)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool CheatManager::add(const string& name, const string& code,
|
||||
bool CheatManager::add(string_view name, string_view code,
|
||||
bool enable, int idx)
|
||||
{
|
||||
const shared_ptr<Cheat> cheat = createCheat(name, code);
|
||||
|
@ -79,7 +79,7 @@ void CheatManager::remove(int idx)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CheatManager::addPerFrame(const string& name, const string& code, bool enable)
|
||||
void CheatManager::addPerFrame(string_view name, string_view code, bool enable)
|
||||
{
|
||||
// The actual cheat will always be in the main list; we look there first
|
||||
shared_ptr<Cheat> cheat;
|
||||
|
@ -117,7 +117,7 @@ void CheatManager::addPerFrame(const string& name, const string& code, bool enab
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CheatManager::addOneShot(const string& name, const string& code)
|
||||
void CheatManager::addOneShot(string_view name, string_view code)
|
||||
{
|
||||
// Evaluate this cheat once, and then immediately discard it
|
||||
const shared_ptr<Cheat> cheat = createCheat(name, code);
|
||||
|
@ -126,7 +126,7 @@ void CheatManager::addOneShot(const string& name, const string& code)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
shared_ptr<Cheat> CheatManager::createCheat(const string& name, const string& code) const
|
||||
shared_ptr<Cheat> CheatManager::createCheat(string_view name, string_view code) const
|
||||
{
|
||||
if(!isValidCode(code))
|
||||
return nullptr;
|
||||
|
@ -143,7 +143,7 @@ shared_ptr<Cheat> CheatManager::createCheat(const string& name, const string& co
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CheatManager::parse(const string& cheats)
|
||||
void CheatManager::parse(string_view cheats)
|
||||
{
|
||||
StringList s;
|
||||
string::size_type lastPos = cheats.find_first_not_of(',', 0);
|
||||
|
@ -198,7 +198,7 @@ void CheatManager::parse(const string& cheats)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CheatManager::enable(const string& code, bool enable)
|
||||
void CheatManager::enable(string_view code, bool enable)
|
||||
{
|
||||
for(const auto& cheat: myCheatList)
|
||||
{
|
||||
|
@ -263,7 +263,7 @@ void CheatManager::saveCheatDatabase()
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CheatManager::loadCheats(const string& md5sum)
|
||||
void CheatManager::loadCheats(string_view md5sum)
|
||||
{
|
||||
myPerFrameList.clear();
|
||||
myCheatList.clear();
|
||||
|
@ -287,7 +287,7 @@ void CheatManager::loadCheats(const string& md5sum)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CheatManager::saveCheats(const string& md5sum)
|
||||
void CheatManager::saveCheats(string_view md5sum)
|
||||
{
|
||||
ostringstream cheats;
|
||||
for(uInt32 i = 0; i < myCheatList.size(); ++i)
|
||||
|
@ -322,7 +322,7 @@ void CheatManager::saveCheats(const string& md5sum)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool CheatManager::isValidCode(const string& code)
|
||||
bool CheatManager::isValidCode(string_view code)
|
||||
{
|
||||
for(const auto c: code)
|
||||
if(!isxdigit(c))
|
||||
|
|
|
@ -49,7 +49,7 @@ class CheatManager
|
|||
|
||||
@return Whether the cheat was created and enabled.
|
||||
*/
|
||||
bool add(const string& name, const string& code,
|
||||
bool add(string_view name, string_view code,
|
||||
bool enable = true, int idx = -1);
|
||||
|
||||
/**
|
||||
|
@ -68,7 +68,7 @@ class CheatManager
|
|||
@param code The actual cheatcode
|
||||
@param enable Add or remove the cheat to the per-frame list
|
||||
*/
|
||||
void addPerFrame(const string& name, const string& code, bool enable);
|
||||
void addPerFrame(string_view name, string_view code, bool enable);
|
||||
|
||||
/**
|
||||
Creates and enables a one-shot cheat. One-shot cheats are the
|
||||
|
@ -78,7 +78,7 @@ class CheatManager
|
|||
@param name Name of the cheat (not absolutely required)
|
||||
@param code The actual cheatcode (in hex)
|
||||
*/
|
||||
void addOneShot(const string& name, const string& code);
|
||||
void addOneShot(string_view name, string_view code);
|
||||
|
||||
/**
|
||||
Enable/disabled the cheat specified by the given code.
|
||||
|
@ -86,7 +86,7 @@ class CheatManager
|
|||
@param code The actual cheatcode to search for
|
||||
@param enable Enable/disable the cheat
|
||||
*/
|
||||
void enable(const string& code, bool enable);
|
||||
void enable(string_view code, bool enable);
|
||||
|
||||
/**
|
||||
Returns the game cheatlist.
|
||||
|
@ -111,17 +111,17 @@ class CheatManager
|
|||
/**
|
||||
Load cheats for ROM with given MD5sum to cheatlist(s).
|
||||
*/
|
||||
void loadCheats(const string& md5sum);
|
||||
void loadCheats(string_view md5sum);
|
||||
|
||||
/**
|
||||
Saves cheats for ROM with given MD5sum to cheat map.
|
||||
*/
|
||||
void saveCheats(const string& md5sum);
|
||||
void saveCheats(string_view md5sum);
|
||||
|
||||
/**
|
||||
Checks if a code is valid.
|
||||
*/
|
||||
static bool isValidCode(const string& code);
|
||||
static bool isValidCode(string_view code);
|
||||
|
||||
private:
|
||||
/**
|
||||
|
@ -132,14 +132,14 @@ class CheatManager
|
|||
|
||||
@return The cheat (if was created), else nullptr.
|
||||
*/
|
||||
shared_ptr<Cheat> createCheat(const string& name, const string& code) const;
|
||||
shared_ptr<Cheat> createCheat(string_view name, string_view code) const;
|
||||
|
||||
/**
|
||||
Parses a list of cheats and adds/enables each one.
|
||||
|
||||
@param cheats Comma-separated list of cheats (without any names)
|
||||
*/
|
||||
void parse(const string& cheats);
|
||||
void parse(string_view cheats);
|
||||
|
||||
private:
|
||||
OSystem& myOSystem;
|
||||
|
@ -147,7 +147,7 @@ class CheatManager
|
|||
CheatList myCheatList;
|
||||
CheatList myPerFrameList;
|
||||
|
||||
std::map<string,string> myCheatMap;
|
||||
std::map<string,string, std::less<>> myCheatMap;
|
||||
string myCheatFile;
|
||||
|
||||
// This is set each time a new cheat/ROM is loaded, for later
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "CheetahCheat.hxx"
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
CheetahCheat::CheetahCheat(OSystem& os, const string& name, const string& code)
|
||||
CheetahCheat::CheetahCheat(OSystem& os, string_view name, string_view code)
|
||||
: Cheat(os, name, code),
|
||||
address{static_cast<uInt16>(0xf000 + unhex(code.substr(0, 3)))},
|
||||
value{static_cast<uInt8>(unhex(code.substr(3, 2)))},
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
class CheetahCheat : public Cheat
|
||||
{
|
||||
public:
|
||||
CheetahCheat(OSystem& os, const string& name, const string& code);
|
||||
CheetahCheat(OSystem& os, string_view name, string_view code);
|
||||
~CheetahCheat() override = default;
|
||||
|
||||
bool enable() override;
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "RamCheat.hxx"
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
RamCheat::RamCheat(OSystem& os, const string& name, const string& code)
|
||||
RamCheat::RamCheat(OSystem& os, string_view name, string_view code)
|
||||
: Cheat(os, name, code),
|
||||
address{static_cast<uInt16>(unhex(myCode.substr(0, 2)))},
|
||||
value{static_cast<uInt8>(unhex(myCode.substr(2, 2)))}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
class RamCheat : public Cheat
|
||||
{
|
||||
public:
|
||||
RamCheat(OSystem& os, const string& name, const string& code);
|
||||
RamCheat(OSystem& os, string_view name, string_view code);
|
||||
~RamCheat() override = default;
|
||||
|
||||
bool enable() override;
|
||||
|
|
|
@ -454,14 +454,14 @@ bool FBBackendSDL2::createRenderer()
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void FBBackendSDL2::setTitle(const string& title)
|
||||
void FBBackendSDL2::setTitle(string_view title)
|
||||
{
|
||||
ASSERT_MAIN_THREAD;
|
||||
|
||||
myScreenTitle = title;
|
||||
|
||||
if(myWindow)
|
||||
SDL_SetWindowTitle(myWindow, title.c_str());
|
||||
SDL_SetWindowTitle(myWindow, string{title}.c_str());
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -78,7 +78,7 @@ class FBBackendSDL2 : public FBBackend
|
|||
|
||||
@param title The title of the application / window
|
||||
*/
|
||||
void setTitle(const string& title) override;
|
||||
void setTitle(string_view title) override;
|
||||
|
||||
/**
|
||||
Shows or hides the cursor based on the given boolean value.
|
||||
|
|
|
@ -44,7 +44,7 @@ class FSNodeFactory
|
|||
enum class Type { SYSTEM, ZIP };
|
||||
|
||||
public:
|
||||
static unique_ptr<AbstractFSNode> create(const string& path, Type type)
|
||||
static unique_ptr<AbstractFSNode> create(string_view path, Type type)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "FSNodeZIP.hxx"
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
FSNodeZIP::FSNodeZIP(const string& p)
|
||||
FSNodeZIP::FSNodeZIP(string_view p)
|
||||
{
|
||||
// Extract ZIP file and virtual file (if specified)
|
||||
const size_t pos = BSPF::findIgnoreCase(p, ".zip");
|
||||
|
|
|
@ -40,11 +40,11 @@ class FSNodeZIP : public AbstractFSNode
|
|||
*
|
||||
* @param path String with the path the new node should point to.
|
||||
*/
|
||||
explicit FSNodeZIP(const string& path);
|
||||
explicit FSNodeZIP(string_view path);
|
||||
|
||||
bool exists() const override;
|
||||
const string& getName() const override { return _name; }
|
||||
void setName(const string& name) override { _name = name; }
|
||||
const string& getName() const override { return _name; }
|
||||
void setName(string_view name) override { _name = name; }
|
||||
const string& getPath() const override { return _path; }
|
||||
string getShortPath() const override { return _shortPath; }
|
||||
bool hasParent() const override { return true; }
|
||||
|
@ -56,7 +56,7 @@ class FSNodeZIP : public AbstractFSNode
|
|||
//////////////////////////////////////////////////////////
|
||||
// For now, ZIP files cannot be modified in any way
|
||||
bool makeDir() override { return false; }
|
||||
bool rename(const string& newfile) override { return false; }
|
||||
bool rename(string_view) override { return false; }
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
size_t getSize() const override { return _size; }
|
||||
|
|
|
@ -537,9 +537,9 @@ HSM::ScoreAddresses HighScoresManager::getPropScoreAddr(const json& jprops)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt16 HighScoresManager::fromHexStr(const string& addr)
|
||||
uInt16 HighScoresManager::fromHexStr(string_view addr)
|
||||
{
|
||||
string naked = addr;
|
||||
string naked{addr};
|
||||
|
||||
if(const int pos = naked.find("0x") != std::string::npos)
|
||||
naked = naked.substr(pos + 1);
|
||||
|
|
|
@ -232,7 +232,7 @@ class HighScoresManager
|
|||
uInt16 defVal = 0);
|
||||
static HSM::ScoreAddresses getPropScoreAddr(const json& jprops);
|
||||
|
||||
static uInt16 fromHexStr(const string& addr);
|
||||
static uInt16 fromHexStr(string_view addr);
|
||||
static Int32 fromBCD(uInt8 bcd);
|
||||
string hash(const HSM::ScoresData& data) const;
|
||||
|
||||
|
|
|
@ -26,44 +26,46 @@ Logger& Logger::instance()
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Logger::log(const string& message, Level level)
|
||||
void Logger::log(string_view message, Level level)
|
||||
{
|
||||
instance().logMessage(message, level);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Logger::error(const string& message)
|
||||
void Logger::error(string_view message)
|
||||
{
|
||||
instance().logMessage(message, Level::ERR);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Logger::info(const string& message)
|
||||
void Logger::info(string_view message)
|
||||
{
|
||||
instance().logMessage(message, Level::INFO);
|
||||
}
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Logger::debug(const string& message)
|
||||
void Logger::debug(string_view message)
|
||||
{
|
||||
instance().logMessage(message, Level::DEBUG);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Logger::logMessage(const string& message, Level level)
|
||||
void Logger::logMessage(string_view message, Level level)
|
||||
{
|
||||
const std::lock_guard<std::mutex> lock(mutex);
|
||||
|
||||
if(level == Logger::Level::ERR)
|
||||
{
|
||||
cout << message << endl << std::flush;
|
||||
myLogMessages += message + "\n";
|
||||
myLogMessages += message;
|
||||
myLogMessages += "\n";
|
||||
}
|
||||
else if(static_cast<int>(level) <= myLogLevel ||
|
||||
level == Logger::Level::ALWAYS)
|
||||
{
|
||||
if(myLogToConsole)
|
||||
cout << message << endl << std::flush;
|
||||
myLogMessages += message + "\n";
|
||||
myLogMessages += message;
|
||||
myLogMessages += "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,13 +40,13 @@ class Logger {
|
|||
|
||||
static Logger& instance();
|
||||
|
||||
static void log(const string& message, Level level = Level::ALWAYS);
|
||||
static void log(string_view message, Level level = Level::ALWAYS);
|
||||
|
||||
static void error(const string& message);
|
||||
static void error(string_view message);
|
||||
|
||||
static void info(const string& message);
|
||||
static void info(string_view message);
|
||||
|
||||
static void debug(const string& message);
|
||||
static void debug(string_view message);
|
||||
|
||||
void setLogParameters(int logLevel, bool logToConsole);
|
||||
void setLogParameters(Level logLevel, bool logToConsole);
|
||||
|
@ -66,7 +66,7 @@ class Logger {
|
|||
std::mutex mutex;
|
||||
|
||||
private:
|
||||
void logMessage(const string& message, Level level);
|
||||
void logMessage(string_view message, Level level);
|
||||
|
||||
Logger(const Logger&) = delete;
|
||||
Logger(Logger&&) = delete;
|
||||
|
|
|
@ -23,12 +23,12 @@
|
|||
#include "MouseControl.hxx"
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
MouseControl::MouseControl(Console& console, const string& mode)
|
||||
MouseControl::MouseControl(Console& console, string_view mode)
|
||||
: myProps{console.properties()},
|
||||
myLeftController{console.leftController()},
|
||||
myRightController{console.rightController()}
|
||||
{
|
||||
istringstream m_axis(mode);
|
||||
istringstream m_axis(string{mode}); // TODO: fixed in C++20
|
||||
string m_mode;
|
||||
m_axis >> m_mode;
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ class MouseControl
|
|||
@param console The console in use by the system
|
||||
@param mode Contains information about how to use the mouse axes/buttons
|
||||
*/
|
||||
MouseControl(Console& console, const string& mode);
|
||||
MouseControl(Console& console, string_view mode);
|
||||
|
||||
/**
|
||||
Cycle through each available mouse control mode
|
||||
|
@ -85,10 +85,10 @@ class MouseControl
|
|||
int xid{-1}, yid{-1};
|
||||
string message;
|
||||
|
||||
explicit MouseMode(const string& msg = "") : message{msg} { }
|
||||
explicit MouseMode(string_view msg = "") : message{msg} { }
|
||||
MouseMode(Controller::Type xt, int xi,
|
||||
Controller::Type yt, int yi,
|
||||
const string& msg)
|
||||
string_view msg)
|
||||
: xtype{xt}, ytype{yt}, xid{xi}, yid{yi}, message{msg} { }
|
||||
|
||||
friend ostream& operator<<(ostream& os, const MouseMode& mm)
|
||||
|
|
|
@ -217,7 +217,7 @@ bool PhysicalJoystickHandler::remove(int id)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool PhysicalJoystickHandler::remove(const string& name)
|
||||
bool PhysicalJoystickHandler::remove(string_view name)
|
||||
{
|
||||
const auto it = myDatabase.find(name);
|
||||
if(it != myDatabase.end() && it->second.joy == nullptr)
|
||||
|
@ -229,7 +229,7 @@ bool PhysicalJoystickHandler::remove(const string& name)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool PhysicalJoystickHandler::mapStelladaptors(const string& saport, int ID)
|
||||
bool PhysicalJoystickHandler::mapStelladaptors(string_view saport, int ID)
|
||||
{
|
||||
bool erased = false;
|
||||
// saport will have two values:
|
||||
|
|
|
@ -73,8 +73,8 @@ class PhysicalJoystickHandler
|
|||
/** Return stick ID on success, -1 on failure. */
|
||||
int add(const PhysicalJoystickPtr& stick);
|
||||
bool remove(int id);
|
||||
bool remove(const string& name);
|
||||
bool mapStelladaptors(const string& saport, int ID = -1);
|
||||
bool remove(string_view name);
|
||||
bool mapStelladaptors(string_view saport, int ID = -1);
|
||||
bool hasStelladaptors() const;
|
||||
void setDefaultMapping(Event::Type event, EventMode mode);
|
||||
|
||||
|
@ -126,7 +126,7 @@ class PhysicalJoystickHandler
|
|||
void changeDrivingSensitivity(int direction = +1);
|
||||
|
||||
private:
|
||||
using StickDatabase = std::map<string,StickInfo>;
|
||||
using StickDatabase = std::map<string, StickInfo, std::less<>>;
|
||||
using StickList = std::map<int, PhysicalJoystickPtr>;
|
||||
|
||||
OSystem& myOSystem;
|
||||
|
|
|
@ -29,7 +29,7 @@ PaletteHandler::PaletteHandler(OSystem& system)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
PaletteHandler::PaletteType PaletteHandler::toPaletteType(const string& name) const
|
||||
PaletteHandler::PaletteType PaletteHandler::toPaletteType(string_view name) const
|
||||
{
|
||||
if(name == SETTING_Z26)
|
||||
return PaletteType::Z26;
|
||||
|
@ -301,7 +301,7 @@ void PaletteHandler::getAdjustables(Adjustable& adjustable) const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void PaletteHandler::setPalette(const string& name)
|
||||
void PaletteHandler::setPalette(string_view name)
|
||||
{
|
||||
myOSystem.settings().setValue("palette", name);
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ class PaletteHandler
|
|||
|
||||
@param name The palette to switch to
|
||||
*/
|
||||
void setPalette(const string& name);
|
||||
void setPalette(string_view name);
|
||||
|
||||
/**
|
||||
Sets the palette from current settings.
|
||||
|
@ -178,7 +178,7 @@ class PaletteHandler
|
|||
|
||||
@return The palette type
|
||||
*/
|
||||
PaletteType toPaletteType(const string& name) const;
|
||||
PaletteType toPaletteType(string_view name) const;
|
||||
|
||||
/**
|
||||
Convert enumeration to palette settings name.
|
||||
|
|
|
@ -37,9 +37,9 @@ struct Point
|
|||
|
||||
constexpr Point() = default;
|
||||
explicit constexpr Point(Int32 x1, Int32 y1) : x{x1}, y{y1} { }
|
||||
explicit Point(const string& p) {
|
||||
explicit Point(string_view p) {
|
||||
char c = '\0';
|
||||
istringstream buf(p);
|
||||
istringstream buf(string{p}); // TODO: fixed in C++20
|
||||
buf >> x >> c >> y;
|
||||
if(c != 'x')
|
||||
x = y = 0;
|
||||
|
@ -60,9 +60,9 @@ struct Size
|
|||
|
||||
constexpr Size() = default;
|
||||
explicit constexpr Size(uInt32 w1, uInt32 h1) : w{w1}, h{h1} { }
|
||||
explicit Size(const string& s) {
|
||||
explicit Size(string_view s) {
|
||||
char c = '\0';
|
||||
istringstream buf(s);
|
||||
istringstream buf(string{s}); // TODO: fixed in C++20
|
||||
buf >> w >> c >> h;
|
||||
if(c != 'x')
|
||||
w = h = 0;
|
||||
|
|
|
@ -96,7 +96,7 @@ void RewindManager::setup()
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool RewindManager::addState(const string& message, bool timeMachine)
|
||||
bool RewindManager::addState(string_view message, bool timeMachine)
|
||||
{
|
||||
// only check for Time Machine states, ignore for debugger
|
||||
if(timeMachine && myStateList.currentIsValid())
|
||||
|
|
|
@ -107,7 +107,7 @@ class RewindManager
|
|||
|
||||
@param message Message to display when replaying this state
|
||||
*/
|
||||
bool addState(const string& message, bool timeMachine = false);
|
||||
bool addState(string_view message, bool timeMachine = false);
|
||||
|
||||
/**
|
||||
Rewind numStates levels of the state list, and display the message associated
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace {
|
|||
} // namespace
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
StaggeredLogger::StaggeredLogger(const string& message, Logger::Level level)
|
||||
StaggeredLogger::StaggeredLogger(string_view message, Logger::Level level)
|
||||
: myMessage{message},
|
||||
myLevel{level}
|
||||
{
|
||||
|
|
|
@ -38,7 +38,7 @@ class StaggeredLogger
|
|||
{
|
||||
public:
|
||||
|
||||
StaggeredLogger(const string& message, Logger::Level level);
|
||||
StaggeredLogger(string_view message, Logger::Level level);
|
||||
~StaggeredLogger();
|
||||
|
||||
void log();
|
||||
|
|
|
@ -139,7 +139,7 @@ void StateManager::toggleTimeMachine()
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool StateManager::addExtraState(const string& message)
|
||||
bool StateManager::addExtraState(string_view message)
|
||||
{
|
||||
if(myActiveMode == Mode::TimeMachine)
|
||||
{
|
||||
|
|
|
@ -77,7 +77,7 @@ class StateManager
|
|||
Optionally adds one extra state when entering the Time Machine dialog;
|
||||
this uses the RewindManager for its functionality.
|
||||
*/
|
||||
bool addExtraState(const string& message);
|
||||
bool addExtraState(string_view message);
|
||||
|
||||
/**
|
||||
Rewinds states; this uses the RewindManager for its functionality.
|
||||
|
|
|
@ -34,9 +34,9 @@ class StringParser
|
|||
|
||||
@param str The string to split
|
||||
*/
|
||||
explicit StringParser(const string& str)
|
||||
explicit StringParser(string_view str)
|
||||
{
|
||||
istringstream buf(str);
|
||||
istringstream buf(string{str}); // TODO: fixed in C++20
|
||||
string line;
|
||||
|
||||
while(std::getline(buf, line, '\n'))
|
||||
|
|
|
@ -45,6 +45,7 @@ class Variant
|
|||
Variant() = default; // NOLINT
|
||||
|
||||
Variant(const string& s) : data{s} { }
|
||||
Variant(string_view s) : data{s} { }
|
||||
Variant(const char* s) : data{s} { }
|
||||
|
||||
Variant(Int32 i) { buf().str(""); buf() << i; data = buf().str(); }
|
||||
|
|
|
@ -193,6 +193,12 @@ namespace BSPF
|
|||
}
|
||||
|
||||
// Convert string to integer, using default value on any error
|
||||
inline int stringToInt(string_view s, const int defaultValue = 0)
|
||||
{
|
||||
try { return std::stoi(string{s}); }
|
||||
catch(...) { return defaultValue; }
|
||||
}
|
||||
// TODO: remove this once we reimplement stoi
|
||||
inline int stringToInt(const string& s, const int defaultValue = 0)
|
||||
{
|
||||
try { return std::stoi(s); }
|
||||
|
@ -285,7 +291,7 @@ namespace BSPF
|
|||
// (case sensitive for upper case characters in second string, except first one)
|
||||
// - the first character must match
|
||||
// - the following characters must appear in the order of the first string
|
||||
inline bool matchesCamelCase(const string_view s1, const string_view s2)
|
||||
inline bool matchesCamelCase(string_view s1, string_view s2)
|
||||
{
|
||||
// skip leading '_' for matching
|
||||
const uInt32 ofs = (s1[0] == '_' && s2[0] == '_') ? 1 : 0;
|
||||
|
@ -330,7 +336,7 @@ namespace BSPF
|
|||
// @param str The searched string
|
||||
// @param pattern The pattern to search for
|
||||
// @return Position of pattern in string.
|
||||
inline size_t matchWithJoker(const string& str, const string& pattern)
|
||||
inline size_t matchWithJoker(string_view str, string_view pattern)
|
||||
{
|
||||
if(str.length() >= pattern.length())
|
||||
{
|
||||
|
@ -361,9 +367,9 @@ namespace BSPF
|
|||
// @param str The searched string
|
||||
// @param pattern The pattern to search for
|
||||
// @return True if pattern was found.
|
||||
inline bool matchWithWildcards(const string& str, const string& pattern)
|
||||
inline bool matchWithWildcards(string_view str, string_view pattern)
|
||||
{
|
||||
string pat = pattern;
|
||||
string pat{pattern}; // TODO: don't use copy
|
||||
|
||||
// remove leading and trailing '*'
|
||||
size_t i = 0;
|
||||
|
@ -394,7 +400,7 @@ namespace BSPF
|
|||
}
|
||||
|
||||
// Modify 'str', replacing all occurrences of 'from' with 'to'
|
||||
inline void replaceAll(string& str, const string& from, const string& to)
|
||||
inline void replaceAll(string& str, string_view from, string_view to)
|
||||
{
|
||||
if(from.empty()) return;
|
||||
size_t start_pos = 0;
|
||||
|
@ -407,11 +413,11 @@ namespace BSPF
|
|||
}
|
||||
|
||||
// Trim leading and trailing whitespace from a string
|
||||
inline string trim(const string& str)
|
||||
inline string trim(string_view str)
|
||||
{
|
||||
const auto first = str.find_first_not_of(' ');
|
||||
return (first == string::npos) ? EmptyString :
|
||||
str.substr(first, str.find_last_not_of(' ')-first+1);
|
||||
string{str.substr(first, str.find_last_not_of(' ')-first+1)};
|
||||
}
|
||||
|
||||
// C++11 way to get local time
|
||||
|
|
|
@ -119,8 +119,8 @@ FBInitStatus Debugger::initializeVideo()
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool Debugger::start(const string& message, int address, bool read,
|
||||
const string& toolTip)
|
||||
bool Debugger::start(string_view message, int address, bool read,
|
||||
string_view toolTip)
|
||||
{
|
||||
if(myOSystem.eventHandler().enterDebugMode())
|
||||
{
|
||||
|
@ -139,7 +139,7 @@ bool Debugger::start(const string& message, int address, bool read,
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool Debugger::startWithFatalError(const string& message)
|
||||
bool Debugger::startWithFatalError(string_view message)
|
||||
{
|
||||
if(myOSystem.eventHandler().enterDebugMode())
|
||||
{
|
||||
|
@ -218,7 +218,7 @@ TrapArray& Debugger::writeTraps() const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string Debugger::run(const string& command)
|
||||
string Debugger::run(string_view command)
|
||||
{
|
||||
return myParser->run(command);
|
||||
}
|
||||
|
@ -450,7 +450,7 @@ bool Debugger::writeTrap(uInt16 t) const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Debugger::log(const string& triggerMsg)
|
||||
void Debugger::log(string_view triggerMsg)
|
||||
{
|
||||
const CartDebug::Disassembly& disasm = myCartDebug->disassembly();
|
||||
const int pc = myCpuDebug->pc();
|
||||
|
@ -719,7 +719,7 @@ string Debugger::showWatches()
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
int Debugger::stringToValue(const string& stringval)
|
||||
int Debugger::stringToValue(string_view stringval)
|
||||
{
|
||||
return myParser->decipher_arg(stringval);
|
||||
}
|
||||
|
@ -745,7 +745,7 @@ void Debugger::saveOldState(bool clearDirtyPages)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Debugger::addState(const string& rewindMsg)
|
||||
void Debugger::addState(string_view rewindMsg)
|
||||
{
|
||||
// Add another rewind level to the Time Machine buffer
|
||||
RewindManager& r = myOSystem.state().rewindManager();
|
||||
|
@ -788,7 +788,7 @@ void Debugger::setQuitState()
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool Debugger::addFunction(const string& name, const string& definition,
|
||||
bool Debugger::addFunction(string_view name, string_view definition,
|
||||
Expression* exp, bool builtin)
|
||||
{
|
||||
myFunctions.emplace(name, unique_ptr<Expression>(exp));
|
||||
|
@ -798,14 +798,14 @@ bool Debugger::addFunction(const string& name, const string& definition,
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool Debugger::isBuiltinFunction(const string& name)
|
||||
bool Debugger::isBuiltinFunction(string_view name)
|
||||
{
|
||||
return std::any_of(ourBuiltinFunctions.cbegin(), ourBuiltinFunctions.cend(),
|
||||
[&](const auto& func) { return name == func.name; });
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool Debugger::delFunction(const string& name)
|
||||
bool Debugger::delFunction(string_view name)
|
||||
{
|
||||
const auto& iter = myFunctions.find(name);
|
||||
if(iter == myFunctions.end())
|
||||
|
@ -815,25 +815,25 @@ bool Debugger::delFunction(const string& name)
|
|||
if(isBuiltinFunction(name))
|
||||
return false;
|
||||
|
||||
myFunctions.erase(name);
|
||||
myFunctions.erase(string{name});
|
||||
|
||||
const auto& def_iter = myFunctionDefs.find(name);
|
||||
if(def_iter == myFunctionDefs.end())
|
||||
return false;
|
||||
|
||||
myFunctionDefs.erase(name);
|
||||
myFunctionDefs.erase(string{name});
|
||||
return true;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
const Expression& Debugger::getFunction(const string& name) const
|
||||
const Expression& Debugger::getFunction(string_view name) const
|
||||
{
|
||||
const auto& iter = myFunctions.find(name);
|
||||
return iter != myFunctions.end() ? *(iter->second) : EmptyExpression;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
const string& Debugger::getFunctionDef(const string& name) const
|
||||
const string& Debugger::getFunctionDef(string_view name) const
|
||||
{
|
||||
const auto& iter = myFunctionDefs.find(name);
|
||||
return iter != myFunctionDefs.end() ? iter->second : EmptyString;
|
||||
|
|
|
@ -67,8 +67,8 @@ class Debugger : public DialogContainer
|
|||
friend class M6502;
|
||||
|
||||
public:
|
||||
using FunctionMap = std::map<string, unique_ptr<Expression>>;
|
||||
using FunctionDefMap = std::map<string, string>;
|
||||
using FunctionMap = std::map<string, unique_ptr<Expression>, std::less<>>;
|
||||
using FunctionDefMap = std::map<string, string, std::less<>>;
|
||||
|
||||
/**
|
||||
Create a new debugger parent object
|
||||
|
@ -94,9 +94,9 @@ class Debugger : public DialogContainer
|
|||
@param message Message to display when entering debugger
|
||||
@param address An address associated with the message
|
||||
*/
|
||||
bool start(const string& message = "", int address = -1, bool read = true,
|
||||
const string& toolTip = "");
|
||||
bool startWithFatalError(const string& message = "");
|
||||
bool start(string_view message = "", int address = -1, bool read = true,
|
||||
string_view toolTip = "");
|
||||
bool startWithFatalError(string_view message = "");
|
||||
|
||||
/**
|
||||
Wrapper method for EventHandler::leaveDebugMode() for those classes
|
||||
|
@ -109,13 +109,13 @@ class Debugger : public DialogContainer
|
|||
*/
|
||||
void quit();
|
||||
|
||||
bool addFunction(const string& name, const string& def,
|
||||
bool addFunction(string_view name, string_view def,
|
||||
Expression* exp, bool builtin = false);
|
||||
static bool isBuiltinFunction(const string& name);
|
||||
bool delFunction(const string& name);
|
||||
const Expression& getFunction(const string& name) const;
|
||||
static bool isBuiltinFunction(string_view name);
|
||||
bool delFunction(string_view name);
|
||||
const Expression& getFunction(string_view name) const;
|
||||
|
||||
const string& getFunctionDef(const string& name) const;
|
||||
const string& getFunctionDef(string_view name) const;
|
||||
FunctionDefMap getFunctionDefMap() const;
|
||||
static string builtinHelp();
|
||||
|
||||
|
@ -194,7 +194,7 @@ class Debugger : public DialogContainer
|
|||
/**
|
||||
Run the debugger command and return the result.
|
||||
*/
|
||||
string run(const string& command);
|
||||
string run(string_view command);
|
||||
|
||||
string autoExec(StringList* history);
|
||||
|
||||
|
@ -204,7 +204,7 @@ class Debugger : public DialogContainer
|
|||
Convert between string->integer and integer->string, taking into
|
||||
account the current base format.
|
||||
*/
|
||||
int stringToValue(const string& stringval);
|
||||
int stringToValue(string_view stringval);
|
||||
|
||||
/* Convenience methods to get/set bit(s) in an 8-bit register */
|
||||
static uInt8 set_bit(uInt8 input, uInt8 bit, bool on)
|
||||
|
@ -296,7 +296,7 @@ class Debugger : public DialogContainer
|
|||
/**
|
||||
Saves a rewind state with the given message.
|
||||
*/
|
||||
void addState(const string& rewindMsg);
|
||||
void addState(string_view rewindMsg);
|
||||
|
||||
/**
|
||||
Set initial state before entering the debugger.
|
||||
|
@ -326,7 +326,7 @@ class Debugger : public DialogContainer
|
|||
bool readTrap(uInt16 t) const;
|
||||
bool writeTrap(uInt16 t) const;
|
||||
void clearAllTraps() const;
|
||||
void log(const string& triggerMsg);
|
||||
void log(string_view triggerMsg);
|
||||
|
||||
// Set a bunch of RAM locations at once
|
||||
string setRAM(IntArray& args);
|
||||
|
|
|
@ -134,7 +134,7 @@ class EqualsExpression : public Expression
|
|||
class EquateExpression : public Expression
|
||||
{
|
||||
public:
|
||||
EquateExpression(const string& label) : Expression(), myLabel{label} { }
|
||||
EquateExpression(string_view label) : Expression(), myLabel{label} { }
|
||||
Int32 evaluate() const override
|
||||
{ return Debugger::debugger().cartDebug().getAddress(myLabel); }
|
||||
|
||||
|
@ -146,7 +146,7 @@ class EquateExpression : public Expression
|
|||
class FunctionExpression : public Expression
|
||||
{
|
||||
public:
|
||||
FunctionExpression(const string& label) : Expression(), myLabel{label} { }
|
||||
FunctionExpression(string_view label) : Expression(), myLabel{label} { }
|
||||
Int32 evaluate() const override
|
||||
{ return Debugger::debugger().getFunction(myLabel).evaluate(); }
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ DebuggerParser::DebuggerParser(Debugger& d, Settings& s)
|
|||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// main entry point: PromptWidget calls this method.
|
||||
string DebuggerParser::run(const string& command)
|
||||
string DebuggerParser::run(string_view command)
|
||||
{
|
||||
#if 0
|
||||
// this was our parser test code. Left for reference.
|
||||
|
@ -163,7 +163,7 @@ string DebuggerParser::exec(const FSNode& file, StringList* history)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void DebuggerParser::outputCommandError(const string& errorMsg, int command)
|
||||
void DebuggerParser::outputCommandError(string_view errorMsg, int command)
|
||||
{
|
||||
const string example = commands[command].extendedDesc.substr(commands[command].extendedDesc.find("Example:"));
|
||||
|
||||
|
@ -190,10 +190,10 @@ void DebuggerParser::getCompletions(const char* in, StringList& completions)
|
|||
// they're valid, or -1 if they're not.
|
||||
// decipher_arg may be called by the GUI as needed. It is also called
|
||||
// internally by DebuggerParser::run()
|
||||
int DebuggerParser::decipher_arg(const string& str)
|
||||
int DebuggerParser::decipher_arg(string_view str)
|
||||
{
|
||||
bool derefByte=false, derefWord=false, lobyte=false, hibyte=false, bin=false, dec=false;
|
||||
string arg = str;
|
||||
string arg{str};
|
||||
|
||||
const Base::Fmt defaultBase = Base::format();
|
||||
|
||||
|
@ -330,7 +330,7 @@ string DebuggerParser::showWatches()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool DebuggerParser::getArgs(const string& command, string& verb)
|
||||
bool DebuggerParser::getArgs(string_view command, string& verb)
|
||||
{
|
||||
ParseState state = ParseState::IN_COMMAND;
|
||||
size_t i = 0;
|
||||
|
@ -2456,7 +2456,7 @@ void DebuggerParser::executeTrapWriteIf()
|
|||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// Wrapper function for trap(if)s
|
||||
void DebuggerParser::executeTraps(bool read, bool write, const string& command,
|
||||
void DebuggerParser::executeTraps(bool read, bool write, string_view command,
|
||||
bool hasCond)
|
||||
{
|
||||
const uInt32 ofs = hasCond ? 1 : 0,
|
||||
|
|
|
@ -35,7 +35,7 @@ class DebuggerParser
|
|||
DebuggerParser(Debugger& debugger, Settings& settings);
|
||||
|
||||
/** Run the given command, and return the result */
|
||||
string run(const string& command);
|
||||
string run(string_view command);
|
||||
|
||||
/** Execute parser commands given in 'file' */
|
||||
string exec(const FSNode& file, StringList* history = nullptr);
|
||||
|
@ -45,23 +45,23 @@ class DebuggerParser
|
|||
static void getCompletions(const char* in, StringList& completions);
|
||||
|
||||
/** Evaluate the given expression using operators, current base, etc */
|
||||
int decipher_arg(const string& str);
|
||||
int decipher_arg(string_view str);
|
||||
|
||||
/** String representation of all watches currently defined */
|
||||
string showWatches();
|
||||
|
||||
static inline string red(const string& msg = "")
|
||||
static inline string red(string_view msg = "")
|
||||
{
|
||||
return char(kDbgColorRed & 0xff) + msg;
|
||||
return char(kDbgColorRed & 0xff) + string{msg};
|
||||
}
|
||||
static inline string inverse(const string& msg = "")
|
||||
static inline string inverse(string_view msg = "")
|
||||
{
|
||||
// ASCII DEL char, decimal 127
|
||||
return "\177" + msg;
|
||||
return "\177" + string{msg};
|
||||
}
|
||||
|
||||
private:
|
||||
bool getArgs(const string& command, string& verb);
|
||||
bool getArgs(string_view command, string& verb);
|
||||
bool validateArgs(int cmd);
|
||||
string eval();
|
||||
string saveScriptFile(string file);
|
||||
|
@ -112,7 +112,7 @@ class DebuggerParser
|
|||
uInt32 end{0};
|
||||
string condition;
|
||||
|
||||
Trap(bool r, bool w, uInt32 b, uInt32 e, const string& c)
|
||||
Trap(bool r, bool w, uInt32 b, uInt32 e, string_view c)
|
||||
: read(r), write(w), begin(b), end(e), condition(c) {}
|
||||
};
|
||||
|
||||
|
@ -146,7 +146,7 @@ class DebuggerParser
|
|||
void listTimers();
|
||||
|
||||
// output the error with the example provided for the command
|
||||
void outputCommandError(const string& errorMsg, int command);
|
||||
void outputCommandError(string_view errorMsg, int command);
|
||||
|
||||
void executeDirective(Device::AccessType type);
|
||||
|
||||
|
@ -252,7 +252,7 @@ class DebuggerParser
|
|||
void executeTrapReadIf();
|
||||
void executeTrapWrite();
|
||||
void executeTrapWriteIf();
|
||||
void executeTraps(bool read, bool write, const string& command, bool cond = false);
|
||||
void executeTraps(bool read, bool write, string_view command, bool cond = false);
|
||||
void executeTrapRW(uInt32 addr, bool read, bool write, bool add = true); // not exposed by debugger
|
||||
void executeType();
|
||||
void executeUHex();
|
||||
|
|
|
@ -1037,7 +1037,7 @@ string TIADebug::audFreq(uInt8 dist, uInt8 div) const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string TIADebug::stringOnly(const string& value, bool changed)
|
||||
string TIADebug::stringOnly(string_view value, bool changed)
|
||||
{
|
||||
ostringstream buf;
|
||||
|
||||
|
@ -1051,7 +1051,7 @@ string TIADebug::stringOnly(const string& value, bool changed)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string TIADebug::decWithLabel(const string& label, uInt16 value,
|
||||
string TIADebug::decWithLabel(string_view label, uInt16 value,
|
||||
bool changed, uInt16 width)
|
||||
{
|
||||
ostringstream buf;
|
||||
|
@ -1069,7 +1069,7 @@ string TIADebug::decWithLabel(const string& label, uInt16 value,
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string TIADebug::hexWithLabel(const string& label, uInt16 value,
|
||||
string TIADebug::hexWithLabel(string_view label, uInt16 value,
|
||||
bool changed, uInt16 width)
|
||||
{
|
||||
ostringstream buf;
|
||||
|
@ -1087,7 +1087,7 @@ string TIADebug::hexWithLabel(const string& label, uInt16 value,
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string TIADebug::binWithLabel(const string& label, uInt16 value, bool changed)
|
||||
string TIADebug::binWithLabel(string_view label, uInt16 value, bool changed)
|
||||
{
|
||||
ostringstream buf;
|
||||
|
||||
|
@ -1104,13 +1104,13 @@ string TIADebug::binWithLabel(const string& label, uInt16 value, bool changed)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string TIADebug::boolWithLabel(const string& label, bool value, bool changed)
|
||||
string TIADebug::boolWithLabel(string_view label, bool value, bool changed)
|
||||
{
|
||||
ostringstream buf;
|
||||
|
||||
if(value)
|
||||
{
|
||||
string l = label;
|
||||
string l{label};
|
||||
buf << "\177" << BSPF::toUpperCase(l) << "\177";
|
||||
//return "+" + BSPF::toUpperCase(label);
|
||||
}
|
||||
|
|
|
@ -188,14 +188,14 @@ class TIADebug : public DebuggerSystem
|
|||
static string colorSwatch(uInt8 c);
|
||||
|
||||
string audFreq(uInt8 dist, uInt8 div) const;
|
||||
static string stringOnly(const string& value, bool changed = false);
|
||||
static string decWithLabel(const string& label, uInt16 value,
|
||||
static string stringOnly(string_view value, bool changed = false);
|
||||
static string decWithLabel(string_view label, uInt16 value,
|
||||
bool changed = false, uInt16 width = 3);
|
||||
static string hexWithLabel(const string& label, uInt16 value,
|
||||
static string hexWithLabel(string_view label, uInt16 value,
|
||||
bool changed = false, uInt16 width = 2);
|
||||
static string binWithLabel(const string& label, uInt16 value,
|
||||
static string binWithLabel(string_view label, uInt16 value,
|
||||
bool changed = false);
|
||||
static string boolWithLabel(const string& label, bool value,
|
||||
static string boolWithLabel(string_view label, bool value,
|
||||
bool changed = false);
|
||||
|
||||
private:
|
||||
|
|
|
@ -582,7 +582,7 @@ void DataGridWidget::handleCommand(CommandSender* sender, int cmd,
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void DataGridWidget::setToolTip(int column, int row, const string& text)
|
||||
void DataGridWidget::setToolTip(int column, int row, string_view text)
|
||||
{
|
||||
if(row >= 0 && row < _rows && column >= 0 && column < _cols)
|
||||
_toolTipList[row * _cols + column] = text;
|
||||
|
|
|
@ -85,7 +85,7 @@ class DataGridWidget : public EditableWidget
|
|||
void setCrossed(bool enable);
|
||||
|
||||
using EditableWidget::setToolTip;
|
||||
void setToolTip(int column, int row, const string& text);
|
||||
void setToolTip(int column, int row, string_view text);
|
||||
string getToolTip(const Common::Point& pos) const override;
|
||||
bool changedToolTip(const Common::Point& oldPos, const Common::Point& newPos) const override;
|
||||
|
||||
|
|
|
@ -434,7 +434,7 @@ void DebuggerDialog::createFont()
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void DebuggerDialog::showFatalMessage(const string& msg)
|
||||
void DebuggerDialog::showFatalMessage(string_view msg)
|
||||
{
|
||||
myFatalError = make_unique<GUI::MessageBox>(this, *myLFont, msg, _w-20, _h-20,
|
||||
kDDExitFatalCmd, "Exit ROM", "Continue", "Fatal error");
|
||||
|
|
|
@ -49,7 +49,7 @@ class DebuggerDialog : public Dialog
|
|||
{
|
||||
public:
|
||||
// Note: these sizes make sure that all major tabs are fully visible
|
||||
// cart dependend information (e.g. DPC+) may require more space
|
||||
// cart dependend information (e.g. DPC+) may require more space
|
||||
enum {
|
||||
kSmallFontMinW = 1090, kSmallFontMinH = 720,
|
||||
kMediumFontMinW = 1160, kMediumFontMinH = 770,
|
||||
|
@ -73,7 +73,7 @@ class DebuggerDialog : public Dialog
|
|||
ButtonWidget& rewindButton() const { return *myRewindButton; }
|
||||
ButtonWidget& unwindButton() const { return *myUnwindButton; }
|
||||
|
||||
void showFatalMessage(const string& msg);
|
||||
void showFatalMessage(string_view msg);
|
||||
void saveConfig() override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -569,10 +569,10 @@ int PromptWidget::historyDir(int& index, int direction)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void PromptWidget::historyAdd(const string& entry)
|
||||
void PromptWidget::historyAdd(string_view entry)
|
||||
{
|
||||
if(_historyIndex >= static_cast<int>(_history.size()))
|
||||
_history.push_back(entry);
|
||||
_history.emplace_back(entry);
|
||||
else
|
||||
_history[_historyIndex] = entry;
|
||||
}
|
||||
|
@ -882,7 +882,7 @@ void PromptWidget::putcharIntern(int c)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void PromptWidget::print(const string& str)
|
||||
void PromptWidget::print(string_view str)
|
||||
{
|
||||
for(const auto c: str)
|
||||
putcharIntern(c);
|
||||
|
|
|
@ -42,7 +42,7 @@ class PromptWidget : public Widget, public CommandSender
|
|||
~PromptWidget() override = default;
|
||||
|
||||
public:
|
||||
void print(const string& str);
|
||||
void print(string_view str);
|
||||
void printPrompt();
|
||||
string saveBuffer(const FSNode& file);
|
||||
|
||||
|
@ -134,7 +134,7 @@ class PromptWidget : public Widget, public CommandSender
|
|||
bool _exitedEarly{false};
|
||||
|
||||
int historyDir(int& index, int direction);
|
||||
void historyAdd(const string& entry);
|
||||
void historyAdd(string_view entry);
|
||||
|
||||
private:
|
||||
// Following constructors and assignment operators not supported
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
RamWidget::RamWidget(GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont,
|
||||
int x, int y, int w, int h,
|
||||
uInt32 ramsize, uInt32 numrows, uInt32 pagesize,
|
||||
const string& helpAnchor)
|
||||
string_view helpAnchor)
|
||||
: Widget(boss, lfont, x, y, w, h),
|
||||
CommandSender(boss),
|
||||
_nfont{nfont},
|
||||
|
@ -393,7 +393,7 @@ void RamWidget::showInputBox(int cmd)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string RamWidget::doSearch(const string& str)
|
||||
string RamWidget::doSearch(string_view str)
|
||||
{
|
||||
bool comparisonSearch = true;
|
||||
|
||||
|
@ -450,7 +450,7 @@ string RamWidget::doSearch(const string& str)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string RamWidget::doCompare(const string& str)
|
||||
string RamWidget::doCompare(string_view str)
|
||||
{
|
||||
bool comparativeSearch = false;
|
||||
int searchVal = 0, offset = 0;
|
||||
|
@ -475,7 +475,7 @@ string RamWidget::doCompare(const string& str)
|
|||
if(str[0] == '-')
|
||||
negative = true;
|
||||
|
||||
string tmp = str;
|
||||
string tmp{str};
|
||||
tmp.erase(0, 1); // remove the operator
|
||||
offset = instance().debugger().stringToValue(tmp);
|
||||
if(negative)
|
||||
|
|
|
@ -36,7 +36,7 @@ class RamWidget : public Widget, public CommandSender
|
|||
RamWidget(GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont,
|
||||
int x, int y, int w, int h,
|
||||
uInt32 ramsize, uInt32 numrows, uInt32 pagesize,
|
||||
const string& helpAnchor);
|
||||
string_view helpAnchor);
|
||||
~RamWidget() override;
|
||||
|
||||
void loadConfig() override;
|
||||
|
@ -60,8 +60,8 @@ class RamWidget : public Widget, public CommandSender
|
|||
void fillGrid(bool updateOld);
|
||||
|
||||
void showInputBox(int cmd);
|
||||
string doSearch(const string& str);
|
||||
string doCompare(const string& str);
|
||||
string doSearch(string_view str);
|
||||
string doCompare(string_view str);
|
||||
void doRestart();
|
||||
void showSearchResults();
|
||||
|
||||
|
|
|
@ -27,12 +27,12 @@
|
|||
#include "Cart.hxx"
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Cartridge::Cartridge(const Settings& settings, const string& md5)
|
||||
Cartridge::Cartridge(const Settings& settings, string_view md5)
|
||||
: mySettings{settings}
|
||||
{
|
||||
const auto to_uInt32 = [](const string& s, uInt32 pos) {
|
||||
return static_cast<uInt32>(std::stoul(s.substr(pos, 8), nullptr, 16));
|
||||
};
|
||||
const auto to_uInt32 = [](string_view s, uInt32 pos) {
|
||||
return static_cast<uInt32>(std::stoul(string{s.substr(pos, 8)}, nullptr, 16));
|
||||
}; // FIXME: convert to string_view by replacing std::stoul
|
||||
|
||||
const uInt32 seed = to_uInt32(md5, 0) ^ to_uInt32(md5, 8) ^
|
||||
to_uInt32(md5, 16) ^ to_uInt32(md5, 24);
|
||||
|
@ -44,8 +44,7 @@ Cartridge::Cartridge(const Settings& settings, const string& md5)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Cartridge::setAbout(const string& about, const string& type,
|
||||
const string& id)
|
||||
void Cartridge::setAbout(string_view about, string_view type, string_view id)
|
||||
{
|
||||
myAbout = about;
|
||||
myDetectedType = type;
|
||||
|
|
|
@ -63,13 +63,13 @@ class Cartridge : public Device
|
|||
@param settings A reference to the various settings (read-only)
|
||||
@param md5 The md5sum of the cart image
|
||||
*/
|
||||
Cartridge(const Settings& settings, const string& md5);
|
||||
Cartridge(const Settings& settings, string_view md5);
|
||||
~Cartridge() override = default;
|
||||
|
||||
/**
|
||||
Set/query some information about this cartridge.
|
||||
*/
|
||||
void setAbout(const string& about, const string& type, const string& id);
|
||||
void setAbout(string_view about, string_view type, string_view id);
|
||||
const string& about() const { return myAbout; }
|
||||
const string& detectedType() const { return myDetectedType; }
|
||||
const string& multiCartID() const { return myMultiCartID; }
|
||||
|
@ -295,10 +295,9 @@ class Cartridge : public Device
|
|||
Informs the cartridge about the name of the nvram file it will
|
||||
use; not all carts support this.
|
||||
|
||||
@param nvramdir The full path of the nvram directory
|
||||
@param romfile The name of the cart from ROM properties
|
||||
@param path The full path of the nvram file
|
||||
*/
|
||||
virtual void setNVRamFile(const string& nvramdir, const string& romfile) { }
|
||||
virtual void setNVRamFile(string_view path) { }
|
||||
|
||||
/**
|
||||
Thumbulator only supports 16-bit ARM code. Some Harmony/Melody drivers,
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "CartARM.hxx"
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
CartridgeARM::CartridgeARM(const string& md5, const Settings& settings)
|
||||
CartridgeARM::CartridgeARM(const Settings& settings, string_view md5)
|
||||
: Cartridge(settings, md5)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ class CartridgeARM : public Cartridge
|
|||
friend class CartridgeARMWidget;
|
||||
|
||||
public:
|
||||
CartridgeARM(const string& md5, const Settings& settings);
|
||||
CartridgeARM(const Settings& settings, string_view md5);
|
||||
~CartridgeARM() override = default;
|
||||
|
||||
/**
|
||||
|
|
|
@ -46,8 +46,8 @@ static constexpr uInt32 getUInt32(const uInt8* _array, size_t _address) {
|
|||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
CartridgeBUS::CartridgeBUS(const ByteBuffer& image, size_t size,
|
||||
const string& md5, const Settings& settings)
|
||||
: CartridgeARM(md5, settings),
|
||||
string_view md5, const Settings& settings)
|
||||
: CartridgeARM(settings, md5),
|
||||
myImage{make_unique<uInt8[]>(32_KB)}
|
||||
{
|
||||
// Copy the ROM image into my buffer
|
||||
|
|
|
@ -41,7 +41,7 @@ class CartridgeBUS : public CartridgeARM
|
|||
friend class CartridgeBUSWidget;
|
||||
friend class CartridgeBUSInfoWidget;
|
||||
friend class CartridgeRamBUSWidget;
|
||||
|
||||
|
||||
enum class BUSSubtype {
|
||||
BUS0, // very old demos when BUS was in flux, not supported in Stella
|
||||
BUS1, // draconian_20161102.bin
|
||||
|
@ -59,7 +59,7 @@ class CartridgeBUS : public CartridgeARM
|
|||
@param md5 The md5sum of the ROM image
|
||||
@param settings A reference to the various settings (read-only)
|
||||
*/
|
||||
CartridgeBUS(const ByteBuffer& image, size_t size, const string& md5,
|
||||
CartridgeBUS(const ByteBuffer& image, size_t size, string_view md5,
|
||||
const Settings& settings);
|
||||
~CartridgeBUS() override = default;
|
||||
|
||||
|
@ -168,12 +168,12 @@ class CartridgeBUS : public CartridgeARM
|
|||
*/
|
||||
CartDebugWidget* debugWidget(GuiObject* boss, const GUI::Font& lfont,
|
||||
const GUI::Font& nfont, int x, int y, int w, int h) override;
|
||||
|
||||
|
||||
CartDebugWidget* infoWidget(GuiObject* boss, const GUI::Font& lfont,
|
||||
const GUI::Font& nfont, int x, int y, int w, int h) override;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
Get the byte at the specified address.
|
||||
|
@ -220,7 +220,7 @@ class CartridgeBUS : public CartridgeARM
|
|||
|
||||
uInt32 getDatastreamIncrement(uInt8 index) const;
|
||||
void setDatastreamIncrement(uInt8 index, uInt32 value);
|
||||
|
||||
|
||||
uInt32 getAddressMap(uInt8 index) const;
|
||||
void setAddressMap(uInt8 index, uInt32 value);
|
||||
|
||||
|
@ -269,16 +269,16 @@ class CartridgeBUS : public CartridgeARM
|
|||
|
||||
// ARM cycle count from when the last callFunction() occurred
|
||||
uInt64 myARMCycles{0};
|
||||
|
||||
|
||||
// Pointer to the array of datastream pointers
|
||||
uInt16 myDatastreamBase{0}; // was DSxPTR
|
||||
|
||||
// Pointer to the array of datastream increments
|
||||
uInt16 myDatastreamIncrementBase{0}; // was DSxINC
|
||||
|
||||
|
||||
// Pointer to the array of datastream maps
|
||||
uInt16 myDatastreamMapBase{0}; // was DSMAPS
|
||||
|
||||
|
||||
// Pointer to the beginning of the waveform data block
|
||||
uInt16 myWaveformBase{0}; // was WAVEFORM
|
||||
|
||||
|
@ -302,7 +302,7 @@ class CartridgeBUS : public CartridgeARM
|
|||
uInt8 myMode{0};
|
||||
|
||||
uInt8 myFastJumpActive{false};
|
||||
|
||||
|
||||
// BUS subtype
|
||||
BUSSubtype myBUSSubtype{BUSSubtype::BUS1};
|
||||
|
||||
|
|
|
@ -62,8 +62,8 @@ namespace {
|
|||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
CartridgeCDF::CartridgeCDF(const ByteBuffer& image, size_t size,
|
||||
const string& md5, const Settings& settings)
|
||||
: CartridgeARM(md5, settings)
|
||||
string_view md5, const Settings& settings)
|
||||
: CartridgeARM(settings, md5)
|
||||
{
|
||||
// Copy the ROM image into my buffer
|
||||
mySize = std::min(size, 512_KB);
|
||||
|
|
|
@ -82,7 +82,7 @@ class CartridgeCDF : public CartridgeARM
|
|||
@param md5 The md5sum of the ROM image
|
||||
@param settings A reference to the various settings (read-only)
|
||||
*/
|
||||
CartridgeCDF(const ByteBuffer& image, size_t size, const string& md5,
|
||||
CartridgeCDF(const ByteBuffer& image, size_t size, string_view md5,
|
||||
const Settings& settings);
|
||||
~CartridgeCDF() override = default;
|
||||
|
||||
|
|
|
@ -357,9 +357,9 @@ bool CartridgeCTY::load(Serializer& in)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CartridgeCTY::setNVRamFile(const string& nvramdir, const string& romfile)
|
||||
void CartridgeCTY::setNVRamFile(string_view path)
|
||||
{
|
||||
myEEPROMFile = nvramdir + romfile + "_eeprom.dat";
|
||||
myEEPROMFile = string{path} + "_eeprom.dat";
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -210,10 +210,9 @@ class CartridgeCTY : public Cartridge
|
|||
/**
|
||||
Informs the cartridge about the name of the nvram file it will use.
|
||||
|
||||
@param nvramdir The full path of the nvram directory
|
||||
@param romfile The name of the cart from ROM properties
|
||||
@param path The full path of the nvram file
|
||||
*/
|
||||
void setNVRamFile(const string& nvramdir, const string& romfile) override;
|
||||
void setNVRamFile(string_view path) override;
|
||||
|
||||
#ifdef DEBUGGER_SUPPORT
|
||||
/**
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
CartridgeDPCPlus::CartridgeDPCPlus(const ByteBuffer& image, size_t size,
|
||||
const string& md5, const Settings& settings)
|
||||
: CartridgeARM(md5, settings),
|
||||
string_view md5, const Settings& settings)
|
||||
: CartridgeARM(settings, md5),
|
||||
myImage{make_unique<uInt8[]>(32_KB)},
|
||||
mySize{std::min(size, 32_KB)}
|
||||
{
|
||||
|
|
|
@ -55,7 +55,7 @@ class CartridgeDPCPlus : public CartridgeARM
|
|||
@param md5 The md5sum of the ROM image
|
||||
@param settings A reference to the various settings (read-only)
|
||||
*/
|
||||
CartridgeDPCPlus(const ByteBuffer& image, size_t size, const string& md5,
|
||||
CartridgeDPCPlus(const ByteBuffer& image, size_t size, string_view md5,
|
||||
const Settings& settings);
|
||||
~CartridgeDPCPlus() override = default;
|
||||
|
||||
|
|
|
@ -79,9 +79,9 @@ bool CartridgeFA2::poke(uInt16 address, uInt8 value)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CartridgeFA2::setNVRamFile(const string& nvramdir, const string& romfile)
|
||||
void CartridgeFA2::setNVRamFile(string_view path)
|
||||
{
|
||||
myFlashFile = nvramdir + romfile + "_flash.dat";
|
||||
myFlashFile = string{path} + "_flash.dat";
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -74,10 +74,9 @@ class CartridgeFA2 : public CartridgeFA
|
|||
/**
|
||||
Informs the cartridge about the name of the nvram file it will use.
|
||||
|
||||
@param nvramdir The full path of the nvram directory
|
||||
@param romfile The name of the cart from ROM properties
|
||||
@param path The full path of the nvram file
|
||||
*/
|
||||
void setNVRamFile(const string& nvramdir, const string& romfile) override;
|
||||
void setNVRamFile(string_view path) override;
|
||||
|
||||
#ifdef DEBUGGER_SUPPORT
|
||||
/**
|
||||
|
|
|
@ -56,7 +56,7 @@ class StreamReader : public Serializable
|
|||
public:
|
||||
StreamReader() { myBuffer1.fill(0); myBuffer2.fill(0); }
|
||||
|
||||
bool open(const string& path) {
|
||||
bool open(string_view path) {
|
||||
myFile = Serializer(path, Serializer::Mode::ReadOnly);
|
||||
if(myFile)
|
||||
myFileSize = myFile.size();
|
||||
|
@ -738,7 +738,7 @@ class MovieCart : public Serializable
|
|||
public:
|
||||
MovieCart() { myROM.fill(0); }
|
||||
|
||||
bool init(const string& path);
|
||||
bool init(string_view path);
|
||||
bool process(uInt16 address);
|
||||
|
||||
bool save(Serializer& out) const override;
|
||||
|
@ -837,7 +837,7 @@ class MovieCart : public Serializable
|
|||
};
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool MovieCart::init(const string& path)
|
||||
bool MovieCart::init(string_view path)
|
||||
{
|
||||
std::copy_n(kernelROM, 1_KB, myROM.data());
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ Console::Console(OSystem& osystem, unique_ptr<Cartridge>& cart,
|
|||
|
||||
// Let the cart know how to query for the 'Cartridge.StartBank' property
|
||||
myCart->setStartBankFromPropsFunc([this]() {
|
||||
const string& startbank = myProperties.get(PropType::Cart_StartBank);
|
||||
const string_view startbank = myProperties.get(PropType::Cart_StartBank);
|
||||
return (startbank == EmptyString || BSPF::equalsIgnoreCase(startbank, "AUTO"))
|
||||
? -1 : BSPF::stringToInt(startbank);
|
||||
});
|
||||
|
@ -169,8 +169,7 @@ Console::Console(OSystem& osystem, unique_ptr<Cartridge>& cart,
|
|||
|
||||
// Add the real controllers for this system
|
||||
// This must be done before the debugger is initialized
|
||||
const string& md5 = myProperties.get(PropType::Cart_MD5);
|
||||
setControllers(md5);
|
||||
setControllers(myProperties.get(PropType::Cart_MD5));
|
||||
|
||||
// Pause audio and clear framebuffer while autodetection runs
|
||||
myOSystem.sound().pause(true);
|
||||
|
@ -238,7 +237,7 @@ Console::Console(OSystem& osystem, unique_ptr<Cartridge>& cart,
|
|||
myConsoleInfo.BankSwitch = myCart->about();
|
||||
|
||||
// Some carts have an associated nvram file
|
||||
myCart->setNVRamFile(myOSystem.nvramDir().getPath(), myConsoleInfo.CartName);
|
||||
myCart->setNVRamFile(myOSystem.nvramDir().getPath() + myConsoleInfo.CartName);
|
||||
|
||||
// Let the other devices know about the new console
|
||||
mySystem->consoleChanged(myConsoleTiming);
|
||||
|
@ -360,13 +359,13 @@ string Console::formatFromFilename() const
|
|||
}};
|
||||
|
||||
// Get filename, and search using regex's above
|
||||
const string& filename = myOSystem.romFile().getName();
|
||||
const string_view filename = myOSystem.romFile().getName();
|
||||
for(const auto& pat: Pattern)
|
||||
{
|
||||
try
|
||||
{
|
||||
const std::regex rgx(pat[0], std::regex_constants::icase);
|
||||
if(std::regex_search(filename, rgx))
|
||||
if(std::regex_search(filename.cbegin(), filename.cend(), rgx))
|
||||
return pat[1];
|
||||
}
|
||||
catch(...)
|
||||
|
@ -676,7 +675,7 @@ FBInitStatus Console::initializeVideo(bool full)
|
|||
Common::Size(2 * myTIA->width(), myTIA->height());
|
||||
|
||||
const bool devSettings = myOSystem.settings().getBool("dev.settings");
|
||||
const string& title = string("Stella ") + STELLA_VERSION +
|
||||
const string title = string{"Stella "} + STELLA_VERSION +
|
||||
": \"" + myProperties.get(PropType::Cart_Name) + "\"";
|
||||
fbstatus = myOSystem.frameBuffer().createDisplay(title,
|
||||
BufferType::Emulator, size, false);
|
||||
|
@ -837,7 +836,7 @@ void Console::createAudioQueue()
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Console::setControllers(const string& romMd5)
|
||||
void Console::setControllers(string_view romMd5)
|
||||
{
|
||||
// Check for CompuMate scheme; it is special in that a handler creates both
|
||||
// controllers for us, and associates them with the bankswitching class
|
||||
|
@ -942,9 +941,8 @@ void Console::changeRightController(int direction)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
unique_ptr<Controller> Console::getControllerPort(const Controller::Type type,
|
||||
const Controller::Jack port,
|
||||
const string& romMd5)
|
||||
unique_ptr<Controller> Console::getControllerPort(
|
||||
const Controller::Type type, const Controller::Jack port, string_view romMd5)
|
||||
{
|
||||
unique_ptr<Controller> controller;
|
||||
|
||||
|
@ -1002,7 +1000,8 @@ unique_ptr<Controller> Console::getControllerPort(const Controller::Type type,
|
|||
{
|
||||
FSNode nvramfile = myOSystem.nvramDir();
|
||||
nvramfile /= "atarivox_eeprom.dat";
|
||||
const Controller::onMessageCallback callback = [&os = myOSystem](const string& msg)
|
||||
const Controller::onMessageCallback callback = [&os = myOSystem]
|
||||
(string_view msg)
|
||||
{
|
||||
const bool devSettings = os.settings().getBool("dev.settings");
|
||||
if(os.settings().getBool(devSettings ? "dev.extaccess" : "plr.extaccess"))
|
||||
|
@ -1016,7 +1015,8 @@ unique_ptr<Controller> Console::getControllerPort(const Controller::Type type,
|
|||
{
|
||||
FSNode nvramfile = myOSystem.nvramDir();
|
||||
nvramfile /= "savekey_eeprom.dat";
|
||||
const Controller::onMessageCallback callback = [&os = myOSystem](const string& msg)
|
||||
const Controller::onMessageCallback callback = [&os = myOSystem]
|
||||
(string_view msg)
|
||||
{
|
||||
const bool devSettings = os.settings().getBool("dev.settings");
|
||||
if(os.settings().getBool(devSettings ? "dev.extaccess" : "plr.extaccess"))
|
||||
|
@ -1031,8 +1031,8 @@ unique_ptr<Controller> Console::getControllerPort(const Controller::Type type,
|
|||
|
||||
case Controller::Type::KidVid:
|
||||
{
|
||||
const Controller::onMessageCallbackForced callback =
|
||||
[&os = myOSystem](const string& msg, bool force) {
|
||||
const Controller::onMessageCallbackForced callback = [&os = myOSystem]
|
||||
(string_view msg, bool force) {
|
||||
const bool devSettings = os.settings().getBool("dev.settings");
|
||||
if(force || os.settings().getBool(devSettings ? "dev.extaccess" : "plr.extaccess"))
|
||||
os.frameBuffer().showTextMessage(msg);
|
||||
|
@ -1241,10 +1241,11 @@ void Console::toggleDeveloperSet(bool toggle)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Console::toggleTIABit(TIABit bit, const string& bitname, bool show, bool toggle) const
|
||||
void Console::toggleTIABit(TIABit bit, string_view bitname,
|
||||
bool show, bool toggle) const
|
||||
{
|
||||
const bool result = myTIA->toggleBit(bit, toggle ? 2 : 3);
|
||||
const string message = bitname + (result ? " enabled" : " disabled");
|
||||
const string message = string{bitname} + (result ? " enabled" : " disabled");
|
||||
|
||||
myOSystem.frameBuffer().showTextMessage(message);
|
||||
}
|
||||
|
@ -1259,10 +1260,12 @@ void Console::toggleBits(bool toggle) const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Console::toggleTIACollision(TIABit bit, const string& bitname, bool show, bool toggle) const
|
||||
void Console::toggleTIACollision(TIABit bit, string_view bitname,
|
||||
bool show, bool toggle) const
|
||||
{
|
||||
const bool result = myTIA->toggleCollision(bit, toggle ? 2 : 3);
|
||||
const string message = bitname + (result ? " collision enabled" : " collision disabled");
|
||||
const string message = string{bitname} +
|
||||
(result ? " collision enabled" : " collision disabled");
|
||||
|
||||
myOSystem.frameBuffer().showTextMessage(message);
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ class Console : public Serializable, public ConsoleIO
|
|||
/**
|
||||
Sets the left and right controllers for the console.
|
||||
*/
|
||||
void setControllers(const string& romMd5);
|
||||
void setControllers(string_view romMd5);
|
||||
|
||||
/**
|
||||
Get the controller plugged into the specified jack
|
||||
|
@ -424,11 +424,12 @@ class Console : public Serializable, public ConsoleIO
|
|||
Selects the left or right controller depending on ROM properties
|
||||
*/
|
||||
unique_ptr<Controller> getControllerPort(const Controller::Type type,
|
||||
const Controller::Jack port, const string& romMd5);
|
||||
const Controller::Jack port,
|
||||
string_view romMd5);
|
||||
|
||||
void toggleTIABit(TIABit bit, const string& bitname,
|
||||
void toggleTIABit(TIABit bit, string_view bitname,
|
||||
bool show = true, bool toggle = true) const;
|
||||
void toggleTIACollision(TIABit bit, const string& bitname,
|
||||
void toggleTIACollision(TIABit bit, string_view bitname,
|
||||
bool show = true, bool toggle = true) const;
|
||||
|
||||
private:
|
||||
|
|
|
@ -134,15 +134,12 @@ string Controller::getPropName(const Type type)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Controller::Type Controller::getType(const string& propName)
|
||||
Controller::Type Controller::getType(string_view propName)
|
||||
{
|
||||
for(int i = 0; i < static_cast<int>(Type::LastType); ++i)
|
||||
{
|
||||
if (BSPF::equalsIgnoreCase(propName, getPropName(Type{i})))
|
||||
{
|
||||
return Type{i};
|
||||
}
|
||||
}
|
||||
|
||||
// special case
|
||||
if(BSPF::equalsIgnoreCase(propName, "KEYPAD"))
|
||||
return Type::Keyboard;
|
||||
|
|
|
@ -279,7 +279,7 @@ class Controller : public Serializable
|
|||
/**
|
||||
Returns the controller type of the given property name
|
||||
*/
|
||||
static Type getType(const string& propName);
|
||||
static Type getType(string_view propName);
|
||||
|
||||
/**
|
||||
Sets the dead zone amount for real analog joysticks.
|
||||
|
|
|
@ -31,8 +31,9 @@ void DispatchResult::setOk(uInt64 cycles)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void DispatchResult::setDebugger(uInt64 cycles, const string& message,
|
||||
const string& tooltip, int address, bool wasReadTrap)
|
||||
void DispatchResult::setDebugger(uInt64 cycles, string_view message,
|
||||
string_view tooltip, int address,
|
||||
bool wasReadTrap)
|
||||
{
|
||||
myStatus = Status::debugger;
|
||||
myCycles = cycles;
|
||||
|
@ -51,7 +52,7 @@ void DispatchResult::setFatal(uInt64 cycles)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void DispatchResult::setMessage(const string& message)
|
||||
void DispatchResult::setMessage(string_view message)
|
||||
{
|
||||
myMessage = message;
|
||||
}
|
||||
|
|
|
@ -31,34 +31,45 @@ class DispatchResult
|
|||
|
||||
uInt64 getCycles() const { return myCycles; }
|
||||
|
||||
const string& getMessage() const { assertStatus(Status::debugger, Status::fatal); return myMessage; }
|
||||
const string& getMessage() const {
|
||||
assertStatus(Status::debugger, Status::fatal);
|
||||
return myMessage;
|
||||
}
|
||||
|
||||
int getAddress() const { assertStatus(Status::debugger); return myAddress; }
|
||||
int getAddress() const {
|
||||
assertStatus(Status::debugger);
|
||||
return myAddress;
|
||||
}
|
||||
|
||||
bool wasReadTrap() const { assertStatus(Status::debugger); return myWasReadTrap; }
|
||||
bool wasReadTrap() const {
|
||||
assertStatus(Status::debugger);
|
||||
return myWasReadTrap;
|
||||
}
|
||||
|
||||
const string& getToolTip() const { assertStatus(Status::debugger, Status::fatal); return myToolTip; }
|
||||
const string& getToolTip() const {
|
||||
assertStatus(Status::debugger, Status::fatal);
|
||||
return myToolTip;
|
||||
}
|
||||
|
||||
bool isSuccess() const;
|
||||
|
||||
void setOk(uInt64 cycles);
|
||||
|
||||
void setDebugger(uInt64 cycles, const string& message = "",
|
||||
const string& tooltip = "", int address = -1, bool wasReadTrap = true);
|
||||
void setDebugger(uInt64 cycles, string_view message = "",
|
||||
string_view tooltip = "", int address = -1,
|
||||
bool wasReadTrap = true);
|
||||
|
||||
void setFatal(uInt64 cycles);
|
||||
|
||||
void setMessage(const string& message);
|
||||
void setMessage(string_view message);
|
||||
|
||||
private:
|
||||
|
||||
void assertStatus(Status status) const
|
||||
{
|
||||
void assertStatus(Status status) const {
|
||||
if (myStatus != status) throw runtime_error("invalid status for operation");
|
||||
}
|
||||
|
||||
template<typename ...Ts> void assertStatus(Status status, Ts... more) const
|
||||
{
|
||||
template<typename ...Ts> void assertStatus(Status status, Ts... more) const {
|
||||
if (myStatus == status) return;
|
||||
|
||||
assertStatus(more...);
|
||||
|
|
|
@ -181,7 +181,7 @@ void EventHandler::removePhysicalJoystick(int id)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void EventHandler::mapStelladaptors(const string& saport)
|
||||
void EventHandler::mapStelladaptors(string_view saport)
|
||||
{
|
||||
#ifdef JOYSTICK_SUPPORT
|
||||
myPJoyHandler->mapStelladaptors(saport);
|
||||
|
@ -1767,7 +1767,7 @@ void EventHandler::handleConsoleStartupEvents()
|
|||
if(myOSystem.settings().getBool("holdselect"))
|
||||
handleEvent(Event::ConsoleSelect);
|
||||
|
||||
const string& holdjoy0 = myOSystem.settings().getString("holdjoy0");
|
||||
const string_view holdjoy0 = myOSystem.settings().getString("holdjoy0");
|
||||
|
||||
if(BSPF::containsIgnoreCase(holdjoy0, "U"))
|
||||
handleEvent(Event::LeftJoystickUp);
|
||||
|
@ -1780,7 +1780,7 @@ void EventHandler::handleConsoleStartupEvents()
|
|||
if(BSPF::containsIgnoreCase(holdjoy0, "F"))
|
||||
handleEvent(Event::LeftJoystickFire);
|
||||
|
||||
const string& holdjoy1 = myOSystem.settings().getString("holdjoy1");
|
||||
const string_view holdjoy1 = myOSystem.settings().getString("holdjoy1");
|
||||
if(BSPF::containsIgnoreCase(holdjoy1, "U"))
|
||||
handleEvent(Event::RightJoystickUp);
|
||||
if(BSPF::containsIgnoreCase(holdjoy1, "D"))
|
||||
|
@ -2056,7 +2056,7 @@ json EventHandler::convertLegacyComboMapping(string list)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void EventHandler::removePhysicalJoystickFromDatabase(const string& name)
|
||||
void EventHandler::removePhysicalJoystickFromDatabase(string_view name)
|
||||
{
|
||||
#ifdef JOYSTICK_SUPPORT
|
||||
myPJoyHandler->remove(name);
|
||||
|
@ -2496,7 +2496,7 @@ string EventHandler::keyAtIndex(int idx, Event::Group group)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void EventHandler::setMouseControllerMode(const string& enable)
|
||||
void EventHandler::setMouseControllerMode(string_view enable)
|
||||
{
|
||||
if(myOSystem.hasConsole())
|
||||
{
|
||||
|
|
|
@ -79,7 +79,7 @@ class EventHandler
|
|||
|
||||
@param saport How to map the ports ('lr' or 'rl')
|
||||
*/
|
||||
void mapStelladaptors(const string& saport);
|
||||
void mapStelladaptors(string_view saport);
|
||||
|
||||
/**
|
||||
Toggles if all four joystick directions are allowed at once
|
||||
|
@ -145,7 +145,7 @@ class EventHandler
|
|||
Currently, this will be one of the following values:
|
||||
'always', 'analog', 'never'
|
||||
*/
|
||||
void setMouseControllerMode(const string& enable);
|
||||
void setMouseControllerMode(string_view enable);
|
||||
void changeMouseControllerMode(int direction = +1);
|
||||
void changeMouseCursor(int direction = +1);
|
||||
|
||||
|
@ -338,7 +338,7 @@ class EventHandler
|
|||
Remove the physical joystick identified by 'name' from the joystick
|
||||
database, only if it is not currently active.
|
||||
*/
|
||||
void removePhysicalJoystickFromDatabase(const string& name);
|
||||
void removePhysicalJoystickFromDatabase(string_view name);
|
||||
|
||||
/**
|
||||
Enable/disable text events (distinct from single-key events).
|
||||
|
|
|
@ -88,7 +88,7 @@ class FBBackend
|
|||
|
||||
@param title The title of the application / window
|
||||
*/
|
||||
virtual void setTitle(const string& title) = 0;
|
||||
virtual void setTitle(string_view title) = 0;
|
||||
|
||||
/**
|
||||
Shows or hides the cursor based on the given boolean value.
|
||||
|
|
|
@ -297,7 +297,7 @@ void FBSurface::frameRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void FBSurface::splitString(const GUI::Font& font, const string& s, int w,
|
||||
void FBSurface::splitString(const GUI::Font& font, string_view s, int w,
|
||||
string& left, string& right)
|
||||
{
|
||||
#ifdef GUI_SUPPORT
|
||||
|
@ -335,7 +335,7 @@ void FBSurface::splitString(const GUI::Font& font, const string& s, int w,
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
int FBSurface::drawString(const GUI::Font& font, const string& s,
|
||||
int FBSurface::drawString(const GUI::Font& font, string_view s,
|
||||
int x, int y, int w, int h,
|
||||
ColorId color, TextAlign align,
|
||||
int deltax, bool useEllipsis, ColorId shadowColor,
|
||||
|
@ -344,7 +344,7 @@ int FBSurface::drawString(const GUI::Font& font, const string& s,
|
|||
int lines = 0;
|
||||
|
||||
#ifdef GUI_SUPPORT
|
||||
string inStr = s;
|
||||
string inStr{s};
|
||||
|
||||
// draw multiline string
|
||||
while(inStr.length() && h >= font.getFontHeight() * 2)
|
||||
|
@ -374,7 +374,7 @@ int FBSurface::drawString(const GUI::Font& font, const string& s,
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
int FBSurface::drawString(const GUI::Font& font, const string& s,
|
||||
int FBSurface::drawString(const GUI::Font& font, string_view s,
|
||||
int x, int y, int w,
|
||||
ColorId color, TextAlign align,
|
||||
int deltax, bool useEllipsis, ColorId shadowColor,
|
||||
|
|
|
@ -228,10 +228,13 @@ class FBSurface
|
|||
@return Number of lines drawn
|
||||
*/
|
||||
|
||||
virtual int drawString(const GUI::Font& font, const string& s, int x, int y, int w, int h,
|
||||
ColorId color, TextAlign align = TextAlign::Left,
|
||||
int deltax = 0, bool useEllipsis = true, ColorId shadowColor = kNone,
|
||||
size_t linkStart = string::npos, size_t linkLen = string::npos,
|
||||
virtual int drawString(const GUI::Font& font, string_view s, int x, int y,
|
||||
int w, int h, ColorId color,
|
||||
TextAlign align = TextAlign::Left,
|
||||
int deltax = 0, bool useEllipsis = true,
|
||||
ColorId shadowColor = kNone,
|
||||
size_t linkStart = string::npos,
|
||||
size_t linkLen = string::npos,
|
||||
bool underline = false);
|
||||
|
||||
/**
|
||||
|
@ -254,10 +257,12 @@ class FBSurface
|
|||
@return x coordinate of end of string
|
||||
|
||||
*/
|
||||
virtual int drawString(const GUI::Font& font, const string& s, int x, int y, int w,
|
||||
ColorId color, TextAlign align = TextAlign::Left,
|
||||
int deltax = 0, bool useEllipsis = true, ColorId shadowColor = kNone,
|
||||
size_t linkStart = string::npos, size_t linkLen = string::npos,
|
||||
virtual int drawString(const GUI::Font& font, string_view s, int x, int y,
|
||||
int w, ColorId color, TextAlign align = TextAlign::Left,
|
||||
int deltax = 0, bool useEllipsis = true,
|
||||
ColorId shadowColor = kNone,
|
||||
size_t linkStart = string::npos,
|
||||
size_t linkLen = string::npos,
|
||||
bool underline = false);
|
||||
|
||||
/**
|
||||
|
@ -269,7 +274,7 @@ class FBSurface
|
|||
@param left The left part of the split string
|
||||
@param right The right part of the split string
|
||||
*/
|
||||
static void splitString(const GUI::Font& font, const string& s, int w,
|
||||
static void splitString(const GUI::Font& font, string_view s, int w,
|
||||
string& left, string& right);
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,13 +26,13 @@ FSNode::FSNode(const AbstractFSNodePtr& realNode)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
FSNode::FSNode(const string& path)
|
||||
FSNode::FSNode(string_view path)
|
||||
{
|
||||
setPath(path);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void FSNode::setPath(const string& path)
|
||||
void FSNode::setPath(string_view path)
|
||||
{
|
||||
// Only create a new object when necessary
|
||||
if (path == getPath())
|
||||
|
@ -48,7 +48,7 @@ void FSNode::setPath(const string& path)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
FSNode& FSNode::operator/=(const string& path)
|
||||
FSNode& FSNode::operator/=(string_view path)
|
||||
{
|
||||
if (path != EmptyString)
|
||||
{
|
||||
|
@ -230,7 +230,7 @@ const string& FSNode::getName() const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void FSNode::setName(const string& name)
|
||||
void FSNode::setName(string_view name)
|
||||
{
|
||||
if (_realNode)
|
||||
_realNode->setName(name);
|
||||
|
@ -249,7 +249,7 @@ string FSNode::getShortPath() const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string FSNode::getNameWithExt(const string& ext) const
|
||||
string FSNode::getNameWithExt(string_view ext) const
|
||||
{
|
||||
if (!_realNode)
|
||||
return EmptyString;
|
||||
|
@ -259,11 +259,13 @@ string FSNode::getNameWithExt(const string& ext) const
|
|||
_realNode->getName().substr(pos+1);
|
||||
|
||||
pos = s.find_last_of('.');
|
||||
return (pos != string::npos) ? s.replace(pos, string::npos, ext) : s + ext;
|
||||
return (pos != string::npos)
|
||||
? s.replace(pos, string::npos, ext)
|
||||
: s + string{ext};
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string FSNode::getPathWithExt(const string& ext) const
|
||||
string FSNode::getPathWithExt(string_view ext) const
|
||||
{
|
||||
if (!_realNode)
|
||||
return EmptyString;
|
||||
|
@ -271,7 +273,9 @@ string FSNode::getPathWithExt(const string& ext) const
|
|||
string s = _realNode->getPath();
|
||||
|
||||
const size_t pos = s.find_last_of('.');
|
||||
return (pos != string::npos) ? s.replace(pos, string::npos, ext) : s + ext;
|
||||
return (pos != string::npos)
|
||||
? s.replace(pos, string::npos, ext)
|
||||
: s + string{ext};
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -321,7 +325,7 @@ bool FSNode::makeDir()
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool FSNode::rename(const string& newfile)
|
||||
bool FSNode::rename(string_view newfile)
|
||||
{
|
||||
return (_realNode && _realNode->exists()) ? _realNode->rename(newfile) : false;
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ class FSNode
|
|||
* operating system doesn't support the concept), some other directory is
|
||||
* used (usually the root directory).
|
||||
*/
|
||||
explicit FSNode(const string& path);
|
||||
explicit FSNode(string_view path);
|
||||
|
||||
/**
|
||||
* Assignment operators.
|
||||
|
@ -106,7 +106,7 @@ class FSNode
|
|||
* Append the given path to the node, adding a directory separator
|
||||
* when necessary. Modelled on the C++17 fs::path API.
|
||||
*/
|
||||
FSNode& operator/=(const string& path);
|
||||
FSNode& operator/=(string_view path);
|
||||
|
||||
/**
|
||||
* By default, the output operator simply outputs the fully-qualified
|
||||
|
@ -159,7 +159,7 @@ class FSNode
|
|||
* @return the file name
|
||||
*/
|
||||
const string& getName() const;
|
||||
void setName(const string& name);
|
||||
void setName(string_view name);
|
||||
|
||||
/**
|
||||
* Return a string representation of the file which can be passed to fopen().
|
||||
|
@ -241,7 +241,7 @@ class FSNode
|
|||
*
|
||||
* @return bool true if the node was renamed, false otherwise.
|
||||
*/
|
||||
bool rename(const string& newfile);
|
||||
bool rename(string_view newfile);
|
||||
|
||||
/**
|
||||
* Get the size of the current node path.
|
||||
|
@ -302,13 +302,13 @@ class FSNode
|
|||
* and replace the extension (if present) with the given one. If no
|
||||
* extension is present, the given one is appended instead.
|
||||
*/
|
||||
string getNameWithExt(const string& ext = "") const;
|
||||
string getPathWithExt(const string& ext = "") const;
|
||||
string getNameWithExt(string_view ext = "") const;
|
||||
string getPathWithExt(string_view ext = "") const;
|
||||
|
||||
private:
|
||||
explicit FSNode(const AbstractFSNodePtr& realNode);
|
||||
AbstractFSNodePtr _realNode;
|
||||
void setPath(const string& path);
|
||||
void setPath(string_view path);
|
||||
};
|
||||
|
||||
|
||||
|
@ -370,7 +370,7 @@ class AbstractFSNode
|
|||
* implementation for more information.
|
||||
*/
|
||||
virtual const string& getName() const = 0;
|
||||
virtual void setName(const string& name) = 0;
|
||||
virtual void setName(string_view name) = 0;
|
||||
|
||||
/**
|
||||
* Returns the 'path' of the current node, usable in fopen().
|
||||
|
@ -443,7 +443,7 @@ class AbstractFSNode
|
|||
*
|
||||
* @return bool true if the node was renamed, false otherwise.
|
||||
*/
|
||||
virtual bool rename(const string& newfile) = 0;
|
||||
virtual bool rename(string_view newfile) = 0;
|
||||
|
||||
/**
|
||||
* Get the size of the current node path.
|
||||
|
@ -504,12 +504,12 @@ class AbstractFSNode
|
|||
* @param str String containing the path.
|
||||
* @return Pointer to the first char of the last component inside str.
|
||||
*/
|
||||
static const char* lastPathComponent(const string& str)
|
||||
static const char* lastPathComponent(string_view str)
|
||||
{
|
||||
if(str.empty())
|
||||
return "";
|
||||
|
||||
const char* const start = str.c_str();
|
||||
const char* const start = str.data();
|
||||
const char* cur = start + str.size() - 2;
|
||||
|
||||
while (cur >= start && !(*cur == '/' || *cur == '\\'))
|
||||
|
|
|
@ -174,7 +174,7 @@ void FrameBuffer::setupFonts()
|
|||
GUI::consoleDesc, GUI::consoleMediumDesc, GUI::stellaMediumDesc,
|
||||
GUI::stellaLargeDesc, GUI::stella12x24tDesc, GUI::stella14x28tDesc,
|
||||
GUI::stella16x32tDesc};
|
||||
const string& dialogFont = myOSystem.settings().getString("dialogfont");
|
||||
const string_view dialogFont = myOSystem.settings().getString("dialogfont");
|
||||
const FontDesc fd = getFontDesc(dialogFont);
|
||||
|
||||
// The general font used in all UI elements
|
||||
|
@ -202,13 +202,13 @@ void FrameBuffer::setupFonts()
|
|||
}
|
||||
|
||||
// The font used by the ROM launcher
|
||||
const string& lf = myOSystem.settings().getString("launcherfont");
|
||||
const string_view lf = myOSystem.settings().getString("launcherfont");
|
||||
|
||||
myLauncherFont = make_unique<GUI::Font>(getFontDesc(lf)); // 8x13
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
FontDesc FrameBuffer::getFontDesc(const string& name)
|
||||
FontDesc FrameBuffer::getFontDesc(string_view name)
|
||||
{
|
||||
if(name == "small")
|
||||
return GUI::consoleDesc; // 8x13
|
||||
|
@ -228,7 +228,7 @@ FontDesc FrameBuffer::getFontDesc(const string& name)
|
|||
#endif
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
FBInitStatus FrameBuffer::createDisplay(const string& title, BufferType type,
|
||||
FBInitStatus FrameBuffer::createDisplay(string_view title, BufferType type,
|
||||
Common::Size size, bool honourHiDPI)
|
||||
{
|
||||
++myInitializedCount;
|
||||
|
@ -609,7 +609,8 @@ void FrameBuffer::updateInEmulationMode(float framesPerSecond)
|
|||
|
||||
#ifdef GUI_SUPPORT
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void FrameBuffer::createMessage(const string& message, MessagePosition position, bool force)
|
||||
void FrameBuffer::createMessage(string_view message, MessagePosition position,
|
||||
bool force)
|
||||
{
|
||||
// Only show messages if they've been enabled
|
||||
if(myMsg.surface == nullptr || !(force || myOSystem.settings().getBool("uimessages")))
|
||||
|
@ -637,8 +638,8 @@ void FrameBuffer::createMessage(const string& message, MessagePosition position,
|
|||
#endif
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void FrameBuffer::showTextMessage(const string& message, MessagePosition position,
|
||||
bool force)
|
||||
void FrameBuffer::showTextMessage(string_view message,
|
||||
MessagePosition position, bool force)
|
||||
{
|
||||
#ifdef GUI_SUPPORT
|
||||
const int fontWidth = font().getMaxCharWidth();
|
||||
|
@ -653,7 +654,7 @@ void FrameBuffer::showTextMessage(const string& message, MessagePosition positio
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void FrameBuffer::showGaugeMessage(const string& message, const string& valueText,
|
||||
void FrameBuffer::showGaugeMessage(string_view message, string_view valueText,
|
||||
float value, float minValue, float maxValue)
|
||||
{
|
||||
#ifdef GUI_SUPPORT
|
||||
|
|
|
@ -83,7 +83,7 @@ class FrameBuffer
|
|||
|
||||
@return Status of initialization (see FBInitStatus 'enum')
|
||||
*/
|
||||
FBInitStatus createDisplay(const string& title, BufferType type,
|
||||
FBInitStatus createDisplay(string_view title, BufferType type,
|
||||
Common::Size size, bool honourHiDPI = true);
|
||||
|
||||
/**
|
||||
|
@ -109,7 +109,7 @@ class FrameBuffer
|
|||
@param position Onscreen position for the message
|
||||
@param force Force showing this message, even if messages are disabled
|
||||
*/
|
||||
void showTextMessage(const string& message,
|
||||
void showTextMessage(string_view message,
|
||||
MessagePosition position = MessagePosition::BottomCenter,
|
||||
bool force = false);
|
||||
/**
|
||||
|
@ -121,7 +121,7 @@ class FrameBuffer
|
|||
@param minValue The minimal value of the gauge bar
|
||||
@param maxValue The maximal value of the gauge bar
|
||||
*/
|
||||
void showGaugeMessage(const string& message, const string& valueText,
|
||||
void showGaugeMessage(string_view message, string_view valueText,
|
||||
float value, float minValue = 0.F, float maxValue = 100.F);
|
||||
|
||||
bool messageShown() const;
|
||||
|
@ -324,7 +324,7 @@ class FrameBuffer
|
|||
|
||||
@return The description of the font
|
||||
*/
|
||||
static FontDesc getFontDesc(const string& name);
|
||||
static FontDesc getFontDesc(string_view name);
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -407,7 +407,7 @@ class FrameBuffer
|
|||
@param position Onscreen position for the message
|
||||
@param force Force showing this message, even if messages are disabled
|
||||
*/
|
||||
void createMessage(const string& message, MessagePosition position,
|
||||
void createMessage(string_view message, MessagePosition position,
|
||||
bool force = false);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
KidVid::KidVid(Jack jack, const Event& event, const OSystem& osystem,
|
||||
const System& system, const string& romMd5,
|
||||
const System& system, string_view romMd5,
|
||||
const onMessageCallbackForced& callback)
|
||||
: Controller(jack, event, system, Controller::Type::KidVid),
|
||||
myEnabled{myJack == Jack::Right},
|
||||
|
|
|
@ -49,7 +49,7 @@ class KidVid : public Controller
|
|||
@param callback Called to pass messages back to the parent controller
|
||||
*/
|
||||
KidVid(Jack jack, const Event& event, const OSystem& osystem,
|
||||
const System& system, const string& romMd5,
|
||||
const System& system, string_view romMd5,
|
||||
const onMessageCallbackForced& callback);
|
||||
~KidVid() override = default;
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Lightgun::Lightgun(Jack jack, const Event& event, const System& system,
|
||||
const string& romMd5, const FrameBuffer& frameBuffer)
|
||||
string_view romMd5, const FrameBuffer& frameBuffer)
|
||||
: Controller(jack, event, system, Controller::Type::Lightgun),
|
||||
myFrameBuffer{frameBuffer}
|
||||
{
|
||||
|
|
|
@ -43,7 +43,7 @@ class Lightgun : public Controller
|
|||
|
||||
*/
|
||||
Lightgun(Jack jack, const Event& event, const System& system,
|
||||
const string& romMd5, const FrameBuffer& frameBuffer);
|
||||
string_view romMd5, const FrameBuffer& frameBuffer);
|
||||
~Lightgun() override = default;
|
||||
|
||||
public:
|
||||
|
|
|
@ -568,10 +568,10 @@ void M6502::attach(Debugger& debugger)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt32 M6502::addCondBreak(Expression* e, const string& name, bool oneShot)
|
||||
uInt32 M6502::addCondBreak(Expression* e, string_view name, bool oneShot)
|
||||
{
|
||||
myCondBreaks.emplace_back(e);
|
||||
myCondBreakNames.push_back(name);
|
||||
myCondBreakNames.emplace_back(name);
|
||||
|
||||
updateStepStateByInstruction();
|
||||
|
||||
|
@ -609,10 +609,10 @@ const StringList& M6502::getCondBreakNames() const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt32 M6502::addCondSaveState(Expression* e, const string& name)
|
||||
uInt32 M6502::addCondSaveState(Expression* e, string_view name)
|
||||
{
|
||||
myCondSaveStates.emplace_back(e);
|
||||
myCondSaveStateNames.push_back(name);
|
||||
myCondSaveStateNames.emplace_back(name);
|
||||
|
||||
updateStepStateByInstruction();
|
||||
|
||||
|
@ -650,10 +650,10 @@ const StringList& M6502::getCondSaveStateNames() const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt32 M6502::addCondTrap(Expression* e, const string& name)
|
||||
uInt32 M6502::addCondTrap(Expression* e, string_view name)
|
||||
{
|
||||
myTrapConds.emplace_back(e);
|
||||
myTrapCondNames.push_back(name);
|
||||
myTrapCondNames.emplace_back(name);
|
||||
|
||||
updateStepStateByInstruction();
|
||||
|
||||
|
|
|
@ -236,19 +236,19 @@ class M6502 : public Serializable
|
|||
BreakpointMap& breakPoints() { return myBreakPoints; }
|
||||
|
||||
// methods for 'breakif' handling
|
||||
uInt32 addCondBreak(Expression* e, const string& name, bool oneShot = false);
|
||||
uInt32 addCondBreak(Expression* e, string_view name, bool oneShot = false);
|
||||
bool delCondBreak(uInt32 idx);
|
||||
void clearCondBreaks();
|
||||
const StringList& getCondBreakNames() const;
|
||||
|
||||
// methods for 'savestateif' handling
|
||||
uInt32 addCondSaveState(Expression* e, const string& name);
|
||||
uInt32 addCondSaveState(Expression* e, string_view name);
|
||||
bool delCondSaveState(uInt32 idx);
|
||||
void clearCondSaveStates();
|
||||
const StringList& getCondSaveStateNames() const;
|
||||
|
||||
// methods for 'trapif' handling
|
||||
uInt32 addCondTrap(Expression* e, const string& name);
|
||||
uInt32 addCondTrap(Expression* e, string_view name);
|
||||
bool delCondTrap(uInt32 idx);
|
||||
void clearCondTraps();
|
||||
const StringList& getCondTrapNames() const;
|
||||
|
|
|
@ -301,11 +301,9 @@ static void Decode(uInt32* output, const uInt8* const input, uInt32 len)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string hash(const string& buffer)
|
||||
string hash(string_view buffer)
|
||||
{
|
||||
std::vector<uint8_t> vec(buffer.begin(), buffer.end());
|
||||
|
||||
return hash(vec.data(), vec.size());
|
||||
return hash(reinterpret_cast<const uInt8*>(buffer.data()), buffer.size());
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace MD5 {
|
|||
|
||||
@return The message - digest
|
||||
*/
|
||||
string hash(const string& buffer);
|
||||
string hash(string_view buffer);
|
||||
|
||||
} // namespace MD5
|
||||
|
||||
|
|
|
@ -207,7 +207,7 @@ bool OSystem::initialize(const Settings::Options& options)
|
|||
// Detect serial port for AtariVox-USB
|
||||
// If a previously set port is defined, use it;
|
||||
// otherwise use the first one found (if any)
|
||||
const string& avoxport = mySettings->getString("avoxport");
|
||||
const string_view avoxport = mySettings->getString("avoxport");
|
||||
const StringList ports = MediaFactory::createSerialPort()->portNames();
|
||||
|
||||
if(avoxport.empty() && !ports.empty())
|
||||
|
@ -277,7 +277,7 @@ void OSystem::setConfigPaths()
|
|||
// Make sure all required directories actually exist
|
||||
const auto buildDirIfRequired = [](FSNode& path,
|
||||
const FSNode& initialPath,
|
||||
const string& pathToAppend = EmptyString)
|
||||
string_view pathToAppend = EmptyString)
|
||||
{
|
||||
path = initialPath;
|
||||
if(pathToAppend != EmptyString)
|
||||
|
@ -293,7 +293,7 @@ void OSystem::setConfigPaths()
|
|||
#endif
|
||||
|
||||
#ifdef IMAGE_SUPPORT
|
||||
const string& ssSaveDir = mySettings->getString("snapsavedir");
|
||||
const string_view ssSaveDir = mySettings->getString("snapsavedir");
|
||||
if(ssSaveDir == EmptyString)
|
||||
mySnapshotSaveDir = userDir();
|
||||
else
|
||||
|
@ -301,7 +301,7 @@ void OSystem::setConfigPaths()
|
|||
if(!mySnapshotSaveDir.isDirectory())
|
||||
mySnapshotSaveDir.makeDir();
|
||||
|
||||
const string& ssLoadDir = mySettings->getString("snaploaddir");
|
||||
const string_view ssLoadDir = mySettings->getString("snaploaddir");
|
||||
if(ssLoadDir == EmptyString)
|
||||
mySnapshotLoadDir = userDir();
|
||||
else
|
||||
|
@ -315,7 +315,7 @@ void OSystem::setConfigPaths()
|
|||
|
||||
#if 0
|
||||
// Debug code
|
||||
auto dbgPath = [](const string& desc, const FSNode& location)
|
||||
auto dbgPath = [](string_view desc, const FSNode& location)
|
||||
{
|
||||
cerr << desc << ": " << location << endl;
|
||||
};
|
||||
|
@ -331,7 +331,7 @@ void OSystem::setConfigPaths()
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void OSystem::setUserDir(const string& path)
|
||||
void OSystem::setUserDir(string_view path)
|
||||
{
|
||||
mySettings->setValue("userdir", path);
|
||||
|
||||
|
@ -416,8 +416,7 @@ void OSystem::createSound()
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string OSystem::createConsole(const FSNode& rom, const string& md5sum,
|
||||
bool newrom)
|
||||
string OSystem::createConsole(const FSNode& rom, string_view md5sum, bool newrom)
|
||||
{
|
||||
bool showmessage = false;
|
||||
|
||||
|
@ -567,7 +566,7 @@ bool OSystem::hasConsole() const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool OSystem::createLauncher(const string& startdir)
|
||||
bool OSystem::createLauncher(string_view startdir)
|
||||
{
|
||||
closeConsole();
|
||||
|
||||
|
@ -666,7 +665,7 @@ unique_ptr<Console> OSystem::openConsole(const FSNode& romfile, string& md5)
|
|||
// Now create the cartridge
|
||||
string cartmd5 = md5;
|
||||
const string& type = props.get(PropType::Cart_Type);
|
||||
const Cartridge::messageCallback callback = [&os = *this](const string& msg)
|
||||
const Cartridge::messageCallback callback = [&os = *this](string_view msg)
|
||||
{
|
||||
const bool devSettings = os.settings().getBool("dev.settings");
|
||||
|
||||
|
|
|
@ -365,7 +365,7 @@ class OSystem
|
|||
|
||||
@return String indicating any error message (EmptyString for no errors)
|
||||
*/
|
||||
string createConsole(const FSNode& rom, const string& md5 = "",
|
||||
string createConsole(const FSNode& rom, string_view md5 = "",
|
||||
bool newrom = true);
|
||||
|
||||
/**
|
||||
|
@ -386,7 +386,7 @@ class OSystem
|
|||
|
||||
@return True on successful creation, otherwise false
|
||||
*/
|
||||
bool createLauncher(const string& startdir = "");
|
||||
bool createLauncher(string_view startdir = "");
|
||||
|
||||
/**
|
||||
Answers whether the ROM launcher was actually successfully used
|
||||
|
@ -455,11 +455,11 @@ class OSystem
|
|||
Again, this is not supported on all systems, so it may be simply
|
||||
ignored.
|
||||
*/
|
||||
static void overrideBaseDir(const string& path) { ourOverrideBaseDir = path; }
|
||||
static void overrideBaseDir(string_view path) { ourOverrideBaseDir = path; }
|
||||
static void overrideBaseDirWithApp() { ourOverrideBaseDirWithApp = true; }
|
||||
|
||||
// Update the path of the user directory
|
||||
void setUserDir(const string& path);
|
||||
void setUserDir(string_view path);
|
||||
|
||||
public:
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
@ -505,7 +505,7 @@ class OSystem
|
|||
they are free to ignore it
|
||||
*/
|
||||
virtual void getBaseDirectories(string& basedir, string& homedir,
|
||||
bool useappdir, const string& usedir) = 0;
|
||||
bool useappdir, string_view usedir) = 0;
|
||||
|
||||
virtual void initPersistence(FSNode& basedir) = 0;
|
||||
|
||||
|
|
|
@ -51,6 +51,6 @@ shared_ptr<CompositeKeyValueRepositoryAtomic> OSystemStandalone::getHighscoreRep
|
|||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void OSystemStandalone::getBaseDirectories(
|
||||
string& basedir, string& homedir, bool useappdir, const string& usedir)
|
||||
string& basedir, string& homedir, bool useappdir, string_view usedir)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ class OSystemStandalone : public OSystem
|
|||
string describePresistence() override;
|
||||
|
||||
void getBaseDirectories(string& basedir, string& homedir,
|
||||
bool useappdir, const string& usedir) override;
|
||||
bool useappdir, string_view usedir) override;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ using std::chrono::milliseconds;
|
|||
class PlusROMRequest {
|
||||
public:
|
||||
struct Destination {
|
||||
Destination(const string& _host, const string& _path)
|
||||
Destination(string_view _host, string_view _path)
|
||||
: host{_host}, path{_path} {}
|
||||
|
||||
string host;
|
||||
|
@ -55,7 +55,7 @@ class PlusROMRequest {
|
|||
};
|
||||
|
||||
struct PlusStoreId {
|
||||
PlusStoreId(const string& _nick, const string& _id)
|
||||
PlusStoreId(string_view _nick, string_view _id)
|
||||
: nick{_nick}, id{_id} {}
|
||||
|
||||
string nick;
|
||||
|
@ -369,7 +369,7 @@ void PlusROM::reset()
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool PlusROM::isValidHost(const string& host)
|
||||
bool PlusROM::isValidHost(string_view host)
|
||||
{
|
||||
// TODO: This isn't 100% either, as we're supposed to check for the length
|
||||
// of each part between '.' in the range 1 .. 63
|
||||
|
@ -377,11 +377,11 @@ bool PlusROM::isValidHost(const string& host)
|
|||
// library we decide to use
|
||||
static const std::regex rgx(R"(^(([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])\.)*([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])$)", std::regex_constants::icase);
|
||||
|
||||
return std::regex_match(host, rgx);
|
||||
return std::regex_match(host.cbegin(), host.cend(), rgx);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool PlusROM::isValidPath(const string& path)
|
||||
bool PlusROM::isValidPath(string_view path)
|
||||
{
|
||||
// TODO: This isn't 100%
|
||||
// Perhaps a better function will be included with whatever network
|
||||
|
|
|
@ -157,8 +157,8 @@ class PlusROM : public Serializable
|
|||
}
|
||||
|
||||
private:
|
||||
static bool isValidHost(const string& host);
|
||||
static bool isValidPath(const string& path);
|
||||
static bool isValidHost(string_view host);
|
||||
static bool isValidPath(string_view path);
|
||||
|
||||
/**
|
||||
Receive data from all requests that have completed.
|
||||
|
|
|
@ -61,7 +61,7 @@ bool Properties::save(KeyValueRepository& repo) const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Properties::set(PropType key, const string& value)
|
||||
void Properties::set(PropType key, string_view value)
|
||||
{
|
||||
const auto pos = static_cast<size_t>(key);
|
||||
if(pos < myProperties.size())
|
||||
|
@ -137,7 +137,7 @@ Properties& Properties::operator=(const Properties& properties)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Properties::setDefault(PropType key, const string& value)
|
||||
void Properties::setDefault(PropType key, string_view value)
|
||||
{
|
||||
ourDefaultProperties[static_cast<size_t>(key)] = value;
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ void Properties::setDefaults()
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
PropType Properties::getPropType(const string& name)
|
||||
PropType Properties::getPropType(string_view name)
|
||||
{
|
||||
for(size_t i = 0; i < NUM_PROPS; ++i)
|
||||
if(ourPropertyNames[i] == name)
|
||||
|
|
|
@ -106,7 +106,7 @@ class Properties
|
|||
@param key The key of the property to set
|
||||
@param value The value to assign to the property
|
||||
*/
|
||||
void set(PropType key, const string& value);
|
||||
void set(PropType key, string_view value);
|
||||
|
||||
/**
|
||||
Print the attributes of this properties object
|
||||
|
@ -148,7 +148,7 @@ class Properties
|
|||
@param key The key of the property to set
|
||||
@param value The value to assign to the property
|
||||
*/
|
||||
static void setDefault(PropType key, const string& value);
|
||||
static void setDefault(PropType key, string_view value);
|
||||
|
||||
private:
|
||||
/**
|
||||
|
@ -165,7 +165,7 @@ class Properties
|
|||
|
||||
@param name The PropType key associated with the given string
|
||||
*/
|
||||
static PropType getPropType(const string& name);
|
||||
static PropType getPropType(string_view name);
|
||||
|
||||
/**
|
||||
When printing each collection of ROM properties, it is useful to
|
||||
|
|
|
@ -70,7 +70,7 @@ unique_ptr<Controller> QuadTari::addController(const Controller::Type type, bool
|
|||
{
|
||||
FSNode nvramfile = myOSystem.nvramDir();
|
||||
const Controller::onMessageCallback callback = [&os = myOSystem]
|
||||
(const string& msg) {
|
||||
(string_view msg) {
|
||||
const bool devSettings = os.settings().getBool("dev.settings");
|
||||
if(os.settings().getBool(devSettings ? "dev.extaccess" : "plr.extaccess"))
|
||||
os.frameBuffer().showTextMessage(msg);
|
||||
|
|
|
@ -22,14 +22,15 @@ using std::ios;
|
|||
using std::ios_base;
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Serializer::Serializer(const string& filename, Mode m)
|
||||
Serializer::Serializer(string_view filename, Mode m)
|
||||
{
|
||||
if(m == Mode::ReadOnly)
|
||||
{
|
||||
const FSNode node(filename);
|
||||
if(node.isFile() && node.isReadable())
|
||||
{
|
||||
unique_ptr<fstream> str = make_unique<fstream>(filename, ios::in | ios::binary);
|
||||
unique_ptr<fstream> str = make_unique<fstream>(
|
||||
string{filename}, ios::in | ios::binary);
|
||||
if(str && str->is_open())
|
||||
{
|
||||
myStream = std::move(str);
|
||||
|
@ -48,13 +49,14 @@ Serializer::Serializer(const string& filename, Mode m)
|
|||
// So we open in write and append mode - the write creates the file
|
||||
// when necessary, and the append doesn't delete any data if it
|
||||
// already exists
|
||||
fstream temp(filename, ios::out | ios::app);
|
||||
string f{filename};
|
||||
fstream temp(f, ios::out | ios::app);
|
||||
temp.close();
|
||||
|
||||
ios_base::openmode stream_mode = ios::in | ios::out | ios::binary;
|
||||
if(m == Mode::ReadWriteTrunc)
|
||||
stream_mode |= ios::trunc;
|
||||
unique_ptr<fstream> str = make_unique<fstream>(filename, stream_mode);
|
||||
unique_ptr<fstream> str = make_unique<fstream>(f, stream_mode);
|
||||
if(str && str->is_open())
|
||||
{
|
||||
myStream = std::move(str);
|
||||
|
@ -236,11 +238,10 @@ void Serializer::putDouble(double value)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Serializer::putString(const string& str)
|
||||
void Serializer::putString(string_view str)
|
||||
{
|
||||
const auto len = static_cast<uInt32>(str.length());
|
||||
putInt(len);
|
||||
myStream->write(str.data(), len);
|
||||
putInt(static_cast<uInt32>(str.size()));
|
||||
myStream->write(str.data(), str.size());
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -49,7 +49,7 @@ class Serializer
|
|||
The valid() method must immediately be called to verify the stream
|
||||
was correctly initialized.
|
||||
*/
|
||||
explicit Serializer(const string& filename, Mode m = Mode::ReadWrite);
|
||||
explicit Serializer(string_view filename, Mode m = Mode::ReadWrite);
|
||||
Serializer();
|
||||
|
||||
public:
|
||||
|
@ -207,11 +207,11 @@ class Serializer
|
|||
void putDouble(double value);
|
||||
|
||||
/**
|
||||
Writes a string to the current output stream.
|
||||
Writes a string(view) to the current output stream.
|
||||
|
||||
@param str The string to write to the output stream.
|
||||
*/
|
||||
void putString(const string& str);
|
||||
void putString(string_view str);
|
||||
|
||||
/**
|
||||
Writes a boolean value to the current output stream.
|
||||
|
|
|
@ -192,7 +192,6 @@ Settings::Settings()
|
|||
setPermanent("confirmexit", false);
|
||||
setPermanent("autopause", false);
|
||||
|
||||
|
||||
// Misc options
|
||||
setPermanent("loglevel", static_cast<int>(Logger::Level::INFO));
|
||||
setPermanent("logtoconsole", "0");
|
||||
|
|
|
@ -1185,14 +1185,9 @@ bool TIA::enableFixedColors(bool enable)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool TIA::setFixedColorPalette(const string& colors)
|
||||
bool TIA::setFixedColorPalette(string_view colors)
|
||||
{
|
||||
string s = colors;
|
||||
sort(s.begin(), s.end());
|
||||
if(s != "bgopry")
|
||||
return false;
|
||||
|
||||
for(int i = 0; i < 6; ++i)
|
||||
for(size_t i = 0; i < std::max<size_t>(6, colors.size()); ++i)
|
||||
{
|
||||
switch(colors[i])
|
||||
{
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue