mirror of
https://github.com/akuker/RASCSI.git
synced 2024-12-22 15:30:09 +00:00
Improved string to integer conversion
This commit is contained in:
parent
ee98e68d1e
commit
da764200af
@ -255,6 +255,10 @@ void Reset()
|
||||
|
||||
bool GetAsInt(const string& value, int& result)
|
||||
{
|
||||
if (value.find_first_not_of("0123456789") != string::npos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
result = std::stoul(value);
|
||||
}
|
||||
@ -1106,6 +1110,7 @@ bool ParseArgument(int argc, char* argv[], int& port)
|
||||
case 'b': {
|
||||
if (!GetAsInt(optarg, block_size)) {
|
||||
cerr << "Invalid block size " << optarg << endl;
|
||||
return false;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user