Hi Christian,

One way to do this:

    capnp::AnyStruct::Reader(myStructReader).getDataSection()

This will return a kj::ArrayPtr<const byte> that points at the "data
section" of the struct, which contains the non-pointer fields. .begin()
gives you a direct pointer to the first byte. The data section comes before
the pointer section, so this is essentially a pointer to the start of the
struct.

-Kenton

On Fri, Feb 17, 2017 at 12:19 AM, <[email protected]> wrote:

> Hi,
> I've been looking at the reflection api for a way to inspect the layout of
> the encoded data. Specifically what I've been looking for is a reliable way
> to find the word-offset of the beginning of a given struct. Is there a way
> to do that?
>
> For context, the reason I need it is that I need to keep some
> proto-encoded data up to date with small changes that come in occasionally.
> So I need a mechanism for representing just the deltas between two versions
> of a proto, and ideally a really simple way that works just on the binary
> encoded data. The data is mainly flat lists of structs. A simple approach I
> wanted to try was to simply xor the entire before- and after- binaries and
> then zipping the result. Before and after will be very similar so the xor
> should be mostly 0 and so zipping should shrink it down to hardly anything.
> Except there's a hitch: if just one of the structs changes size the other
> elements will shift around and not line up, and xor'ing won't cancel them
> out. But if I could determine where in the binary each element starts I can
> line corresponding elements up by 0-padding (which would be removed again
> when applying the update) and then the scheme should work.
>
>
> c
>
> --
> 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.
>

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