Re: Binary serialization of a struct
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: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 core.stdc.stdlib.malloc (uint > size) is not callable using argument types (ulong) > > >
Re: Binary serialization of a struct
On Saturday, 16 September 2017 at 13:15:54 UTC, Azi Hassan wrote: 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 deserialize back in to the structs? I want something straight forward without allot of plumbing on my end. Have you checked Cerealed ? From the looks of it, it supports a @NoCereal attribute which does the opposite of what you'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
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 core.stdc.stdlib.malloc (uint size) is not callable using argument types (ulong)
Re: Binary serialization of a struct
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 deserialize back in to the structs? I want something straight forward without allot of plumbing on my end. https://github.com/msgpack/msgpack-d is about as simple as it can get: import std.file; import msgpack; struct S { int x; float y; string z; } void main() { S input = S(10, 25.5, "message"); // serialize data ubyte[] inData = pack(input); // write data to a file write("file.dat", inData); // read data from a file ubyte[] outData = cast(ubyte[])read("file.dat"); // unserialize the data S target = outData.unpack!S(); // verify data is the same assert(target.x == input.x); assert(target.y == input.y); assert(target.z == input.z); }
Re: Binary serialization of a struct
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 deserialize back in to the structs? I want something straight forward without allot of plumbing on my end. https://github.com/huntlabs/common/blob/master/source/zhang2018/common/Serialize.d only a single file . can serialize/deserialize struct,class,array.
Re: Binary serialization of a struct
On Saturday, 16 September 2017 at 03:30:51 UTC, Joseph wrote: Are there any simple direct serialization libraries... I want something straight forward without allot of plumbing on my end. You may also take a look at https://github.com/sdegtiarev/persistentObject This is small module for binary serialization.
Re: Binary serialization of a struct
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 deserialize back in to the structs? I want something straight forward without allot of plumbing on my end. Have you checked Cerealed ? From the looks of it, it supports a @NoCereal attribute which does the opposite of what you're looking for. Not sure how it handles nested structs, but there are examples in the test/directory : https://github.com/atilaneves/cerealed/
Binary serialization of a struct
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 forward without allot of plumbing on my end.