From 88c01588aa0830e219eaa62588839e4d1e2883ce Mon Sep 17 00:00:00 2001 From: untodesu Date: Wed, 25 Jun 2025 00:44:36 +0500 Subject: Clang-format the entire source code --- core/cmdline.cc | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'core/cmdline.cc') diff --git a/core/cmdline.cc b/core/cmdline.cc index 4cc7de0..c83f9e6 100644 --- a/core/cmdline.cc +++ b/core/cmdline.cc @@ -1,4 +1,5 @@ #include "core/pch.hh" + #include "core/cmdline.hh" // Valid options always start with OPTION_PREFIX, can contain @@ -7,21 +8,24 @@ constexpr static char OPTION_PREFIX = '-'; static std::unordered_map options; -static inline bool is_option_string(const std::string &string) +static inline bool is_option_string(const std::string& string) { - if(string.find_last_of(OPTION_PREFIX) >= (string.size() - 1)) + if(string.find_last_of(OPTION_PREFIX) >= (string.size() - 1)) { return false; + } + return string[0] == OPTION_PREFIX; } -static inline std::string get_option(const std::string &string) +static inline std::string get_option(const std::string& string) { std::size_t i; - for(i = 0; string[i] == OPTION_PREFIX; ++i); + for(i = 0; string[i] == OPTION_PREFIX; ++i) + ; return std::string(string.cbegin() + i, string.cend()); } -void cmdline::create(int argc, char **argv) +void cmdline::create(int argc, char** argv) { for(int idx = 1; idx < argc; ++idx) { std::string string = argv[idx]; @@ -51,22 +55,27 @@ void cmdline::create(int argc, char **argv) } } -void cmdline::insert(const char *option, const char *argument) +void cmdline::insert(const char* option, const char* argument) { - if(argument == nullptr) + if(argument == nullptr) { options.insert_or_assign(option, std::string()); - else options.insert_or_assign(option, argument); + } else { + options.insert_or_assign(option, argument); + } } -const char *cmdline::get(const char *option, const char *fallback) +const char* cmdline::get(const char* option, const char* fallback) { auto it = options.find(option); - if(it == options.cend()) + + if(it == options.cend()) { return fallback; + } + return it->second.c_str(); } -bool cmdline::contains(const char *option) +bool cmdline::contains(const char* option) { return options.count(option); } -- cgit