CamolaZ

Read transition

Apr 21st, 2016
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.63 KB | None | 0 0
  1.     void readTransaction(Transaction &transaction, ifstream &trans, vector <string> &Products, int &clientID)
  2.     {
  3.         // file transactions:
  4.         if (trans.is_open())
  5.         {
  6.  
  7.             string line;
  8.  
  9.             for (int counter = 1; getline(trans, line, ';'); counter++)
  10.             {
  11.  
  12.                 //cout << line << endl; show: 1/01/2016 ...
  13.                 stringstream ss(line);
  14.                 string test;
  15.                 switch (counter)
  16.                 {
  17.                 case 1:
  18.                     //cin >> transation.id; //cli
  19.                     ss >> transaction.id;
  20.                     if (transaction.id > clientID)
  21.                         clientID = transaction.id;
  22.                     break;
  23.                 case 2:
  24.                     /*int i;
  25.                     i << ss; // mandar de ler de um ss para um int */
  26.                     getline(ss, test, '/');
  27.                     cout << test << endl;
  28.                     getline(ss, test, '/');
  29.                     cout << test << endl;
  30.                     getline(ss, test, '/');
  31.                     cout << test << endl;
  32.                     //cin >> transation.buyDate.day; // read the day of shopping
  33.                     /*
  34.                     getline(ss, line, '/');
  35.                     cin >> transation.buyDate.month;
  36.  
  37.                     getline(trans, line, '/');
  38.                     cin >> transation.buyDate.year;*/
  39.                     /*switch (int counter = 0 )
  40.                     case 1:*/
  41.                     break;
  42.                 case 3:
  43.                     /*istringstream lineI(line); // read until the end of line
  44.                     while (getline(trans, line)); coloca para um string os items
  45.                     getline(trans, line, ',');
  46.                     push_back
  47.                     while (!items.eof())
  48.  
  49.                     cin >> transation.Items;
  50.  
  51.                     counter++;
  52.                     if (counter > 3)
  53.                     {
  54.                     counter = 1;
  55.                     Products.push_back(transation);
  56.                     }*/
  57.                     counter = 1;
  58.                     break;
  59.                 }
  60.             }
  61.         }
  62.         else
  63.             cerr << "error to open transactions file" << endl;
  64.  
  65.         /*while (!cli.eof()) // if
  66.         {
  67.  
  68.         // c_str . atoi (process clients
  69.         // .push_back
  70.         }*/
  71.     }
Advertisement
Add Comment
Please, Sign In to add comment