How to read a C++ class from file into memory

David Finlayson david.p.finlayson at gmail.com
Thu Mar 22 21:56:16 PDT 2007


For the moment, I just want to understand the key part of your Deserialize function.

The secret sauce is in this line (and others like it): 

s.readExact(strptr, char.sizeof * len)

where s is a file stream. It looks like with this method, it is only possible to read a single variable or an array of the same type (as you are doing here). Is it possible to send a pointer to a struct and read THAT in from the stream? If so, how does it handle padding bytes? I know there is an align() attribute for structs that might apply here.


More information about the Digitalmars-d-learn mailing list