summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/softlist.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/emu/softlist.cpp')
-rw-r--r--src/emu/softlist.cpp78
1 files changed, 57 insertions, 21 deletions
diff --git a/src/emu/softlist.cpp b/src/emu/softlist.cpp
index 647a2198ed3..62e6feeecaa 100644
--- a/src/emu/softlist.cpp
+++ b/src/emu/softlist.cpp
@@ -21,7 +21,7 @@
// TYPE DEFINITIONS
//**************************************************************************
-typedef std::unordered_map<std::string,software_info *> softlist_map;
+typedef std::unordered_map<std::string,const software_info *> softlist_map;
// ======================> softlist_parser
@@ -95,6 +95,34 @@ const device_type SOFTWARE_LIST = &device_creator<software_list_device>;
//**************************************************************************
+// FEATURE LIST ITEM
+//**************************************************************************
+
+//-------------------------------------------------
+// feature_list_item - constructor
+//-------------------------------------------------
+
+feature_list_item::feature_list_item(const std::string &name, const std::string &value)
+ : m_next(nullptr),
+ m_name(name),
+ m_value(value)
+{
+}
+
+
+//-------------------------------------------------
+// feature_list_item - constructor
+//-------------------------------------------------
+
+feature_list_item::feature_list_item(std::string &&name, std::string &&value)
+ : m_next(nullptr),
+ m_name(std::move(name)),
+ m_value(std::move(value))
+{
+}
+
+
+//**************************************************************************
// SOFTWARE PART
//**************************************************************************
@@ -263,7 +291,7 @@ const software_part *software_info::find_part(const char *partname, const char *
if (partname != nullptr && strlen(partname)==0) partname = nullptr;
if (partname == nullptr && interface == nullptr)
- return m_partdata.first();
+ return &m_partdata.front();
// look for the part by name and match against the interface if provided
for (const software_part &part : m_partdata)
@@ -289,7 +317,7 @@ bool software_info::has_multiple_parts(const char *interface) const
int count = 0;
// increment the count for each match and stop if we hit more than 1
- for (software_part &part : m_partdata)
+ for (const software_part &part : m_partdata)
if (part.matches_interface(interface))
if (++count > 1)
return true;
@@ -374,8 +402,8 @@ void software_list_device::find_approx_matches(const char *name, int matches, co
// iterate over our info (will cause a parse if needed)
for (const software_info &swinfo : get_info())
{
- const software_part *part = swinfo.first_part();
- if ((interface == nullptr || part->matches_interface(interface)) && part->is_compatible(*this) == SOFTWARE_IS_COMPATIBLE)
+ const software_part &part = swinfo.parts().front();
+ if ((interface == nullptr || part.matches_interface(interface)) && part.is_compatible(*this) == SOFTWARE_IS_COMPATIBLE)
{
// pick the best match between driver name and description
int longpenalty = driver_list::penalty_compare(name, swinfo.longname().c_str());
@@ -413,7 +441,7 @@ void software_list_device::release()
m_parsed = false;
m_description.clear();
m_errors.clear();
- m_infolist.reset();
+ m_infolist.clear();
}
@@ -481,7 +509,7 @@ void software_list_device::display_matches(const machine_config &config, const c
// from an intermediate point
//-------------------------------------------------
-const software_info *software_list_device::find(const char *look_for, const software_info *prev)
+const software_info *software_list_device::find(const char *look_for)
{
// nullptr search returns nothing
if (look_for == nullptr)
@@ -490,11 +518,13 @@ const software_info *software_list_device::find(const char *look_for, const soft
bool iswild = strchr(look_for, '*') != nullptr || strchr(look_for, '?');
// find a match (will cause a parse if needed when calling get_info)
- for (prev = (prev != nullptr) ? prev->next() : get_info().first(); prev != nullptr; prev = prev->next())
- if ((iswild && core_strwildcmp(look_for, prev->shortname().c_str()) == 0) || core_stricmp(look_for, prev->shortname().c_str()) == 0)
- break;
+ for (const software_info &info : get_info())
+ {
+ if ((iswild && core_strwildcmp(look_for, info.shortname().c_str()) == 0) || core_stricmp(look_for, info.shortname().c_str()) == 0)
+ return &info;
+ }
- return prev;
+ return nullptr;
}
@@ -561,7 +591,7 @@ void software_list_device::internal_validity_check(validity_checker &valid)
softlist_map names;
softlist_map descriptions;
- for (software_info &swinfo : get_info())
+ for (const software_info &swinfo : get_info())
{
// first parse and output core errors if any
if (m_errors.length() > 0)
@@ -605,7 +635,7 @@ void software_list_device::internal_validity_check(validity_checker &valid)
// check for duplicate names
if (!names.insert(std::make_pair(swinfo.shortname(), &swinfo)).second)
{
- software_info *match = names.find(swinfo.shortname())->second;
+ const software_info *match = names.find(swinfo.shortname())->second;
osd_printf_error("%s: %s is a duplicate name (%s)\n", filename(), swinfo.shortname().c_str(), match->shortname().c_str());
}
@@ -647,7 +677,7 @@ void software_list_device::internal_validity_check(validity_checker &valid)
}
softlist_map part_names;
- for (software_part &part : swinfo.parts())
+ for (const software_part &part : swinfo.parts())
{
if (part.interface().empty())
osd_printf_error("%s: %s has a part (%s) without interface\n", filename(), swinfo.shortname().c_str(), part.name().c_str());
@@ -940,7 +970,10 @@ void softlist_parser::parse_main_start(const char *tagname, const char **attribu
auto attrvalues = parse_attributes(attributes, attrnames);
if (!attrvalues[0].empty())
- m_current_info = &m_list.m_infolist.append(*global_alloc(software_info(m_list, std::move(attrvalues[0]), std::move(attrvalues[1]), attrvalues[2].c_str())));
+ {
+ m_list.m_infolist.emplace_back(m_list, std::move(attrvalues[0]), std::move(attrvalues[1]), attrvalues[2].c_str());
+ m_current_info = &m_list.m_infolist.back();
+ }
else
parse_error("No name defined for item");
}
@@ -982,7 +1015,7 @@ void softlist_parser::parse_soft_start(const char *tagname, const char **attribu
auto attrvalues = parse_attributes(attributes, attrnames);
if (!attrvalues[0].empty() && !attrvalues[1].empty())
- m_current_info->m_other_info.append(*global_alloc(feature_list_item(std::move(attrvalues[0]), std::move(attrvalues[1]))));
+ m_current_info->m_other_info.emplace_back(std::move(attrvalues[0]), std::move(attrvalues[1]));
else
parse_error("Incomplete other_info definition");
}
@@ -994,7 +1027,7 @@ void softlist_parser::parse_soft_start(const char *tagname, const char **attribu
auto attrvalues = parse_attributes(attributes, attrnames);
if (!attrvalues[0].empty() && !attrvalues[1].empty())
- m_current_info->m_shared_info.append(*global_alloc(feature_list_item(std::move(attrvalues[0]), std::move(attrvalues[1]))));
+ m_current_info->m_shared_info.emplace_back(std::move(attrvalues[0]), std::move(attrvalues[1]));
else
parse_error("Incomplete sharedfeat definition");
}
@@ -1006,7 +1039,10 @@ void softlist_parser::parse_soft_start(const char *tagname, const char **attribu
auto attrvalues = parse_attributes(attributes, attrnames);
if (!attrvalues[0].empty() && !attrvalues[1].empty())
- m_current_part = &m_current_info->m_partdata.append(*global_alloc(software_part(*m_current_info, std::move(attrvalues[0]), std::move(attrvalues[1]))));
+ {
+ m_current_info->m_partdata.emplace_back(*m_current_info, std::move(attrvalues[0]), std::move(attrvalues[1]));
+ m_current_part = &m_current_info->m_partdata.back();
+ }
else
parse_error("Incomplete part definition");
}
@@ -1090,7 +1126,7 @@ void softlist_parser::parse_part_start(const char *tagname, const char **attribu
auto attrvalues = parse_attributes(attributes, attrnames);
if (!attrvalues[0].empty())
- m_current_part->m_featurelist.append(*global_alloc(feature_list_item(std::move(attrvalues[0]), std::move(attrvalues[1]))));
+ m_current_part->m_featurelist.emplace_back(std::move(attrvalues[0]), std::move(attrvalues[1]));
else
parse_error("Incomplete feature definition");
}
@@ -1258,7 +1294,7 @@ void softlist_parser::parse_soft_end(const char *tagname)
// get the info; if present, copy shared data (we assume name/value strings live
// in the string pool and don't need to be reallocated)
if (m_current_info != nullptr)
- for (feature_list_item &item : m_current_info->shared_info())
- m_current_part->m_featurelist.append(*global_alloc(feature_list_item(item.name(), item.value())));
+ for (const feature_list_item &item : m_current_info->shared_info())
+ m_current_part->m_featurelist.emplace_back(item.name(), item.value());
}
}