Tools.h++ Manual

11-4 104011 Tandem Computers Incorporated
11
5. Seek to the location where the
RWDate
will be stored.
6. Store the date at that location. Most Tools.h++ classes have an
overloaded version of the streaming (<< and >>) operators.
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:
Program description:
1. The program accepts names until encountering an EOF.
#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;
}