Re: Binary Serialization

2019-07-13 Thread harakim via Digitalmars-d-learn
On Sunday, 14 July 2019 at 00:18:02 UTC, Adam D. Ruppe wrote: On Saturday, 13 July 2019 at 23:52:38 UTC, harakim wrote: class MoveCommand { byte serialNumber; int x; int y; } When I do MoveCommand.sizeof, it returns 4. It is important to understand a class in D is a re

Re: Binary Serialization

2019-07-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 13 July 2019 at 23:52:38 UTC, harakim wrote: class MoveCommand { byte serialNumber; int x; int y; } When I do MoveCommand.sizeof, it returns 4. It is important to understand a class in D is a reference type, so `MoveCommand` here is actually a pointer inte

Binary Serialization

2019-07-13 Thread harakim via Digitalmars-d-learn
I am receiving packets of data over the network from a C#/Java/dlang/etc. client. I'm writing the data directly to a socket, one primitive value at a time in little endian format. I would like to receive this super easily in d. Here is an example of roughly what I want to do. class MoveComm

Re: Binary serialization of a struct

2017-12-08 Thread Daniel Kozak via Digitalmars-d-learn
You should use size_t instead of ulong, but on 32bit you would have still problem because you are trying assign 2^32 which is too big to hold in 32bit On Thu, Dec 7, 2017 at 11:42 PM, kdevel via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > On Tuesday, 19 September 2017 at 06:

Re: Binary serialization of a struct

2017-12-08 Thread Cym13 via Digitalmars-d-learn
27;re looking for. Not sure how it handles nested structs, but there are examples in the test/directory : https://github.com/atilaneves/cerealed/ Cerealed is definitely my favourite library out there for binary serialization. High quality.

Re: Binary serialization of a struct

2017-12-07 Thread kdevel via Digitalmars-d-learn
On Tuesday, 19 September 2017 at 06:32:52 UTC, Nordlöw wrote: I want something straight forward without allot of plumbing on my end. https://github.com/msgpack/msgpack-d I can't unittest my 32-bit code: $ MODEL=32 make -f posix.mak unittest [...] src/msgpack/packer.d(1139): Error: function

Re: Binary serialization of a struct

2017-09-18 Thread Nordlöw via Digitalmars-d-learn
On Saturday, 16 September 2017 at 03:30:51 UTC, Joseph wrote: Are there any simple direct serialization libraries where I can mark elements of a class or struct that I want serialized with an attribute and it will take care of all the rest(including recursive structures, arrays, etc) then deser

Re: Binary serialization of a struct

2017-09-18 Thread spring via Digitalmars-d-learn
On Saturday, 16 September 2017 at 03:30:51 UTC, Joseph wrote: Are there any simple direct serialization libraries where I can mark elements of a class or struct that I want serialized with an attribute and it will take care of all the rest(including recursive structures, arrays, etc) then deser

Re: Binary serialization of a struct

2017-09-16 Thread Sergei Degtiarev via Digitalmars-d-learn
binary serialization.

Re: Binary serialization of a struct

2017-09-16 Thread Azi Hassan via Digitalmars-d-learn
On Saturday, 16 September 2017 at 03:30:51 UTC, Joseph wrote: Are there any simple direct serialization libraries where I can mark elements of a class or struct that I want serialized with an attribute and it will take care of all the rest(including recursive structures, arrays, etc) then deser

Binary serialization of a struct

2017-09-15 Thread Joseph via Digitalmars-d-learn
Are there any simple direct serialization libraries where I can mark elements of a class or struct that I want serialized with an attribute and it will take care of all the rest(including recursive structures, arrays, etc) then deserialize back in to the structs? I want something straight for