From aaed751bf4430bf4b9b30cef532b8753b9f639ce Mon Sep 17 00:00:00 2001 From: untodesu Date: Thu, 11 Sep 2025 13:48:31 +0500 Subject: Replace most of C strings with string_view --- core/config/boolean.cc | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'core/config/boolean.cc') diff --git a/core/config/boolean.cc b/core/config/boolean.cc index 6363271..45d5a38 100644 --- a/core/config/boolean.cc +++ b/core/config/boolean.cc @@ -7,12 +7,12 @@ config::Boolean::Boolean(bool default_value) m_value = default_value; } -void config::Boolean::set(const char* value) +void config::Boolean::set(std::string_view value) { m_value = from_string(value); } -const char* config::Boolean::get(void) const +std::string_view config::Boolean::get(void) const { return to_string(m_value); } @@ -27,7 +27,7 @@ void config::Boolean::set_value(bool value) m_value = value; } -const char* config::Boolean::to_string(bool value) +std::string_view config::Boolean::to_string(bool value) { if(value) { return "true"; @@ -37,12 +37,7 @@ const char* config::Boolean::to_string(bool value) } } -bool config::Boolean::from_string(const char* value) +bool config::Boolean::from_string(std::string_view value) { - if(std::strcmp(value, "false") && !std::strcmp(value, "true")) { - return true; - } - else { - return false; - } + return value == "true" && value != "false"; } -- cgit