-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c8f9684
commit fd3b991
Showing
4 changed files
with
121 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include "rfl/capnproto/Reader.hpp" | ||
|
||
#include "rfl/parsing/schemaful/IsSchemafulReader.hpp" | ||
|
||
namespace rfl::capnproto { | ||
|
||
static_assert(parsing::schemaful::IsSchemafulReader<Reader>, | ||
"This must be a schemaful reader."); | ||
|
||
bool Reader::is_empty(const InputVarType& _var) const noexcept { | ||
// TODO: Is this correct? | ||
return _var.val_.getType() == capnp::DynamicValue::VOID; | ||
} | ||
|
||
rfl::Result<Reader::InputArrayType> Reader::to_array( | ||
const InputVarType& _var) const noexcept { | ||
if (_var.val_.getType() != capnp::DynamicValue::LIST) { | ||
return Error("Could not cast to a list."); | ||
} | ||
return InputArrayType{_var.val_.as<capnp::DynamicList>()}; | ||
} | ||
|
||
rfl::Result<Reader::InputObjectType> Reader::to_object( | ||
const InputVarType& _var) const noexcept { | ||
if (_var.val_.getType() != capnp::DynamicValue::STRUCT) { | ||
return Error("Could not cast to a struct."); | ||
} | ||
return InputObjectType{_var.val_.as<capnp::DynamicStruct>()}; | ||
} | ||
|
||
rfl::Result<Reader::InputMapType> Reader::to_map( | ||
const InputVarType& _var) const noexcept { | ||
if (_var.val_.getType() != capnp::DynamicValue::LIST) { | ||
return Error("Could not cast to a list."); | ||
} | ||
return InputMapType{_var.val_.as<capnp::DynamicList>()}; | ||
} | ||
|
||
rfl::Result<Reader::InputUnionType> Reader::to_union( | ||
const InputVarType& _var) const noexcept { | ||
if (_var.val_.getType() != capnp::DynamicValue::STRUCT) { | ||
return Error("Could not cast to a struct."); | ||
} | ||
return InputUnionType{_var.val_.as<capnp::DynamicStruct>()}; | ||
} | ||
|
||
} // namespace rfl::capnproto |