summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/input.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/emu/input.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/emu/input.cpp')
-rw-r--r--src/emu/input.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/emu/input.cpp b/src/emu/input.cpp
index ffcdaf722be..0cc37abc1c9 100644
--- a/src/emu/input.cpp
+++ b/src/emu/input.cpp
@@ -20,6 +20,8 @@
#include "emu.h"
#include "inputdev.h"
+#include "corestr.h"
+
//**************************************************************************
@@ -46,10 +48,10 @@ const input_seq input_seq::empty_seq;
// simple class to match codes to strings
struct code_string_table
{
- u32 operator[](const char *string) const
+ u32 operator[](std::string_view string) const
{
for (const code_string_table *current = this; current->m_code != ~0; current++)
- if (strcmp(current->m_string, string) == 0)
+ if (current->m_string == string)
return current->m_code;
return ~0;
}
@@ -818,8 +820,7 @@ std::string input_manager::code_name(input_code code) const
str.append(" ").append(modifier);
// delete any leading spaces
- strtrimspace(str);
- return str;
+ return std::string(strtrimspace(str));
}
@@ -887,7 +888,7 @@ input_code input_manager::code_from_token(const char *_token)
// first token should be the devclass
int curtok = 0;
- input_device_class devclass = input_device_class((*devclass_token_table)[token[curtok++].c_str()]);
+ input_device_class devclass = input_device_class((*devclass_token_table)[token[curtok++]]);
if (devclass == ~input_device_class(0))
return INPUT_CODE_INVALID;
@@ -902,7 +903,7 @@ input_code input_manager::code_from_token(const char *_token)
return INPUT_CODE_INVALID;
// next token is the item ID
- input_item_id itemid = input_item_id((*itemid_token_table)[token[curtok].c_str()]);
+ input_item_id itemid = input_item_id((*itemid_token_table)[token[curtok]]);
bool standard = (itemid != ~input_item_id(0));
// if we're a standard code, default the itemclass based on it
@@ -940,7 +941,7 @@ input_code input_manager::code_from_token(const char *_token)
input_item_modifier modifier = ITEM_MODIFIER_NONE;
if (curtok < numtokens)
{
- modifier = input_item_modifier((*modifier_token_table)[token[curtok].c_str()]);
+ modifier = input_item_modifier((*modifier_token_table)[token[curtok]]);
if (modifier != ~input_item_modifier(0))
curtok++;
else
@@ -950,7 +951,7 @@ input_code input_manager::code_from_token(const char *_token)
// if we have another token, it is the item class
if (curtok < numtokens)
{
- u32 temp = (*itemclass_token_table)[token[curtok].c_str()];
+ u32 temp = (*itemclass_token_table)[token[curtok]];
if (temp != ~0)
{
curtok++;
@@ -1340,7 +1341,7 @@ bool input_manager::map_device_to_controller(const devicemap_table_type *devicem
return false;
// first token should be the devclass
- input_device_class devclass = input_device_class((*devclass_token_table)[strmakeupper(token[0]).c_str()]);
+ input_device_class devclass = input_device_class((*devclass_token_table)[strmakeupper(token[0])]);
if (devclass == ~input_device_class(0))
return false;