Merge pull request #1214 from npwoods/more_diimage_softlist_stdstring_stuff
More softlist-related conversions of strings to std::string
This commit is contained in:
commit
61579a4f16
@ -1038,7 +1038,7 @@ image_init_result device_image_interface::load_software(const std::string &softl
|
||||
|
||||
// Check if there's a software list defined for this device and use that if we're not creating an image
|
||||
std::string list_name;
|
||||
bool softload = load_software_part(softlist_name.c_str(), m_software_part_ptr, &list_name);
|
||||
bool softload = load_software_part(softlist_name, m_software_part_ptr, &list_name);
|
||||
if (!softload)
|
||||
{
|
||||
m_is_loading = false;
|
||||
@ -1272,7 +1272,7 @@ void device_image_interface::update_names(const device_type device_type, const c
|
||||
// case.
|
||||
//-------------------------------------------------
|
||||
|
||||
void device_image_interface::software_name_split(const char *swlist_swname, std::string &swlist_name, std::string &swname, std::string &swpart)
|
||||
void device_image_interface::software_name_split(const std::string &swlist_swname, std::string &swlist_name, std::string &swname, std::string &swpart)
|
||||
{
|
||||
// reset all output parameters
|
||||
swlist_name.clear();
|
||||
@ -1280,26 +1280,26 @@ void device_image_interface::software_name_split(const char *swlist_swname, std:
|
||||
swpart.clear();
|
||||
|
||||
// if no colon, this is the swname by itself
|
||||
const char *split1 = strchr(swlist_swname, ':');
|
||||
if (split1 == nullptr)
|
||||
auto split1 = swlist_swname.find_first_of(':');
|
||||
if (split1 == std::string::npos)
|
||||
{
|
||||
swname.assign(swlist_swname);
|
||||
swname = swlist_swname;
|
||||
return;
|
||||
}
|
||||
|
||||
// if one colon, it is the swname and swpart alone
|
||||
const char *split2 = strchr(split1 + 1, ':');
|
||||
if (split2 == nullptr)
|
||||
auto split2 = swlist_swname.find_first_of(':', split1 + 1);
|
||||
if (split2 == std::string::npos)
|
||||
{
|
||||
swname.assign(swlist_swname, split1 - swlist_swname);
|
||||
swpart.assign(split1 + 1);
|
||||
swname = swlist_swname.substr(0, split1);
|
||||
swpart = swlist_swname.substr(split1 + 1);
|
||||
return;
|
||||
}
|
||||
|
||||
// if two colons present, split into 3 parts
|
||||
swlist_name.assign(swlist_swname, split1 - swlist_swname);
|
||||
swname.assign(split1 + 1, split2 - (split1 + 1));
|
||||
swpart.assign(split2 + 1);
|
||||
swlist_name = swlist_swname.substr(0, split1);
|
||||
swname = swlist_swname.substr(split1 + 1, split2 - (split1 + 1));
|
||||
swpart = swlist_swname.substr(split2 + 1);
|
||||
}
|
||||
|
||||
|
||||
@ -1307,7 +1307,7 @@ void device_image_interface::software_name_split(const char *swlist_swname, std:
|
||||
// find_software_item
|
||||
//-------------------------------------------------
|
||||
|
||||
const software_part *device_image_interface::find_software_item(const char *path, bool restrict_to_interface, software_list_device **dev) const
|
||||
const software_part *device_image_interface::find_software_item(const std::string &path, bool restrict_to_interface, software_list_device **dev) const
|
||||
{
|
||||
// split full software name into software list name and short software name
|
||||
std::string swlist_name, swinfo_name, swpart_name;
|
||||
@ -1386,7 +1386,7 @@ const software_list_loader &device_image_interface::get_software_list_loader() c
|
||||
// sw_info and sw_part are also set.
|
||||
//-------------------------------------------------
|
||||
|
||||
bool device_image_interface::load_software_part(const char *path, const software_part *&swpart, std::string *list_name)
|
||||
bool device_image_interface::load_software_part(const std::string &path, const software_part *&swpart, std::string *list_name)
|
||||
{
|
||||
// if no match has been found, we suggest similar shortnames
|
||||
software_list_device *swlist;
|
||||
|
@ -239,7 +239,7 @@ public:
|
||||
bool load_software(software_list_device &swlist, const char *swname, const rom_entry *entry);
|
||||
int reopen_for_write(const std::string &path);
|
||||
|
||||
static void software_name_split(const char *swlist_swname, std::string &swlist_name, std::string &swname, std::string &swpart);
|
||||
static void software_name_split(const std::string &swlist_swname, std::string &swlist_name, std::string &swname, std::string &swpart);
|
||||
static void static_set_user_loadable(device_t &device, bool user_loadable) {
|
||||
device_image_interface *img;
|
||||
if (!device.interface(img))
|
||||
@ -272,8 +272,8 @@ protected:
|
||||
void image_checkhash();
|
||||
void update_names(const device_type device_type = nullptr, const char *inst = nullptr, const char *brief = nullptr);
|
||||
|
||||
const software_part *find_software_item(const char *path, bool restrict_to_interface, software_list_device **device = nullptr) const;
|
||||
bool load_software_part(const char *path, const software_part *&swpart, std::string *list_name = nullptr);
|
||||
const software_part *find_software_item(const std::string &path, bool restrict_to_interface, software_list_device **device = nullptr) const;
|
||||
bool load_software_part(const std::string &path, const software_part *&swpart, std::string *list_name = nullptr);
|
||||
std::string software_get_default_slot(const char *default_card_slot) const;
|
||||
|
||||
void add_format(std::unique_ptr<image_device_format> &&format);
|
||||
|
@ -128,10 +128,10 @@ void software_list_device::device_start()
|
||||
// and optional interface
|
||||
//-------------------------------------------------
|
||||
|
||||
void software_list_device::find_approx_matches(const char *name, int matches, const software_info **list, const char *interface)
|
||||
void software_list_device::find_approx_matches(const std::string &name, int matches, const software_info **list, const char *interface)
|
||||
{
|
||||
// if no name, return
|
||||
if (name == nullptr || name[0] == 0)
|
||||
if (name.empty())
|
||||
return;
|
||||
|
||||
// initialize everyone's states
|
||||
@ -149,8 +149,8 @@ void software_list_device::find_approx_matches(const char *name, int matches, co
|
||||
if ((interface == nullptr || part.matches_interface(interface)) && is_compatible(part) == SOFTWARE_IS_COMPATIBLE)
|
||||
{
|
||||
// pick the best match between driver name and description
|
||||
int longpenalty = driver_list::penalty_compare(name, swinfo.longname().c_str());
|
||||
int shortpenalty = driver_list::penalty_compare(name, swinfo.shortname().c_str());
|
||||
int longpenalty = driver_list::penalty_compare(name.c_str(), swinfo.longname().c_str());
|
||||
int shortpenalty = driver_list::penalty_compare(name.c_str(), swinfo.shortname().c_str());
|
||||
int curpenalty = std::min(longpenalty, shortpenalty);
|
||||
|
||||
// insert into the sorted table of matches
|
||||
@ -209,13 +209,13 @@ software_list_device *software_list_device::find_by_name(const machine_config &c
|
||||
// name, across all software list devices
|
||||
//-------------------------------------------------
|
||||
|
||||
void software_list_device::display_matches(const machine_config &config, const char *interface, const char *name)
|
||||
void software_list_device::display_matches(const machine_config &config, const char *interface, const std::string &name)
|
||||
{
|
||||
// check if there is at least one software list
|
||||
software_list_device_iterator deviter(config.root_device());
|
||||
if (deviter.first() != nullptr)
|
||||
osd_printf_error("\n\"%s\" approximately matches the following\n"
|
||||
"supported software items (best match first):\n\n", name);
|
||||
"supported software items (best match first):\n\n", name.c_str());
|
||||
|
||||
// iterate through lists
|
||||
for (software_list_device &swlistdev : deviter)
|
||||
|
@ -152,13 +152,13 @@ public:
|
||||
|
||||
// operations
|
||||
const software_info *find(const char *look_for);
|
||||
void find_approx_matches(const char *name, int matches, const software_info **list, const char *interface);
|
||||
void find_approx_matches(const std::string &name, int matches, const software_info **list, const char *interface);
|
||||
void release();
|
||||
software_compatibility is_compatible(const software_part &part) const;
|
||||
|
||||
// static helpers
|
||||
static software_list_device *find_by_name(const machine_config &mconfig, const std::string &name);
|
||||
static void display_matches(const machine_config &config, const char *interface, const char *name);
|
||||
static void display_matches(const machine_config &config, const char *interface, const std::string &name);
|
||||
static device_image_interface *find_mountable_image(const machine_config &mconfig, const software_part &part);
|
||||
|
||||
protected:
|
||||
|
Loading…
Reference in New Issue
Block a user