The Main Routine
The following is the main routine for the tutorial. The line numbers correspond to the comments that follow the code.
#include <rw/db/db.h> //1
#include "tututil.h" //2
#include "conrep.h" //3
int main(int argc, char** argv) //4
{
associateStreams("t5in.dat", "t5out.txt", "t5err.txt"); //5
RWDBManager::setErrorHandler(outputStatus); //6
RWCString serverType, serverName, userName,
password, databaseName, pstring; //7
initializeDatabaseArguments(argc, argv, serverType,
serverName, userName, password,
databaseName, pstring); //8
RWDBDatabase aDB = RWDBManager::database
(serverType, serverName, userName, password,
databaseName, pstring); //9
VVContactRepository customerRep(aDB, customerTable); //10
while (!inStream.eof()
&& !inStream.bad() && !inStream.fail()) { //11
unsigned long id; //12
inStream >> id; //13
if (inStream.eof()) //14
break; //15
customerRep.remove( id ); //16
outStream << "Removed customer with ID = "
<< id << " from the database." << endl; //17
}
closeStreams("t5in.dat", "t5out.txt", "t5err.txt");
return 0;
} //18