mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-24 03:32:50 +01:00
move try_to_int64 to StrUtil
This commit is contained in:
parent
f4bcf9ad1d
commit
2c2003aa5b
@ -58,7 +58,7 @@ std::vector<std::string> cfg::make_int_range(s64 min, s64 max)
|
|||||||
return {std::to_string(min), std::to_string(max)};
|
return {std::to_string(min), std::to_string(max)};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cfg::try_to_int64(s64* out, const std::string& value, s64 min, s64 max)
|
bool try_to_int64(s64* out, const std::string& value, s64 min, s64 max)
|
||||||
{
|
{
|
||||||
s64 result;
|
s64 result;
|
||||||
const char* start = &value.front();
|
const char* start = &value.front();
|
||||||
@ -104,7 +104,7 @@ std::vector<std::string> cfg::make_uint_range(u64 min, u64 max)
|
|||||||
return {std::to_string(min), std::to_string(max)};
|
return {std::to_string(min), std::to_string(max)};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cfg::try_to_uint64(u64* out, const std::string& value, u64 min, u64 max)
|
bool try_to_uint64(u64* out, const std::string& value, u64 min, u64 max)
|
||||||
{
|
{
|
||||||
u64 result;
|
u64 result;
|
||||||
const char* start = &value.front();
|
const char* start = &value.front();
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "util/types.hpp"
|
#include "util/types.hpp"
|
||||||
#include "Utilities/StrFmt.h"
|
#include "Utilities/StrUtil.h"
|
||||||
#include "util/logs.hpp"
|
#include "util/logs.hpp"
|
||||||
#include "util/atomic.hpp"
|
#include "util/atomic.hpp"
|
||||||
#include "util/shared_ptr.hpp"
|
#include "util/shared_ptr.hpp"
|
||||||
@ -17,15 +17,9 @@ namespace cfg
|
|||||||
// Format min and max values
|
// Format min and max values
|
||||||
std::vector<std::string> make_int_range(s64 min, s64 max);
|
std::vector<std::string> make_int_range(s64 min, s64 max);
|
||||||
|
|
||||||
// Convert string to signed integer
|
|
||||||
bool try_to_int64(s64* out, const std::string& value, s64 min, s64 max);
|
|
||||||
|
|
||||||
// Format min and max unsigned values
|
// Format min and max unsigned values
|
||||||
std::vector<std::string> make_uint_range(u64 min, u64 max);
|
std::vector<std::string> make_uint_range(u64 min, u64 max);
|
||||||
|
|
||||||
// Convert string to unsigned integer
|
|
||||||
bool try_to_uint64(u64* out, const std::string& value, u64 min, u64 max);
|
|
||||||
|
|
||||||
// Internal hack
|
// Internal hack
|
||||||
bool try_to_enum_value(u64* out, decltype(&fmt_class_string<int>::format) func, const std::string&);
|
bool try_to_enum_value(u64* out, decltype(&fmt_class_string<int>::format) func, const std::string&);
|
||||||
|
|
||||||
|
@ -21,6 +21,12 @@ inline void strcpy_trunc(D& dst, const T& src)
|
|||||||
std::memset(std::data(dst) + count, 0, std::size(dst) - count);
|
std::memset(std::data(dst) + count, 0, std::size(dst) - count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Convert string to signed integer
|
||||||
|
bool try_to_int64(s64* out, const std::string& value, s64 min, s64 max);
|
||||||
|
|
||||||
|
// Convert string to unsigned integer
|
||||||
|
bool try_to_uint64(u64* out, const std::string& value, u64 min, u64 max);
|
||||||
|
|
||||||
namespace fmt
|
namespace fmt
|
||||||
{
|
{
|
||||||
std::string replace_all(std::string_view src, std::string_view from, std::string_view to, usz count = -1);
|
std::string replace_all(std::string_view src, std::string_view from, std::string_view to, usz count = -1);
|
||||||
|
@ -10,7 +10,7 @@ bool cheat_info::from_str(const std::string& cheat_line)
|
|||||||
auto cheat_vec = fmt::split(cheat_line, {"@@@"}, false);
|
auto cheat_vec = fmt::split(cheat_line, {"@@@"}, false);
|
||||||
|
|
||||||
s64 val64 = 0;
|
s64 val64 = 0;
|
||||||
if (cheat_vec.size() != 5 || !cfg::try_to_int64(&val64, cheat_vec[2], 0, cheat_type_max - 1))
|
if (cheat_vec.size() != 5 || !try_to_int64(&val64, cheat_vec[2], 0, cheat_type_max - 1))
|
||||||
{
|
{
|
||||||
log_cheat.fatal("Failed to parse cheat line");
|
log_cheat.fatal("Failed to parse cheat line");
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user