I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
Index » Programming » New Module Ideas »

will\′s Photo
24 Sep 05, 5:59PM
This approach will work the same as any C++ container, such as vector or list etc.

Your concern shouldn't about how the data inside a class is stored. In truth that's none of your business. What you're interested in doing is saving the contents of the class and retrieving it with (I suspect) a simple cast that put it back into the same form as it was originally. What I think though you're getting at is the use of the [b:472263e98b]new[/b:472263e98b] operator within that class (say).. Thus two variables of class X, could uses substantially different amounts of dynamic memory, because variable 1, allocated 100k of memory, while variable 2 allocated 200k of memory.

This is a much more complex problem and one you can't solve unless you know exactly how that class is configured. The best you can do is insist that your these 'complex' data types have a common method that ensure that they can be forced to save data and reload it on que.

If you go down that line. Then you probably want to structure your binary file in the following form: ------ [data for each data type] * N ------ [key to additional dynamic data] ------ [additional dynamic data] * N

Hope that make sense. But here how I would image it working, with a request for some data 1) You extract the contents of the dynamic data type given the index, using the overload [] operator we discussed above. 2) You call the 'load' method within that newely reloaded class/struct etc, that reloads any additional dynamic data, give a file offset you provide. The offset you get from the key section (or if you prefer you store it immediately after each individual data type).. This simply means on saving you need to know how many data types you have, so you know how much space to leave for each section, with the additional dynamic bit on the end, since you've no idea how big this is until you get to saving..

Thats the only way I can see this will work..

Hope that helps..
Currently you need to be logged in to leave a message.