Question: Can you please help me struct void readFile,bool getNextField, and bool getNextField? Data for this code 367430850,2019-01-01T00:00:05,30.40366,-88.85801,0.0,126.3,511.0,MISS NIZ,IMO8987539,WDF2697,31,0,22,8,2.4,52,B 255806194,2019-01-01T00:00:05,29.91171,-90.10790,0.0,137.2,272.0,NORDBALTIC,IMO9241475,CQAJ8,70,0,207,30,9.4,70,B 548799000,2019-01-01T00:00:06,29.20933,-89.27852,9.5,-78.6,332.0,BOW HECTOR,IMO9363493,DYWK,80,0,174,27,11.0,80,B #include #include #include #include

 Can you please help me struct void readFile,bool getNextField, and boolgetNextField? Data for this code 367430850,2019-01-01T00:00:05,30.40366,-88.85801,0.0,126.3,511.0,MISS NIZ,IMO8987539,WDF2697,31,0,22,8,2.4,52,B 255806194,2019-01-01T00:00:05,29.91171,-90.10790,0.0,137.2,272.0,NORDBALTIC,IMO9241475,CQAJ8,70,0,207,30,9.4,70,B 548799000,2019-01-01T00:00:06,29.20933,-89.27852,9.5,-78.6,332.0,BOW HECTOR,IMO9363493,DYWK,80,0,174,27,11.0,80,B #include #include

Can you please help me struct void readFile,bool getNextField, and bool getNextField?

Data for this code

367430850,2019-01-01T00:00:05,30.40366,-88.85801,0.0,126.3,511.0,MISS NIZ,IMO8987539,WDF2697,31,0,22,8,2.4,52,B 255806194,2019-01-01T00:00:05,29.91171,-90.10790,0.0,137.2,272.0,NORDBALTIC,IMO9241475,CQAJ8,70,0,207,30,9.4,70,B 548799000,2019-01-01T00:00:06,29.20933,-89.27852,9.5,-78.6,332.0,BOW HECTOR,IMO9363493,DYWK,80,0,174,27,11.0,80,B

#include #include #include #include #include #include

using namespace std;

// Structure to hold item data struct AISType { string MMSI; // 0 string baseDateTime; // 1 double lattitude; // 2 double longitude; // 3 double sog; // 4 double cog; // 5 double heading; // 6 string vesselName; // 7 string imo; // 8 string callSign; // 9 string vesselType; // 10 string status; // 11 double length; // 12 double width; // 13 double draft; // 14 string cargo; // 15 string transceiverClass; // 16 };

// Prototypes for functions void readFile( ifstream & inFile, vector &item, int& count); bool openInputFile( ifstream & inFile ); string makeStringUpper( string s); int searchForVesselByName( vector & dataBase, string vesselName, vector & s ); void printRecord( AISType & item ); bool getNextField(string &line, int &index, string &subString); double stringConvert(string); int findLastOccurrance(string mmsi, vector &d); int findFirstOccurrance(string mmsi, vector &d); void addUniqueString( vector &s, string value); void saveField( int fieldNumber, string subString, AISType &tempItem ); double distanceTraveled( vector & dataBase, int first, int last );

int main() { // number of records read into the dataBase int count=0;

// the dataBase // vector type is used because it's too big for an array. // (on my computer anyway) vector dataBase; vector mmsi;

// input file ifstream inFile;

// temporary strings string temp; string ansYN;

int found=0; string stars=""; int first =0, last =0;

// open the input file if (openInputFile( inFile ) ) cout

// read the entire file into the dataBase readFile( inFile, dataBase, count);

cout

cin.ignore( 40, ' ');

// user interaction loop do{

// prompt the user for the input to search for. q to quit temp.clear(); mmsi.clear();

cout

// read the user input. getline is used so that spaces may be included // in the input getline(cin, temp, ' ');

// check to see if the user wants to exit the program. // If not exiting, output the search string. if ( temp != "q" or temp == "Q" ){ cout

// search for the number of items that contain the name/phrase // All names in the vessel dataBase are upper case, so make the search // string upper. MMSI is built by the function and contains the vector // of unique vessels that contain the name searched for. found = searchForVesselByName( dataBase, makeStringUpper(temp), mmsi );

// Let the user know if any ships were found with the name if( found

// ships were found, see if the user wants to display them cout > ansYN;

if (ansYN =="y" or ansYN == "Y"){

// print all the first records for the ships found for (unsigned int i=0; i

// find the vessels using MMSI and print the records int index = findFirstOccurrance( mmsi[i], dataBase );

// verify that a valid record was found, print the record if ( index != -1) printRecord( dataBase[index]); } // Ask user if they want to calculate the distance traveled for // the vessel. cout > ansYN;

if ( ansYN == "y" or ansYN == "Y"){ cout > temp; cout

// locate the index value of the first and last record first = findFirstOccurrance( temp, dataBase); last = findLastOccurrance( temp, dataBase);

//output the sitances and miles traveled cout

} while ( true );

} double distanceTraveled( vector & dataBase, int first, int last ){

return 0.0; // Keeps the compiler happy, students should replace

} int findLastOccurrance(string mmsi, vector &d){ return -1; // Keeps the compiler happy, students should replace } int findFirstOccurrance(string mmsi, vector &d){ return -1;// Keeps the compiler happy, students should replace } int searchForVesselByName( vector & dataBase, string vesselName, vector &s) { return 0; // Keeps the compiler happy, students should replace

} void addUniqueString( vector &s, string value){ } double stringConvert(string s){ return 0.0; // Keeps the compiler happy, students should replace } void printRecord( AISType &item ) {

} bool openInputFile( ifstream & inFile ) { return false ; // Keeps the compiler happy, students should replace } void readFile( ifstream & inFile, vector &item, int& count) {

} void saveField( int fieldNumber, string subString, AISType &tempItem ){

} bool getNextField(string &line, int &index, string &subString) { return false;// Keeps the compiler happy, students should replace } string makeStringUpper(string s) { return s; // Keeps the compiler happy, students should replace }

Can you please help me struct void readFile,bool getNextField, and bool getNextField?

Data for this code

367430850,2019-01-01T00:00:05,30.40366,-88.85801,0.0,126.3,511.0,MISS NIZ,IMO8987539,WDF2697,31,0,22,8,2.4,52,B 255806194,2019-01-01T00:00:05,29.91171,-90.10790,0.0,137.2,272.0,NORDBALTIC,IMO9241475,CQAJ8,70,0,207,30,9.4,70,B 548799000,2019-01-01T00:00:06,29.20933,-89.27852,9.5,-78.6,332.0,BOW HECTOR,IMO9363493,DYWK,80,0,174,27,11.0,80,B

void readFile( ifstream & inFile, vector Sitem, int& count); inFile - already open file to be read item - vector to store data count - the number of records read This function uses the previously opened filestream to read in the data from the file. You must use getline() to read the data from the file with a ' 'as the terminating character. Once the line of data has been read, use getNextField() to parse the line, one field at a time. The initial call after the getline) should have the index set to zero, so it starts at the beginning of the string. getNextField() will update the index, so it won't need to be reset to zero until after the next call to getline(). The data should be read until end of file is reached. See example output. The function should start with a locally declared and initialized AISType temporary record. As the line is read/parsed and the fields are parsed, set the corresponding value in the temporary record. Once parsing the line is complete, and the temporary record is filled, use push_back() to add the temporary record to the AISType vector. Reset all values in the temporary record to default before reusing the temporary record on the next line. The function must keep a counter of the number of records read. The counter is used for outputting the number or records read. readFile() uses the following C++ functions getline() - C++ library getNextField() - student provided saveField() - student provided Algorithm for readFile() 1. use getline() to read the line into a string 2. check for eofo 3. set index to 0, fieldNumber to 0 4. call getNextField() on the string read in 1, passing index, and a string to receive the field 5. use saveField() to store the data in a temporary struct of type AISType (use fieldNumber to determine which field gets the data) 6. increment fieldNumber 7. loop back to 4 until the entire string has been processed. 8. add the temporary struct holding the data to the vector using .push_back() 9. reset fieldNumber and index to 0 10. loop back to 1 till eof() To get the progress count, place the following code at the bottom of the read loop. // Output the number processed. If the number update stops, then // their may be problem with the program. char eraseLine[]={" ',27, 'T', '1','K'}; if( (count % 100000 ) == 0){ cout Sitem, int& count); inFile - already open file to be read item - vector to store data count - the number of records read This function uses the previously opened filestream to read in the data from the file. You must use getline() to read the data from the file with a ' 'as the terminating character. Once the line of data has been read, use getNextField() to parse the line, one field at a time. The initial call after the getline) should have the index set to zero, so it starts at the beginning of the string. getNextField() will update the index, so it won't need to be reset to zero until after the next call to getline(). The data should be read until end of file is reached. See example output. The function should start with a locally declared and initialized AISType temporary record. As the line is read/parsed and the fields are parsed, set the corresponding value in the temporary record. Once parsing the line is complete, and the temporary record is filled, use push_back() to add the temporary record to the AISType vector. Reset all values in the temporary record to default before reusing the temporary record on the next line. The function must keep a counter of the number of records read. The counter is used for outputting the number or records read. readFile() uses the following C++ functions getline() - C++ library getNextField() - student provided saveField() - student provided Algorithm for readFile() 1. use getline() to read the line into a string 2. check for eofo 3. set index to 0, fieldNumber to 0 4. call getNextField() on the string read in 1, passing index, and a string to receive the field 5. use saveField() to store the data in a temporary struct of type AISType (use fieldNumber to determine which field gets the data) 6. increment fieldNumber 7. loop back to 4 until the entire string has been processed. 8. add the temporary struct holding the data to the vector using .push_back() 9. reset fieldNumber and index to 0 10. loop back to 1 till eof() To get the progress count, place the following code at the bottom of the read loop. // Output the number processed. If the number update stops, then // their may be problem with the program. char eraseLine[]={" ',27, 'T', '1','K'}; if( (count % 100000 ) == 0){ cout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!