mirror of
https://github.com/holub/mame
synced 2025-05-11 08:38:47 +03:00
Merge pull request #2242 from npwoods/prune_options_cruft
Pruned out some cruft in src/lib/util/options.[cpp|h]
This commit is contained in:
commit
bf3d4f0f06
@ -202,7 +202,7 @@ void cli_frontend::start_execution(mame_machine_manager *manager, std::vector<st
|
||||
if (!mame_options::parse_command_line(m_options, args, option_errors))
|
||||
{
|
||||
// if we failed, check for no command and a system name first; in that case error on the name
|
||||
if (*(m_options.command()) == 0 && mame_options::system(m_options) == nullptr && *(m_options.system_name()) != 0)
|
||||
if (m_options.command().empty() && mame_options::system(m_options) == nullptr && *(m_options.system_name()) != 0)
|
||||
throw emu_fatalerror(EMU_ERR_NO_SUCH_GAME, "Unknown system '%s'", m_options.system_name());
|
||||
|
||||
// otherwise, error on the options
|
||||
@ -215,7 +215,7 @@ void cli_frontend::start_execution(mame_machine_manager *manager, std::vector<st
|
||||
std::string exename = core_filename_extract_base(args[0], true);
|
||||
|
||||
// if we have a command, execute that
|
||||
if (*(m_options.command()) != 0)
|
||||
if (!m_options.command().empty())
|
||||
{
|
||||
execute_commands(exename.c_str());
|
||||
return;
|
||||
@ -1329,14 +1329,14 @@ void cli_frontend::romident(const char *filename)
|
||||
void cli_frontend::execute_commands(const char *exename)
|
||||
{
|
||||
// help?
|
||||
if (strcmp(m_options.command(), CLICOMMAND_HELP) == 0)
|
||||
if (m_options.command() == CLICOMMAND_HELP)
|
||||
{
|
||||
display_help(exename);
|
||||
return;
|
||||
}
|
||||
|
||||
// showusage?
|
||||
if (strcmp(m_options.command(), CLICOMMAND_SHOWUSAGE) == 0)
|
||||
if (m_options.command() == CLICOMMAND_SHOWUSAGE)
|
||||
{
|
||||
osd_printf_info("Usage: %s [machine] [media] [software] [options]",exename);
|
||||
osd_printf_info("\n\nOptions:\n%s", m_options.output_help().c_str());
|
||||
@ -1344,7 +1344,7 @@ void cli_frontend::execute_commands(const char *exename)
|
||||
}
|
||||
|
||||
// validate?
|
||||
if (strcmp(m_options.command(), CLICOMMAND_VALIDATE) == 0)
|
||||
if (m_options.command() == CLICOMMAND_VALIDATE)
|
||||
{
|
||||
validity_checker valid(m_options);
|
||||
valid.set_validate_all(true);
|
||||
@ -1362,7 +1362,7 @@ void cli_frontend::execute_commands(const char *exename)
|
||||
osd_printf_error("%s\n", option_errors.c_str());
|
||||
|
||||
// createconfig?
|
||||
if (strcmp(m_options.command(), CLICOMMAND_CREATECONFIG) == 0)
|
||||
if (m_options.command() == CLICOMMAND_CREATECONFIG)
|
||||
{
|
||||
// attempt to open the output file
|
||||
emu_file file(OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
|
||||
@ -1398,7 +1398,7 @@ void cli_frontend::execute_commands(const char *exename)
|
||||
}
|
||||
|
||||
// showconfig?
|
||||
if (strcmp(m_options.command(), CLICOMMAND_SHOWCONFIG) == 0)
|
||||
if (m_options.command() == CLICOMMAND_SHOWCONFIG)
|
||||
{
|
||||
// print the INI text
|
||||
printf("%s\n", m_options.output_ini().c_str());
|
||||
@ -1435,7 +1435,7 @@ void cli_frontend::execute_commands(const char *exename)
|
||||
// find the command
|
||||
for (auto & info_command : info_commands)
|
||||
{
|
||||
if (strcmp(m_options.command(), info_command.option) == 0)
|
||||
if (m_options.command() == info_command.option)
|
||||
{
|
||||
// parse any relevant INI files before proceeding
|
||||
const char *sysname = m_options.system_name();
|
||||
@ -1444,9 +1444,9 @@ void cli_frontend::execute_commands(const char *exename)
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_osd.execute_command(m_options.command()))
|
||||
if (!m_osd.execute_command(m_options.command().c_str()))
|
||||
// if we get here, we don't know what has been requested
|
||||
throw emu_fatalerror(EMU_ERR_INVALID_CONFIG, "Unknown command '%s' specified", m_options.command());
|
||||
throw emu_fatalerror(EMU_ERR_INVALID_CONFIG, "Unknown command '%s' specified", m_options.command().c_str());
|
||||
}
|
||||
|
||||
|
||||
|
@ -56,7 +56,6 @@ const char *const core_options::s_option_unadorned[MAX_UNADORNED_OPTIONS] =
|
||||
core_options::entry::entry(const char *name, const char *description, uint32_t flags, const char *defvalue)
|
||||
: m_next(nullptr),
|
||||
m_flags(flags),
|
||||
m_seqid(0),
|
||||
m_error_reported(false),
|
||||
m_priority(OPTION_PRIORITY_DEFAULT),
|
||||
m_description(description),
|
||||
@ -111,7 +110,6 @@ void core_options::entry::set_value(const char *newdata, int priority)
|
||||
// set the data and priority, then bump the sequence
|
||||
m_data = newdata;
|
||||
m_priority = priority;
|
||||
m_seqid++;
|
||||
}
|
||||
|
||||
|
||||
@ -683,16 +681,6 @@ int core_options::priority(const char *name) const
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// seqid - return the seqid for a given option
|
||||
//-------------------------------------------------
|
||||
|
||||
uint32_t core_options::seqid(const char *name) const
|
||||
{
|
||||
auto curentry = m_entrymap.find(name);
|
||||
return (curentry != m_entrymap.end()) ? curentry->second->seqid() : 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// exists - return if option exists in list
|
||||
//-------------------------------------------------
|
||||
@ -702,16 +690,7 @@ bool core_options::exists(const char *name) const
|
||||
return (m_entrymap.find(name) != m_entrymap.end());
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// is_changed - return if option have been marked
|
||||
// changed
|
||||
//-------------------------------------------------
|
||||
|
||||
bool core_options::is_changed(const char *name) const
|
||||
{
|
||||
auto curentry = m_entrymap.find(name);
|
||||
return (curentry != m_entrymap.end()) ? curentry->second->is_changed() : false;
|
||||
}
|
||||
//-------------------------------------------------
|
||||
// set_value - set the raw option value
|
||||
//-------------------------------------------------
|
||||
|
@ -8,8 +8,8 @@
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef __OPTIONS_H__
|
||||
#define __OPTIONS_H__
|
||||
#ifndef MAME_LIB_UTIL_OPTIONS_H
|
||||
#define MAME_LIB_UTIL_OPTIONS_H
|
||||
|
||||
#include "corefile.h"
|
||||
#include <unordered_map>
|
||||
@ -81,7 +81,6 @@ public:
|
||||
const char *default_value() const { return m_defdata.c_str(); }
|
||||
const char *minimum() const { return m_minimum.c_str(); }
|
||||
const char *maximum() const { return m_maximum.c_str(); }
|
||||
uint32_t seqid() const { return m_seqid; }
|
||||
int type() const { return (m_flags & OPTION_TYPE_MASK); }
|
||||
uint32_t flags() const { return m_flags; }
|
||||
bool is_header() const { return type() == OPTION_HEADER; }
|
||||
@ -103,7 +102,6 @@ public:
|
||||
// internal state
|
||||
entry * m_next; // link to the next data
|
||||
uint32_t m_flags; // flags from the entry
|
||||
uint32_t m_seqid; // sequence ID; bumped on each change
|
||||
bool m_error_reported; // have we reported an error on this option yet?
|
||||
int m_priority; // priority of the data set
|
||||
const char * m_description; // description for this item
|
||||
@ -130,7 +128,7 @@ public:
|
||||
|
||||
// getters
|
||||
entry *first() const { return m_entrylist.first(); }
|
||||
const char *command() const { return m_command.c_str(); }
|
||||
const std::string &command() const { return m_command; }
|
||||
entry *get_entry(const char *name) const;
|
||||
|
||||
// range iterators
|
||||
@ -165,9 +163,7 @@ public:
|
||||
bool bool_value(const char *name) const { return (atoi(value(name)) != 0); }
|
||||
int int_value(const char *name) const { return atoi(value(name)); }
|
||||
float float_value(const char *name) const { return atof(value(name)); }
|
||||
uint32_t seqid(const char *name) const;
|
||||
bool exists(const char *name) const;
|
||||
bool is_changed(const char *name) const;
|
||||
|
||||
// setting
|
||||
bool set_value(const char *name, const char *value, int priority, std::string &error_string);
|
||||
@ -210,4 +206,4 @@ private:
|
||||
|
||||
|
||||
|
||||
#endif /* __OPTIONS_H__ */
|
||||
#endif // MAME_LIB_UTIL_OPTIONS_H
|
||||
|
Loading…
Reference in New Issue
Block a user