-
Notifications
You must be signed in to change notification settings - Fork 106
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
5433262
commit 23c76ff
Showing
4 changed files
with
43 additions
and
27 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,22 @@ | ||
#include "rfl/capnproto/SchemaImpl.hpp" | ||
|
||
#include <capnp/schema-parser.h> | ||
#include <capnp/schema.h> | ||
|
||
namespace rfl::capnproto { | ||
|
||
SchemaImpl::SchemaImpl(const std::string& _str) | ||
: str_(_str), schema_(Box<capnp::StructSchema>::make(make_schema(_str))) {} | ||
|
||
capnp::StructSchema make_schema(const std::string& _str) { | ||
auto dir = kj::newInMemoryDirectory(kj::nullClock()); | ||
auto path = kj::Path::parse("foo/bar.capnp"); | ||
dir->openFile(path, kj::WriteMode::CREATE | kj::WriteMode::CREATE_PARENT) | ||
->writeAll(_str); | ||
capnp::SchemaParser parser; | ||
auto parsed_schema = | ||
parser.parseFromDirectory(*dir, std::move(path), nullptr); | ||
return parsed_schema.asStruct(); | ||
} | ||
|
||
} // namespace rfl::capnproto |