home *** CD-ROM | disk | FTP | other *** search
- // Copyright 1994 A.D. Software. All Rights Reserved
-
- // OOFTEST11
-
- // this sample uses shows an easy way to generate test data
- // it comes from a real project, which is why the CLASS_TABLE
- // looks a bit funny - it was generated by AppMaker
-
- // Simple stream I/O is used to interact with the user.
- #include "oofile.hpp"
-
-
- CLASS_TABLE(CdbPhonePro)
- dbChar LastName;
- dbChar FirstName;
- dbChar Title;
- dbChar Extn;
- dbChar Department;
- dbChar Pager;
-
- CdbPhonePro() : dbTable("PhonePro") ,
- LastName(50, "LastName"),
- FirstName(30, "FirstName"),
- Title(50, "Title"),
- Extn(24, "Extn"),
- Department(50, "Department"),
- Pager(24, "Pager")
- {
- LastName.index(kIndexCompress);
- FirstName.index(kIndexCompress);
- Title.index(kIndexCompress);
- Extn.index(kIndexCompress);
- Department.index(kIndexCompress);
- Pager.index(kIndexCompress);
-
- };
- };
-
-
- dbConnect_ctree theDB;
- CdbPhonePro PhonePro;
-
- int main()
- {
-
- #ifdef _Macintosh
- // change types of files created by c-tree (given modification to ctclib.c)
- ctMacCreator = 'PhPr';
- ctMacType = 'OOCT';
- #endif
-
- cout << "OOFILE Validation Suite - Test 11\n"
- << "Simple test to demonstrate using the inbuilt test data generator" << endl
- << "as you would to generate random data for a real project" << endl << endl;
-
- cout << "Enter the name of a text file from which random chunks will be drawn" << endl
- << "File: " << flush;
-
- char testFileName[255];
- cin.width(255);
- cin >> testFileName;
-
- if (!dbConnect::fileExists(testFileName)) {
- cout << "Sorry, couldn't find the file: " << testFileName << endl;
- return EXIT_SUCCESS;
- }
-
- cout << endl << "Number of test records: " << flush;
- unsigned long numRecs;
- cin >> numRecs;
-
- if (numRecs==0)
- return EXIT_SUCCESS;
-
- if (dbConnect::fileExists("ooftst11.db")) {
- theDB.openConnection("ooftst11.db");
- cout << "Deleting the " << PhonePro.countAll() << " records from the last run..." << endl;
- PhonePro.deleteAll();
- }
- else {
- theDB.newConnection("ooftst11.db");
- }
-
- cout << endl << "Generating " << numRecs << " test records..." << endl;
-
- theDB.generateTestData(testFileName, numRecs);
-
- cout << endl << "Do you want to display the test data? (Y/N) " << flush;
- char yn = 'N';
- cin >> yn;
-
- if ((yn=='y') || (yn=='Y'))
- cout << theDB << endl;
-
- cout << "done" << endl;
-
- return EXIT_SUCCESS;
- }