summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/util/options.cpp
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2016-03-31 09:43:53 -0400
committer AJR <ajrhacker@users.noreply.github.com>2016-03-31 09:43:53 -0400
commita7e393b36b57cead61978f332135a509b2ddc82a (patch)
tree4d0d9a4b83d394e8706bd0475f379b5f468c43b1 /src/lib/util/options.cpp
parent677cfa86fd8675dd15cc6cde0e26fd216823c61b (diff)
Iterate over core classes C++11 style
C++11 range-based for loops can now iterate over simple_list, tagged_list, core_options, device_t::subdevice_list, device_t::interface_list, render_primitive_list and all subclasses of the above, and much code has been refactored to use them. Most core classes that have these lists as members now have methods that return the lists themselves, replacing most of the methods that returned the object at an owned list's head. (A few have been retained due to their use in drivers or OSD.) device_t now manages subdevice and interface lists through subclasses, but has given up the work of adding and removing subdevices to machine_config. memory_manager has its tagged lists exposed, though the old rooted tag lookup methods have been removed (they were privatized already).
Diffstat (limited to 'src/lib/util/options.cpp')
-rw-r--r--src/lib/util/options.cpp38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/lib/util/options.cpp b/src/lib/util/options.cpp
index 9890ae46115..7e8b993c0b2 100644
--- a/src/lib/util/options.cpp
+++ b/src/lib/util/options.cpp
@@ -226,11 +226,11 @@ core_options &core_options::operator=(const core_options &rhs)
bool core_options::operator==(const core_options &rhs)
{
// iterate over options in the first list
- for (entry *curentry = m_entrylist.first(); curentry != nullptr; curentry = curentry->next())
- if (!curentry->is_header())
+ for (entry &curentry : m_entrylist)
+ if (!curentry.is_header())
{
// if the values differ, return false
- if (strcmp(curentry->value(), rhs.value(curentry->name())) != 0)
+ if (strcmp(curentry.value(), rhs.value(curentry.name())) != 0)
return false;
}
@@ -468,8 +468,8 @@ bool core_options::parse_ini_file(util::core_file &inifile, int priority, int ig
void core_options::revert(int priority)
{
// iterate over options and revert to defaults if below the given priority
- for (entry *curentry = m_entrylist.first(); curentry != nullptr; curentry = curentry->next())
- curentry->revert(priority);
+ for (entry &curentry : m_entrylist)
+ curentry.revert(priority);
}
@@ -489,10 +489,10 @@ std::string core_options::output_ini(const core_options *diff) const
const char *last_header = nullptr;
// loop over all items
- for (entry *curentry = m_entrylist.first(); curentry != nullptr; curentry = curentry->next())
+ for (entry &curentry : m_entrylist)
{
- const char *name = curentry->name();
- const char *value = curentry->value();
+ const char *name = curentry.name();
+ const char *value = curentry.value();
bool is_unadorned = false;
// check if it's unadorned
@@ -503,13 +503,13 @@ std::string core_options::output_ini(const core_options *diff) const
}
// header: record description
- if (curentry->is_header())
- last_header = curentry->description();
+ if (curentry.is_header())
+ last_header = curentry.description();
// otherwise, output entries for all non-command items
- else if (!curentry->is_command())
+ else if (!curentry.is_command())
{
- if ( !curentry->is_internal() )
+ if (!curentry.is_internal())
{
// look up counterpart in diff, if diff is specified
if (diff == nullptr || strcmp(value, diff->value(name)) != 0)
@@ -549,15 +549,15 @@ std::string core_options::output_help() const
std::ostringstream buffer;
// loop over all items
- for (entry *curentry = m_entrylist.first(); curentry != nullptr; curentry = curentry->next())
+ for (entry &curentry : m_entrylist)
{
// header: just print
- if (curentry->is_header())
- util::stream_format(buffer, "\n#\n# %s\n#\n", curentry->description());
+ if (curentry.is_header())
+ util::stream_format(buffer, "\n#\n# %s\n#\n", curentry.description());
// otherwise, output entries for all non-deprecated items
- else if (curentry->description() != nullptr)
- util::stream_format(buffer, "-%-20s%s\n", curentry->name(), curentry->description());
+ else if (curentry.description() != nullptr)
+ util::stream_format(buffer, "-%-20s%s\n", curentry.name(), curentry.description());
}
return buffer.str();
}
@@ -744,8 +744,8 @@ void core_options::copyfrom(const core_options &src)
reset();
// iterate through the src options and make our own
- for (entry *curentry = src.m_entrylist.first(); curentry != nullptr; curentry = curentry->next())
- append_entry(*global_alloc(entry(curentry->name(), curentry->description(), curentry->flags(), curentry->default_value())));
+ for (entry &curentry : src.m_entrylist)
+ append_entry(*global_alloc(entry(curentry.name(), curentry.description(), curentry.flags(), curentry.default_value())));
}
/**