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); 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) 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) // TODO: this could be rewritten without exceptions (but it should be as safe as possible and provide logs)

View file

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