Skip to content

Commit

Permalink
Fixed bytestring
Browse files Browse the repository at this point in the history
  • Loading branch information
liuzicheng1987 committed Nov 9, 2024
1 parent bd40b7a commit f9137eb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions include/rfl/ubjson/Reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ class Reader {
return _var.val_->as<std::string>();
} else if constexpr (std::is_same<std::remove_cvref_t<T>,
rfl::Bytestring>()) {
if (!_var.val_->is_byte_string()) {
if (!_var.val_->is<std::vector<uint8_t>>()) {
return Error("Could not cast to bytestring.");
}
return rfl::Bytestring(); // TODO
const auto vec = _var.val_->as<std::vector<uint8_t>>();
return rfl::Bytestring(std::bit_cast<const std::byte*>(vec.data()),
vec.size());
} else if constexpr (std::is_same<std::remove_cvref_t<T>, bool>()) {
if (!_var.val_->is_bool()) {
return rfl::Error("Could not cast to boolean.");
Expand Down

0 comments on commit f9137eb

Please sign in to comment.