summaryrefslogtreecommitdiffstats
path: root/src/frontend/mame/clifront.cpp
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2021-01-20 17:46:03 -0500
committer AJR <ajrhacker@users.noreply.github.com>2021-01-20 18:06:15 -0500
commit91921618c2e06bd0ed073b8efccd31a127c9012d (patch)
treed3958b32d8db82540cd31083766b22991eb8e8ae /src/frontend/mame/clifront.cpp
parentc691b79cce315acdfabe1901cb2b5a1e39957bc1 (diff)
Much more core std::string_view modernization
- Remove corestr.h from emu.h; update a few source files to not use it at all - Change strtrimspace, strtrimrightspace and core_filename_extract_* to be pure functions taking a std::string_view by value and returning the same type - Change strmakeupper and strmakelower to be pure functions taking a std::string_view and constructing a std::string - Remove the string-modifying version of zippath_parent - Change tag-based lookup functions in device_t to take std::string_view instead of const std::string & or const char * - Remove the subdevice tag cache from device_t (since device finders are now recommended) and replace it with a map covering directly owned subdevices only - Move the working directory setup method out of device_image_interface (only the UI seems to actually use the full version of this) - Change output_manager to use std::string_view for output name arguments - Change core_options to accept std::string_view for most name and value arguments (return values are still C strings for now) - Change miscellaneous other functions to accept std::string_view arguments - Remove a few string accessor macros from romload.h - Remove many unnecessary c_str() calls from logging/error messages
Diffstat (limited to 'src/frontend/mame/clifront.cpp')
-rw-r--r--src/frontend/mame/clifront.cpp35
1 files changed, 15 insertions, 20 deletions
diff --git a/src/frontend/mame/clifront.cpp b/src/frontend/mame/clifront.cpp
index 3d177e7e851..1c2ba0d809c 100644
--- a/src/frontend/mame/clifront.cpp
+++ b/src/frontend/mame/clifront.cpp
@@ -18,17 +18,18 @@
#include "language.h"
#include "luaengine.h"
#include "mame.h"
+#include "mameopts.h"
#include "media_ident.h"
#include "pluginopts.h"
#include "emuopts.h"
-#include "mameopts.h"
#include "romload.h"
#include "softlist_dev.h"
#include "validity.h"
#include "sound/samples.h"
#include "chd.h"
+#include "corestr.h"
#include "unzip.h"
#include "xmlfile.h"
@@ -229,12 +230,12 @@ void cli_frontend::start_execution(mame_machine_manager *manager, const std::vec
}
// determine the base name of the EXE
- std::string exename = core_filename_extract_base(args[0], true);
+ std::string_view exename = core_filename_extract_base(args[0], true);
// if we have a command, execute that
if (!m_options.command().empty())
{
- execute_commands(exename.c_str());
+ execute_commands(exename);
return;
}
@@ -253,10 +254,7 @@ void cli_frontend::start_execution(mame_machine_manager *manager, const std::vec
manager->start_luaengine();
if (option_errors.tellp() > 0)
- {
- std::string option_errors_string = option_errors.str();
- osd_printf_error("Error in command line:\n%s\n", strtrimspace(option_errors_string));
- }
+ osd_printf_error("Error in command line:\n%s\n", strtrimspace(option_errors.str()));
// if we can't find it, give an appropriate error
const game_driver *system = mame_options::system(m_options);
@@ -285,9 +283,7 @@ int cli_frontend::execute(std::vector<std::string> &args)
// handle exceptions of various types
catch (emu_fatalerror &fatal)
{
- std::string str(fatal.what());
- strtrimspace(str);
- osd_printf_error("%s\n", str);
+ osd_printf_error("%s\n", strtrimspace(fatal.what()));
m_result = (fatal.exitcode() != 0) ? fatal.exitcode() : EMU_ERR_FATALERROR;
// if a game was specified, wasn't a wildcard, and our error indicates this was the
@@ -568,8 +564,7 @@ void cli_frontend::listroms(const std::vector<std::string> &args)
length = rom_file_size(rom);
// start with the name
- const char *name = ROM_GETNAME(rom);
- osd_printf_info("%-32s ", name);
+ osd_printf_info("%-32s ", rom->name());
// output the length next
if (length >= 0)
@@ -578,7 +573,7 @@ void cli_frontend::listroms(const std::vector<std::string> &args)
osd_printf_info("%10s", "");
// output the hash data
- util::hash_collection hashes(ROM_GETHASHDATA(rom));
+ util::hash_collection hashes(rom->hashdata());
if (!hashes.flag(util::hash_collection::FLAG_NO_DUMP))
{
if (hashes.flag(util::hash_collection::FLAG_BAD_DUMP))
@@ -1101,7 +1096,7 @@ void cli_frontend::output_single_softlist(std::ostream &out, software_list_devic
util::stream_format(out, "\t\t\t<publisher>%s</publisher>\n", util::xml::normalize_string(swinfo.publisher().c_str()));
for (const feature_list_item &flist : swinfo.other_info())
- util::stream_format(out, "\t\t\t<info name=\"%s\" value=\"%s\"/>\n", flist.name().c_str(), util::xml::normalize_string(flist.value().c_str()));
+ util::stream_format(out, "\t\t\t<info name=\"%s\" value=\"%s\"/>\n", flist.name(), util::xml::normalize_string(flist.value().c_str()));
for (const software_part &part : swinfo.parts())
{
@@ -1112,7 +1107,7 @@ void cli_frontend::output_single_softlist(std::ostream &out, software_list_devic
out << ">\n";
for (const feature_list_item &flist : part.featurelist())
- util::stream_format(out, "\t\t\t\t<feature name=\"%s\" value=\"%s\" />\n", flist.name().c_str(), util::xml::normalize_string(flist.value().c_str()));
+ util::stream_format(out, "\t\t\t\t<feature name=\"%s\" value=\"%s\" />\n", flist.name(), util::xml::normalize_string(flist.value().c_str()));
// TODO: display ROM region information
for (const rom_entry *region = part.romdata().data(); region; region = rom_next_region(region))
@@ -1120,9 +1115,9 @@ void cli_frontend::output_single_softlist(std::ostream &out, software_list_devic
int is_disk = ROMREGION_ISDISKDATA(region);
if (!is_disk)
- util::stream_format(out, "\t\t\t\t<dataarea name=\"%s\" size=\"%d\">\n", util::xml::normalize_string(ROMREGION_GETTAG(region)), ROMREGION_GETLENGTH(region));
+ util::stream_format(out, "\t\t\t\t<dataarea name=\"%s\" size=\"%d\">\n", util::xml::normalize_string(region->name().c_str()), region->get_length());
else
- util::stream_format(out, "\t\t\t\t<diskarea name=\"%s\">\n", util::xml::normalize_string(ROMREGION_GETTAG(region)));
+ util::stream_format(out, "\t\t\t\t<diskarea name=\"%s\">\n", util::xml::normalize_string(region->name().c_str()));
for (const rom_entry *rom = rom_first_file(region); rom && !ROMENTRY_ISREGIONEND(rom); rom++)
{
@@ -1134,7 +1129,7 @@ void cli_frontend::output_single_softlist(std::ostream &out, software_list_devic
util::stream_format(out, "\t\t\t\t\t<disk name=\"%s\"", util::xml::normalize_string(ROM_GETNAME(rom)));
// dump checksum information only if there is a known dump
- util::hash_collection hashes(ROM_GETHASHDATA(rom));
+ util::hash_collection hashes(rom->hashdata());
if (!hashes.flag(util::hash_collection::FLAG_NO_DUMP))
util::stream_format(out, " %s", hashes.attribute_string());
else
@@ -1607,7 +1602,7 @@ const cli_frontend::info_command_struct *cli_frontend::find_command(const std::s
// commands
//-------------------------------------------------
-void cli_frontend::execute_commands(const char *exename)
+void cli_frontend::execute_commands(std::string_view exename)
{
// help?
if (m_options.command() == CLICOMMAND_HELP)
@@ -1726,7 +1721,7 @@ void cli_frontend::execute_commands(const char *exename)
// output
//-------------------------------------------------
-void cli_frontend::display_help(const char *exename)
+void cli_frontend::display_help(std::string_view exename)
{
osd_printf_info(
"%3$s v%2$s\n"