1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 02:32:36 +01:00

CFG: provide _int range in to_list()

This commit is contained in:
Nekotekina 2017-08-02 13:22:53 +03:00
parent 930ce4af60
commit faf9ed9fec
2 changed files with 14 additions and 1 deletions

View File

@ -48,6 +48,11 @@ namespace cfg
static void decode(const YAML::Node& data, class _base& rhs);
}
std::vector<std::string> cfg::make_int_range(s64 min, s64 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)
{
// TODO: this could be rewritten without exceptions (but it should be as safe as possible and provide logs)
@ -268,7 +273,7 @@ std::string cfg::node::to_string() const
YAML::Emitter out;
cfg::encode(out, *this);
return{ out.c_str(), out.size() };
return {out.c_str(), out.size()};
}
bool cfg::node::from_string(const std::string& value)

View File

@ -12,6 +12,9 @@
namespace cfg
{
// Format min and max values
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);
@ -249,6 +252,11 @@ namespace cfg
return false;
}
std::vector<std::string> to_list() const override
{
return make_int_range(Min, Max);
}
};
// Alias for 32 bit int