given the following dummy schema test.capnp:
struct Person {
const type :Text = "person.type.example";
version @0 :UInt32;
name @1 :Text;
}
At runtime, how can we read the default const value from a schema struct (i.e the "person.type.example" above? type does not show up as a field:
std::string schema_filename = "test.capnp";
kj::ArrayPtr<const kj::StringPtr> import_paths;
capnp::SchemaParser parser;
capnp::ParsedSchema schema = parser.parseDiskFile(
schema_filename.c_str(), schema_filename.c_str(), import_paths);
auto person_maybe = schema.findNested("Person");
auto* person_schema = kj::_::readMaybe(person_maybe);
// how can I read "person.type.example" out of the Person struct?
We need to go down a nested level with getNexted and then reinterpret the const type as text: