diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-18 19:38:22 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-18 19:38:22 +0100 |
| commit | f651858b579138d5df0f89363879825513ece227 (patch) | |
| tree | 7f9fc7f18d7948e4c969b3901e9ca6559f4941d9 /tools | |
| parent | ed6d2f6007b572b907e3cb11b4303c13d1572c9c (diff) | |
chore: MKFS library improvements on documentation.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/libmkfs/mkfs.h | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/tools/libmkfs/mkfs.h b/tools/libmkfs/mkfs.h index e3ce19b5..787f93a1 100644 --- a/tools/libmkfs/mkfs.h +++ b/tools/libmkfs/mkfs.h @@ -23,7 +23,8 @@ namespace detail { return static_cast<size_t>(gb) * 1024ULL * 1024ULL * 1024ULL; } - inline bool parse_decimal(const std::string& opt, unsigned long long& out) { + /// \brief Parse decimal parameter. + inline bool parse_decimal(const std::string& opt, long& out) { if (opt.empty()) return false; char* endptr = nullptr; unsigned long long val = std::strtoull(opt.c_str(), &endptr, 10); @@ -32,7 +33,8 @@ namespace detail { return true; } - inline bool parse_signed(const std::string& opt, long& out, int base = 10) { + /// \brief Parse decimal with numerical base. + inline bool parse_signed(const std::string& opt, long& out, const int& base = 10) { out = 0L; if (opt.empty()) return true; @@ -48,6 +50,7 @@ namespace detail { return true; } + /// \brief Helper to build arguments for filesystem tooling. inline std::string build_args(int argc, char** argv) { std::string combined; for (int i = 1; i < argc; ++i) { @@ -59,7 +62,7 @@ namespace detail { } // namespace detail /// @brief Helper function to get the option value from command line arguments. -template <typename CharType> +template <typename CharType = char> inline std::basic_string<CharType> get_option(const std::basic_string<CharType>& args, const std::basic_string<CharType>& option) { size_t pos = args.find(CharType('-') + option + CharType('=')); @@ -67,10 +70,15 @@ inline std::basic_string<CharType> get_option(const std::basic_string<CharType>& if (pos != std::string::npos) { size_t start = pos + option.length() + 2; size_t end = args.find(' ', start); + + if (end == std::string::npos) { + return {}; + } + return args.substr(start, end - start); } - return std::basic_string<CharType>{}; + return {}; } inline auto console_out() -> std::ostream& { @@ -79,4 +87,4 @@ inline auto console_out() -> std::ostream& { return conout; } -} // namespace mkfs
\ No newline at end of file +} // namespace mkfs |
