Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions cli/cli_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,32 @@ const char *CLIParser::next_string()
argv++;
return ret;
}

size_t CLIParser::next_size()
{
const char *max_size_str = next_string();
size_t max_size;
if (max_size_str) {
char *end;
max_size = strtoul(max_size_str, &end, 10);
if (end == max_size_str) {
max_size = 0;
} else {
switch (*end)
{
case 'K':
case 'k':
max_size *= 1024;
break;
case 'M':
case 'm':
max_size *= 1024*1024;
break;
default:
break;
}
}
}
return max_size;
}
}
2 changes: 2 additions & 0 deletions cli/cli_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class CLIParser

const char *next_string();

size_t next_size();

bool is_ended_state() const
{
return ended_state;
Expand Down
Loading