Re: [capnproto] Byte Order of multi byte values

2023-01-24 Thread 'Kenton Varda' via Cap'n Proto
Hi Stefan,

Cap'n Proto automatically takes care of byte ordering. You do not need to
worry about this.

Generally, all modern serialization libraries will take care of endianness
automatically. The only time you need to worry about byte-swapping is if
you are reading raw bytes from the wire and interpreting them as integers
yourself, without the help of a serialization library like Cap'n Proto.

Note that Cap'n Proto uses little-endian encoding on the wire. Almost all
processors in wide use these days are little-endian, so this issue hardly
even comes up anymore. However, Cap'n Proto is designed to detect if it is
running on a big-endian architecture and, if so, it'll swap the bytes
automatically.

-Kenton

On Thu, Jan 19, 2023 at 2:59 AM Stefan Schmelz  wrote:

>
> Hey everyone,
> Do you guys know if I have to ensure Byte Order for multi byte values and
> larger integers?
> I was working on a project that did parts of the encoding themselves, so
> Big-/Little endianness would be ensured.
>
> Now I am refactoring a fork of that library for myself and wanted to
> remove anything that is unnecessary. Encoding a 64bit integer as an array
> of 8 bytes is a little excessive, so I would like to remove it.
>
> Nonetheless I still need to ensure that Linux, windows, Mac OS work on all
> hardware platforms. I did read the documentation as if capnp would ensure
> that everything will be encoded and decoded correctly on every platform.
>
> I'm improving on prior work, but try to eliminate some naive mistakes we
> made the first time. By now I have written a schema generator and a
> primitive schema registry. You can create global schema that are stored in
> a central location and symlinked into your source. The central directory
> can be converted to a git repo, so it can be shared. You can also generate
> local schema, that are stored in your sources.
>
> The original project used python to generate wrapping C++ classes to
> automatically load from byte arrays and do some validation... At that time
> nothing like this was documented by Capnproto so we did everything
> ourselves.
>
> --
> 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 capnproto+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/capnproto/CAKJF573hOOgPLSVP2u6OoQmagUmX_0T-08hqYqP1F%3DtXdvbdLg%40mail.gmail.com
> 
> .
>

-- 
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 capnproto+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/capnproto/CAJouXQmfubu70vBcPMjyndqhLXKwNNX-HEg%2BHuNVygK1Bz5_yA%40mail.gmail.com.


[capnproto] Byte Order of multi byte values

2023-01-19 Thread Stefan Schmelz
Hey everyone,
Do you guys know if I have to ensure Byte Order for multi byte values and
larger integers?
I was working on a project that did parts of the encoding themselves, so
Big-/Little endianness would be ensured.

Now I am refactoring a fork of that library for myself and wanted to remove
anything that is unnecessary. Encoding a 64bit integer as an array of 8
bytes is a little excessive, so I would like to remove it.

Nonetheless I still need to ensure that Linux, windows, Mac OS work on all
hardware platforms. I did read the documentation as if capnp would ensure
that everything will be encoded and decoded correctly on every platform.

I'm improving on prior work, but try to eliminate some naive mistakes we
made the first time. By now I have written a schema generator and a
primitive schema registry. You can create global schema that are stored in
a central location and symlinked into your source. The central directory
can be converted to a git repo, so it can be shared. You can also generate
local schema, that are stored in your sources.

The original project used python to generate wrapping C++ classes to
automatically load from byte arrays and do some validation... At that time
nothing like this was documented by Capnproto so we did everything
ourselves.

-- 
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 capnproto+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/capnproto/CAKJF573hOOgPLSVP2u6OoQmagUmX_0T-08hqYqP1F%3DtXdvbdLg%40mail.gmail.com.