On Mon, Feb 6, 2017 at 4:47 AM, <[email protected]> wrote:

> Hi
> I have important questions about dynamic reflection:
> Is that true that dynamic reflection works only with compiled *.capnp
> files (and statically linked to exe/dll)?
>

No. You can load schemas dynamically using `capnp::SchemaLoader` (if you
already have them in binary format as defined in `schema.capnp`) or
`capnp::SchemaParser` (to parse text schemas at runtime).


> And it is not possible just to have *.capnp file and compile them "on the
> fly" and use in dynamic reflection?
>

You can use `capnp::SchemaParser`. You will need to link against the
library `libcapnpc.so` in addition to `libcapnp.so`.

However, it's more secure and robust to exchange schemas in binary format
if possible, and that does not require `libcapnpc.so`.

For example, say you want to design a server that sits in front of a
database, receives Cap'n Proto messages, and inserts them into the
database, converting each field into a row. The server needs to know the
message schema in order to extract field values to turn them into rows.
But, it is intended to work with many different clients with different
schemas and can't be recompiled every time a client changes schema.

In this example, the client should send capnp::schema::Node structures
(defined in `schema.capnp`) to the server, defining the types in question.
These schema nodes are compiled into the client (the capnp generated code
includes embedded binary schemas). You can obtain the schema node for a
type using `capnp::Schema::from<Type>().getProto()`.

-Kenton

-- 
You received this message because you are subscribed to the Google Groups 
"Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/capnproto.

Reply via email to