summaryrefslogtreecommitdiffstats
path: root/src/lib/util/corestr.h
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/lib/util/corestr.h
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/lib/util/corestr.h')
-rw-r--r--src/lib/util/corestr.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/lib/util/corestr.h b/src/lib/util/corestr.h
index de294c0665c..81b04eeebaf 100644
--- a/src/lib/util/corestr.h
+++ b/src/lib/util/corestr.h
@@ -14,6 +14,7 @@
#pragma once
#include <string>
+#include <string_view>
#include <cstring>
@@ -53,16 +54,16 @@ bool core_iswildstr(const char *sp);
void strdelchr(std::string& str, char chr);
void strreplacechr(std::string& str, char ch, char newch);
-std::string &strtrimspace(std::string& str);
-std::string &strtrimrightspace(std::string& str);
-std::string &strmakeupper(std::string& str);
-std::string &strmakelower(std::string& str);
+[[nodiscard]] std::string_view strtrimspace(std::string_view str);
+[[nodiscard]] std::string_view strtrimrightspace(std::string_view str);
+[[nodiscard]] std::string strmakeupper(std::string_view str);
+[[nodiscard]] std::string strmakelower(std::string_view str);
int strreplace(std::string &str, const std::string& search, const std::string& replace);
namespace util {
// based on Jaro-Winkler distance - returns value from 0.0 (totally dissimilar) to 1.0 (identical)
-double edit_distance(std::u32string const &lhs, std::u32string const &rhs);
+double edit_distance(std::u32string_view lhs, std::u32string_view rhs);
} // namespace util