Changeset 233 in tmcsimulator for branches/FEPSimulator/HighwaysParser.cpp
- Timestamp:
- 11/13/2017 06:07:07 PM (8 years ago)
- File:
-
- 1 edited
-
branches/FEPSimulator/HighwaysParser.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/FEPSimulator/HighwaysParser.cpp
r218 r233 1 1 /* 2 * File: HighwaysParser.cpp 3 * Author: jtorres 2 * File: HighwaysParser.h 4 3 * 5 * Created on October 28, 2017, 7:23 PM 4 * The HighwaysParser class takes in a character buffer and parses it into a 5 * vector of FEP_LINEs and a vector of STATIONS. The buffer is sent in via the 6 * constructor and the FEP_LINE and STATION vectors are accessible via public 7 * members. 8 * 9 * @author John A. Torres 6 10 */ 7 11 8 12 #include "HighwaysParser.h" 9 /* 43 // "number of lines" 10 * 32 0 13 // "line id" "count num" "number of stations" 11 * 1210831 1 5 S 0.9 8 // "station id" "drop num" "route num"... 12 * // ..."direction" "postmile" "number of loops" 13 * 1210832 0.0 0 // "loop id" "occ" "vol" 14 * 1210833 0.0 0 // .. 15 * 1210834 0.0 0 // .. 16 * 1210835 0.0 0 // .. 17 * 1210836 0.0 0 // .. 18 * 1210837 0.0 0 // .. 19 * 1210838 0.0 0 // .. 20 * 1210839 0.0 0 // .. 21 * */ 13 14 // The public stations member, containing the parsed vector of STATIONS 22 15 HighwaysParser::HighwaysParser(char * hwyData) { 23 16 parseLines(hwyData); 24 17 } 25 18 19 // Frees all allocated memory in the class 26 20 HighwaysParser::~HighwaysParser() { 27 21 // deallocate FEPLines … … 48 42 } 49 43 44 /** 45 * Parses the buffer into FEP_LINE and STATION vectors. 46 * 47 * @param highwaysData buffer 48 */ 50 49 void HighwaysParser::parseLines(char * hwyData) 51 50 { 51 // convert buffer to cpp string type 52 52 string highwaysData = hwyData; 53 // create buffer stream 53 54 istringstream highwaysStream(highwaysData); 55 // get the number of FEPLines 54 56 string currLine; 55 57 getline(highwaysStream, currLine); 56 58 int numLines; 57 59 sscanf(currLine.c_str(), "%d", &numLines); 60 61 // declare variables used in parsing lines and stations 58 62 int lineNum = 0; 59 63 long lds = 0; … … 72 76 int vol = 0; 73 77 78 // for each line 74 79 for(int lineIndex = 0; lineIndex < numLines; lineIndex++) 75 80 { … … 87 92 newLine->schedleSeq = schedleSeq; 88 93 94 // for each station 89 95 for(int stationIndex = 0; stationIndex < numStations; stationIndex++) 90 96 { … … 104 110 newStation->MlTotVol = 0; 105 111 newStation->OppTotVol = 0; 106 112 // for each loop 107 113 for(int loopIndex = 0; loopIndex < numLoops; loopIndex++) 108 114 { … … 121 127 newStation->dataPack = DataPacker::packData(newStation); 122 128 129 // add new station to stations vector 123 130 this->stations.push_back(newStation); 124 131 } 132 // add new line to lines vector 125 133 this->lines.push_back(newLine); 126 134 }
Note: See TracChangeset
for help on using the changeset viewer.
