From faf9ed9fec3eff24b313085f6532219ebc6b4f37 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Wed, 2 Aug 2017 13:22:53 +0300 Subject: [PATCH] CFG: provide _int range in to_list() --- Utilities/Config.cpp | 7 ++++++- Utilities/Config.h | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Utilities/Config.cpp b/Utilities/Config.cpp index 8f261c1483..02cefd19c7 100644 --- a/Utilities/Config.cpp +++ b/Utilities/Config.cpp @@ -48,6 +48,11 @@ namespace cfg static void decode(const YAML::Node& data, class _base& rhs); } +std::vector 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) diff --git a/Utilities/Config.h b/Utilities/Config.h index 5937c26676..4cbc88a85f 100644 --- a/Utilities/Config.h +++ b/Utilities/Config.h @@ -12,6 +12,9 @@ namespace cfg { + // Format min and max values + std::vector 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 to_list() const override + { + return make_int_range(Min, Max); + } }; // Alias for 32 bit int