void Maze::loadMaze(char *mazefile) { ifstream mazein; int y = 0; mazein.open(mazefile); if (!mazein) { cout << "Unable to read from " << mazefile << "\n"; exit(0); } while (!mazein.eof()) { string line; Row row(y); getline(mazein, line); row.loadRow(line); rows.insert(row); y++; } rows.rebalance(); mazein.close(); }
void Row::loadRow(const string &s) { int xpos = 0; for (string::const_iterator itr = s.begin(); itr < s.end(); itr++) { Cell *cell = new Cell(xpos, *itr); cells.insert(*cell); xpos++; } }
void read_file(const string &filename, bintree &bt) { ifstream base(filename); if (!base) { cerr << "couldn't read " << filename << endl; exit(1); } string name, line; double lat, lon; while (getline(base, line)) { stringstream sline(line); sline >> lat >> lon >> ws; getline(sline, name); bt.insert(name, lon); } }