How do I use binaryStoreSize and recursiveStoreSize?

Article ID: 1058
Last updated: 05 Feb, 2008
Article ID: 1058
Last updated: 05 Feb, 2008
Revision: 1
Views: 3112
Posted: 25 Jun, 1997
by Dean J.
Updated: 05 Feb, 2008
by Dean J.
Problem


This entry contains more information about the use of binaryStoreSize() and recursiveStoreSize().


Action


These two functions are used to calculate how much space an object will take up if it is persisted in an RWFile. (Note: this is not the same as persisting to a virtual stream. The amount of space needed for a stream varies depending on the implementation that is derived from the RWvostream base class.)

To calculate the correct store size, there are four different functions to use:

  • sizeof() for built-in types
  • binaryStoreSize() for Rogue Wave types not derived from RWCollectable
  • recursiveStoreSize() for RWCollectables
  • nilStoreSize() for RWCollectable pointers that are nil.
The confusing part is that RWCollectables also have a binaryStoreSize() function, but in this instance it isn't the correct function to use (it is used internally by the recursiveStoreSize() function). The RWvostream& operator<< that we define for RWCollectable classes adds in a little extra storage that binaryStoreSize() doesn't take into account, but recursiveStoreSize() does. Classes such as RWCString that don't derive from RWCollectable don't have this extra overhead, so binaryStoreSize() will return the correct value for those classes.
This article was:   Helpful | Not helpful
Report an issue
Article ID: 1058
Last updated: 05 Feb, 2008
Revision: 1
Views: 3112
Posted: 25 Jun, 1997 by Dean J.
Updated: 05 Feb, 2008 by Dean J.

Others in this category