Instruction Manual

//4 Allocate enough space from the RWFileManager to store the birthday. Function
binaryStoreSize() is a member function in most Rogue Wave classes. It returns the number
of bytes necessary to store an object in an RWFile. If you are storing an entire
RWCollection, or using one of the methods recursiveSaveOn() or operator<<(RWFile&,
RWCollectable), be sure to use recursiveStoreSize() instead.
//5 Seek to the location where the RWDate will be stored.
//6 Store the date at that location. Most Rogue Wave classes have an overloaded version of the
streaming operators << and >>.
//7 Insert the key and offset to the object in the B-tree.
Having stored the names and birthdates on a file, here's how you might retrieve them:
#include <rw/disktree.h>
#include <rw/filemgr.h>
#include <rw/cstring.h>
#include <rw/rwdate.h>
#include <rw/rstream.h>
main(){
RWCString name;
RWDate birthday;
RWFileManager fm("birthday.dat");
RWBTreeOnDisk btree(fm);
while(1)
{
cout << "Give name: ";
if (!( cin >> name)) break; // 1
RWoffset loc = btree.findValue(name); // 2
if (loc==RWNIL) // 3
cerr << "Not found.\n";
else
{
fm.SeekTo(loc); // 4
fm >> birthday; // 5
cout << "Birthday is " << birthday << endl; // 6
}
}
return 0;
}
Here is a description of the program: