// parsesection.cpp non-section-specific parsing functions #include "parsesection.h" /******************************************************************************* // FUNCTION NAME: AnotherRecord // // DESCRIPTION OF FUNCTION: Tests the input file to determine if there are any // records remaining in the current section // // DESCRIPTION OF ALGORITHM: Gets a char from the input stream. If that char // is the same as the SECTION_DELIMITER, returns false. Otherwise, puts the // char back into the input stream and returns true. // // CALLED BY: GetAlleyInfo,GetEventInfo,GetToolsInfo,GetBallInfo, // GetReleaseInfo,GetConditionsInfo,GetGameInfo // CALLS: none // // PARAMETERS: / in / inputFile - ifstream to be tested // // PRECONDITIONS: inputFile has been properly intialized to the appropriate // BAM file // // POSTCONDITIONS: If the next line of the input file does not begin with // a SECTION_DELIMITER char, returns true. Otherwise, returns false. // // AUTHOR: Amy Langill *2B DATE: 3/28/1999 *******************************************************************************/ bool AnotherRecord(ifstream& inputFile) { bool moreInSection=true; char testChar; inputFile.get(testChar); if (testChar!=SECTION_DELIMITER) inputFile.putback(testChar); else moreInSection=false; return moreInSection; } /******************************************************************************* // FUNCTION NAME: ReadRecord // // DESCRIPTION OF FUNCTION: Reads record information from inputFile into // recordString // // DESCRIPTION OF ALGORITHM: Depending on the value of section, the function // either reads a single line into recordString or reads a second line into // anotherLine and concatenates the two into recordString // // CALLED BY: GetAlleyInfo,GetEventInfo,GetToolsInfo,GetBallInfo, // GetReleaseInfo,GetConditionsInfo,GetGameInfo,GetFramesInfo // CALLS: none // // PARAMETERS: / inout / inputFile - input filestream that contains the record // to be extracted // / out / recordString - string to hold the record pulled from // inputFile // / in / section - BALSectionType that tells which section is being // parsed, and thus, how many lines are in a record // // PRECONDITIONS: inputFile has been properly opened to the appopriate BAM data // file. The front of the ifstream contains only record data, (record or // section delimiting lines have been removed from the input filestream) // // POSTCONDITIONS: The record data as it appears in inputFile for a single // record has been extracted into recordString. // // AUTHOR: Amy Langill *2B DATE: 3/28/1999 *******************************************************************************/ void ReadRecord(ifstream& inputFile,string& recordString,BALSectionType section) { string anotherLine; getline(inputFile,recordString); switch (section) { case ALLEY: case BALL: case FRAMES: getline(inputFile,anotherLine); recordString += FLD_SEPARATOR + anotherLine; break; } return; }