next up previous contents
Next: GetObject Up: Persistence Methods Previous: Persistence Methods

WriteObject

NAME WriteObject

PROTOTYPE

#include "SSTable.h"
#include "FileNavigator.h"

int SSTable::WriteObject(FileNavigator * fnav);

EXAMPLE

#include "SSTable.h"
#include "FileNavigator.h"

const int MAX_TABLES = 50;
const char * NAV_FILE = "table.odb";

SSTable * pTable = new SSTable[MAX_TABLES];
int * table_loc = new int[MAX_TABLES];
FileNavigator * f = new FileNavigator();
f->OpenFile(NAV_FILE, WRITE_MODE);
f->ReadFileHeader();

... // do table construction/maniputation

// Write out all the tables...
Word list_loc = 0, place = 0;
f->WriteWord(0, list_loc);

for (int i = 0; i < MAX_TABLES; i++) {
  table_loc[i] = pTable[i].WriteObject(f);
}

f->WriteWords((Word *) table_locs, MAX_TABLES, place);
f->UpdateWord(place, list_loc, list_loc);
f->CloseFile();
PURPOSE

WriteObject dumps out the object to a persistent storage file.

RECEIVES

fnav A pointer to the FileNavigator object responsible for writing the persistent storage file.

RETURN VALUE

A negative value indicates an error or warning.
A non-negative value indicates the index of the object, needed for reconstruction.

REMARKS

See also: GetObject



Olivera Tosic
12/17/1999