View previous topic :: View next topic |
Author |
Message |
TLukar
Joined: 26 Jan 2005 Posts: 2
|
Posted: Sat Jan 29, 2005 10:51 am Post subject: Converting a class to an array of bytes |
|
|
Hi, i am using outbuffer to create the raw data im going to write to a file. But i have stumbled upon many things while trying to write the data inside this class into a file. So i would like to know if there is a way to convert a class into an array of bytes to directly send to the outbuffer. If not just tell me.
Code: |
class Web
{
Web*[] links;
char[] data;
...
}
|
This is the class im trying to write to a file for loading it later on. Thanks. Any suggestions for writing it to a file through other methods are welcome. |
|
Back to top |
|
|
kris
Joined: 27 Mar 2004 Posts: 1494 Location: South Pacific
|
Posted: Sat Jan 29, 2005 1:15 pm Post subject: D class serialization |
|
|
D does not have a native capability for doing that.
However, you'll probably find just what you need in the Mango.io package (via dsource) ... take a look at the example "pickle.d" over here: http://svn.dsource.org/svn/projects/mango/trunk/example/pickle.d
Note that Mango allows you to extend the IO system by binding your own classes to it (via the interfaces IReadable/IWritable, illustrated in that example), which makes it really easy to encapsulate the serialization & deserialization details. Unlike Phobos, Mango.io supports all of the native D types, along with their basic array variations.
You might also find some value in the Mango.cache.VirtualCache, which manages a cache of D classes while spooling overflow entries to the file-system (and subsequently resurrecting them). It will, at least, show you another way to perform Mango pickling
Bon Chance; |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|