Advertisement
Brandan

Untitled

Oct 10th, 2014
474
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. bool list::ReadFromDisk(void) {
  2.     ifstream codes("launch-codes");
  3.     while (codes) {
  4.         string s;
  5.         if (!getline(codes, s)) break;
  6.         istringstream ss(s);
  7.         while (ss) {
  8.             Winery* obj = new Winery;
  9.             string s;
  10.             if (!getline(ss, s, ',')) break;
  11.             obj->setName(s.c_str());
  12.             if (!getline(ss, s, ',')) break;
  13.             obj->setLocation(s.c_str());
  14.             if (!getline(ss, s, ',')) break;
  15.             obj->setAcre(atoi(s.c_str()));
  16.             if (!getline(ss, s, ',')) break;
  17.             obj->setRating(atoi(s.c_str()));
  18.             if (!getline(ss, s, ',')) break;
  19.             obj->setYear(atoi(s.c_str()));
  20.             this->insert(*obj);
  21.             delete obj;
  22.         }
  23.     }
  24.     if (!codes.eof()) {
  25.         cerr << "Error!\n";
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement