A bit of error handling and better comments
This commit is contained in:
parent
2eb0754b4e
commit
b888585f75
@ -189,7 +189,7 @@ std::vector<Block> ModuleDataFormatter::StringToBlocks(
|
||||
case Configuration::IOBASE_FORMAT::BASE_16:
|
||||
case Configuration::IOBASE_FORMAT::BASE_64:
|
||||
// Easy case: Each digit is exactly one char in size.
|
||||
// We can just calculate how many bits we should take.
|
||||
// We can just calculate how many bytes we should read.
|
||||
for (std::size_t i = 0; i < str.length(); i += blockWidth) {
|
||||
|
||||
const std::string subs = str.substr(i, blockWidth);
|
||||
@ -204,8 +204,8 @@ std::vector<Block> ModuleDataFormatter::StringToBlocks(
|
||||
break;
|
||||
|
||||
case Configuration::IOBASE_FORMAT::BASE_UWU:
|
||||
case Configuration::IOBASE_FORMAT::BASE_UGH:
|
||||
// Hard case: Each digit n digits long. Digits may vary in length.
|
||||
case Configuration::IOBASE_FORMAT::BASE_UGH: {
|
||||
// Hard case: Each digit is n digits long. Digits may vary in length.
|
||||
// They are seperated by spaces.
|
||||
// We have to parse them...
|
||||
std::size_t digitsPassed = 0;
|
||||
@ -232,12 +232,17 @@ std::vector<Block> ModuleDataFormatter::StringToBlocks(
|
||||
blockStart = i+1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// Here should never be any digits left. A formatted block should ALWAYS be full length.
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
throw std::invalid_argument("ModuleDataFormatter::StringToBlocks() has been passed an unknown base! No switch-case matched!");
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return blocks;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user