summaryrefslogtreecommitdiffstats
path: root/core/config/boolean.cc
diff options
context:
space:
mode:
authoruntodesu <kirill@untode.su>2025-09-11 13:48:31 +0500
committeruntodesu <kirill@untode.su>2025-09-11 13:48:31 +0500
commitaaed751bf4430bf4b9b30cef532b8753b9f639ce (patch)
tree16bc751c272ba27ad53ec48dbdd3a6d9e6a8d4c2 /core/config/boolean.cc
parent96bd73ae020ecca1f94698744c77498a89ad19f7 (diff)
downloadvoxelius-aaed751bf4430bf4b9b30cef532b8753b9f639ce.tar.bz2
voxelius-aaed751bf4430bf4b9b30cef532b8753b9f639ce.zip
Replace most of C strings with string_view
Diffstat (limited to 'core/config/boolean.cc')
-rw-r--r--core/config/boolean.cc15
1 files changed, 5 insertions, 10 deletions
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";
}