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
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,
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