WIP
This commit is contained in:
parent
cf434bcae3
commit
14620c4487
@ -80,6 +80,7 @@ public:
|
||||
long int size = 0;
|
||||
std::size_t var_size = 0;
|
||||
auto id = *curr;
|
||||
traits&
|
||||
format::type token_type;
|
||||
++curr;
|
||||
switch (id) {
|
||||
@ -127,27 +128,34 @@ public:
|
||||
size = sizeof(format::str32::first_type);
|
||||
token_type = format::type::string;
|
||||
break;
|
||||
case format::bin8::marker:
|
||||
size = sizeof(format::bin8::first_type);
|
||||
token_type = format::type::bytes;
|
||||
break;
|
||||
case format::bin16::marker:
|
||||
size = sizeof(format::bin16::first_type);
|
||||
token_type = format::type::bytes;
|
||||
break;
|
||||
case format::bin32::marker:
|
||||
size = sizeof(format::bin32::first_type);
|
||||
token_type = format::type::bytes;
|
||||
break;
|
||||
default:
|
||||
return tl::make_unexpected(error::not_implemented);
|
||||
}
|
||||
|
||||
if (remaining(curr) < size) {
|
||||
return tl::make_unexpected(error::incomplete_message);
|
||||
}
|
||||
|
||||
switch (token_type) {
|
||||
case format::type::unsigned_int:
|
||||
if (remaining(curr) < size) {
|
||||
return tl::make_unexpected(error::out_of_space);
|
||||
}
|
||||
tok = detail::read_value<format::type::unsigned_int>(size, curr);
|
||||
break;
|
||||
case format::type::signed_int:
|
||||
if (remaining(curr) < size) {
|
||||
return tl::make_unexpected(error::out_of_space);
|
||||
}
|
||||
tok = detail::read_value<format::type::signed_int>(size, curr);
|
||||
break;
|
||||
case format::type::string:
|
||||
if (remaining(curr) < size) {
|
||||
return tl::make_unexpected(error::incomplete_message);
|
||||
}
|
||||
var_size = std::bit_cast<std::size_t>(detail::read(size, curr));
|
||||
if (std::size_t(remaining(curr)) < var_size) {
|
||||
return tl::make_unexpected(error::incomplete_message);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user