mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Use sv literal suffixes for most string_view literals
They're not in scope by default when using MSVC so using them in header files is problematic.
This commit is contained in:
@@ -50,6 +50,7 @@
|
||||
using std::filesystem::u8path;
|
||||
|
||||
namespace {
|
||||
using std::string_view_literals::operator""sv;
|
||||
using loot::GameType;
|
||||
|
||||
// The Microsoft Store installs Fallout 4 DLCs to directories outside of the
|
||||
@@ -57,19 +58,19 @@ using loot::GameType;
|
||||
// game install path (renaming them causes the game launch to fail, or not
|
||||
// find the DLC files).
|
||||
constexpr std::string_view MS_FO4_AUTOMATRON_DATA_PATH =
|
||||
"../../Fallout 4- Automatron (PC)/Content/Data";
|
||||
"../../Fallout 4- Automatron (PC)/Content/Data"sv;
|
||||
constexpr std::string_view MS_FO4_CONTRAPTIONS_DATA_PATH =
|
||||
"../../Fallout 4- Contraptions Workshop (PC)/Content/Data";
|
||||
"../../Fallout 4- Contraptions Workshop (PC)/Content/Data"sv;
|
||||
constexpr std::string_view MS_FO4_FAR_HARBOR_DATA_PATH =
|
||||
"../../Fallout 4- Far Harbor (PC)/Content/Data";
|
||||
"../../Fallout 4- Far Harbor (PC)/Content/Data"sv;
|
||||
constexpr std::string_view MS_FO4_TEXTURE_PACK_DATA_PATH =
|
||||
"../../Fallout 4- High Resolution Texture Pack/Content/Data";
|
||||
"../../Fallout 4- High Resolution Texture Pack/Content/Data"sv;
|
||||
constexpr std::string_view MS_FO4_NUKA_WORLD_DATA_PATH =
|
||||
"../../Fallout 4- Nuka-World (PC)/Content/Data";
|
||||
"../../Fallout 4- Nuka-World (PC)/Content/Data"sv;
|
||||
constexpr std::string_view MS_FO4_VAULT_TEC_DATA_PATH =
|
||||
"../../Fallout 4- Vault-Tec Workshop (PC)/Content/Data";
|
||||
"../../Fallout 4- Vault-Tec Workshop (PC)/Content/Data"sv;
|
||||
constexpr std::string_view MS_FO4_WASTELAND_DATA_PATH =
|
||||
"../../Fallout 4- Wasteland Workshop (PC)/Content/Data";
|
||||
"../../Fallout 4- Wasteland Workshop (PC)/Content/Data"sv;
|
||||
|
||||
bool IsMicrosoftStoreInstall(const GameType gameType,
|
||||
const std::filesystem::path& gamePath) {
|
||||
|
||||
@@ -29,9 +29,10 @@
|
||||
#include <spdlog/sinks/base_sink.h>
|
||||
|
||||
namespace {
|
||||
using std::string_view_literals::operator""sv;
|
||||
using loot::LogLevel;
|
||||
|
||||
constexpr std::string_view LOGGER_NAME = "loot_api_logger";
|
||||
constexpr std::string_view LOGGER_NAME = "loot_api_logger"sv;
|
||||
|
||||
LogLevel mapFromSpdlog(spdlog::level::level_enum severity) {
|
||||
using spdlog::level::level_enum;
|
||||
|
||||
@@ -34,31 +34,33 @@
|
||||
#endif
|
||||
|
||||
namespace loot {
|
||||
using std::string_view_literals::operator""sv;
|
||||
|
||||
/* The string below matches timestamps that use forwardslashes for date
|
||||
separators. However, Pseudosem v1.0.1 will only compare the first
|
||||
two digits as it does not recognise forwardslashes as separators. */
|
||||
constexpr std::string_view dateRegex =
|
||||
R"((\d{1,2}/\d{1,2}/\d{1,4} \d{1,2}:\d{1,2}:\d{1,2}))";
|
||||
R"((\d{1,2}/\d{1,2}/\d{1,4} \d{1,2}:\d{1,2}:\d{1,2}))"sv;
|
||||
|
||||
/* The string below matches the range of version strings supported by
|
||||
Pseudosem v1.0.1, excluding space separators, as they make version
|
||||
extraction from inside sentences very tricky and have not been
|
||||
seen "in the wild". */
|
||||
constexpr std::string_view pseudosemVersionRegex =
|
||||
R"((\d+(?:\.\d+)+(?:[-._:]?[A-Za-z0-9]+)*))"
|
||||
R"((\d+(?:\.\d+)+(?:[-._:]?[A-Za-z0-9]+)*))"sv
|
||||
// The string below prevents version numbers followed by a comma from
|
||||
// matching.
|
||||
R"((?!,))";
|
||||
R"((?!,))"sv;
|
||||
|
||||
/* The string below matches a number containing one or more
|
||||
digits found at the start of the search string or preceded by
|
||||
'v' or 'version:. */
|
||||
constexpr std::string_view digitsVersionRegex = R"((?:^|v|version:\s*)(\d+))";
|
||||
constexpr std::string_view digitsVersionRegex = R"((?:^|v|version:\s*)(\d+))"sv;
|
||||
|
||||
std::vector<Tag> ExtractBashTags(std::string_view description) {
|
||||
std::vector<Tag> tags;
|
||||
|
||||
static constexpr std::string_view BASH_TAGS_OPENER = "{{BASH:";
|
||||
static constexpr std::string_view BASH_TAGS_OPENER = "{{BASH:"sv;
|
||||
|
||||
size_t startPos = description.find("{{BASH:");
|
||||
if (startPos == std::string::npos ||
|
||||
|
||||
@@ -38,8 +38,10 @@
|
||||
#include "loot/exception/file_access_error.h"
|
||||
|
||||
namespace loot {
|
||||
constexpr std::string_view PRELUDE_ON_FIRST_LINE = "prelude:";
|
||||
constexpr std::string_view PRELUDE_ON_NEW_LINE = "\nprelude:";
|
||||
using std::string_view_literals::operator""sv;
|
||||
|
||||
constexpr std::string_view PRELUDE_ON_FIRST_LINE = "prelude:"sv;
|
||||
constexpr std::string_view PRELUDE_ON_NEW_LINE = "\nprelude:"sv;
|
||||
|
||||
std::string read_to_string(const std::filesystem::path& filePath) {
|
||||
std::ifstream in(filePath);
|
||||
|
||||
Reference in New Issue
Block a user