Re: [capnproto] Dynamically reading schema const property at runtime (c++)

2022-06-08 Thread Daniel Koohmarey
Appreciate the reply Kenton, that got me to the solution I was looking for: std::string type = person_schema->getNested("type").asConst().as().cStr(); And will do on avoiding kj::_. Thanks again! On Wednesday, June 8, 2022 at 11:13:56 AM UTC-7 ken...@cloudflare.com wrote: > Hi Daniel, > > I

Re: [capnproto] Dynamically reading schema const property at runtime (c++)

2022-06-08 Thread 'Kenton Varda' via Cap'n Proto
Hi Daniel, I think you can do: capnp::ConstSchema type = schema.getNested("Person").getNested("type").asConst(); But it's been a long time since I touched this. By the way, please do not use stuff in kj::_ directly, that is a private namespace. To read a Maybe, use KJ_IF_MAYBE,

[capnproto] Dynamically reading schema const property at runtime (c++)

2022-06-08 Thread Daniel Koohmarey
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 is not considered a field