The Main Routine
This code sample shows the main routine for the tutorial. The line numbers correspond to the comments that follow the code.
#include <rw/db/db.h> //1
#include "conrep.h" //2
#include "rentrep.h" //3
#include "tututil.h" //4
int main(int argc, char** argv) //5
{
associateStreams("", "t2out.txt", "t2err.txt");
RWDBManager::setErrorHandler (outputStatus);
RWCString serverType, serverName, userName,
password, databaseName, pstring;
initializeDatabaseArguments(argc, argv, serverType,
serverName, userName, password,
databaseName, pstring); //5
RWDBDatabase aDB = RWDBManager::database
(serverType, serverName, userName, password,
databaseName, pstring); //6
VVContactRepository customerPool (aDB,
customerTableName); //7
VVRentalTransactionRepository rentalTransactions
(aDB, rentalTableName); //8
RWDBColumn customerID = customerPool.idColumn(); //9
RWDBColumn rentalCustomerID =
rentalTransactions.customeridColumn(); //10
RWDBColumn dueDate =
rentalTransactions.dueDateColumn(); //11
RWDateTime aWeekAgo(9,6,2000); //12
aWeekAgo = aWeekAgo - (7 * RWDateTime::millisecsInDay); //13
customerPool.mailingLabels (outStream,
customerID == rentalCustomerID &&
dueDate < aWeekAgo); //14
closeStreams ("", "t2out.txt", "t2err.txt");
return 0;
} //15
Here is a line-by-line description of the program: