Advertisement
TwITe

Untitled

Dec 2nd, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.50 KB | None | 0 0
  1. void load_map_from_file() {
  2.     int id;
  3.     index_data current_id;
  4.     ifstream file;
  5.     string file_name = "/home/twite/CLionProjects/Database/map.dat";
  6.     file.open(file_name);
  7.     string s;
  8.     int a;
  9.     streamoff b;
  10.     while (getline (file, s)) {
  11.         if (s == "id") {
  12.             getline (file, s);
  13.             std::istringstream iss(s);
  14.             iss >> a;
  15.             id = a;
  16.         }
  17.         if (s == "file_names") {
  18.             while (getline(file, s)) {
  19.                 if (s == "--") {
  20.                     break;
  21.                 }
  22.                 current_id.file_names.push_back(s);
  23.             }
  24.         }
  25.         if (s == "start_reading_positions") {
  26.             while (getline(file, s)) {
  27.                 if (s == "--") {
  28.                     break;
  29.                 }
  30.                 std::istringstream iss(s);
  31.                 iss >> b;
  32.                 current_id.start_reading_positions.push_back(b);
  33.             }
  34.         }
  35.         if (s == "end_reading_positions") {
  36.             while (getline(file, s)) {
  37.                 if (s == "--") {
  38.                     break;
  39.                 }
  40.                 std::istringstream iss(s);
  41.                 iss >> b;
  42.                 current_id.end_reading_positions.push_back(b);
  43.             }
  44.         }
  45.         if (s == "data_size") {
  46.             getline(file, s);
  47.             std::istringstream iss(s);
  48.             iss >> a;
  49.             current_id.data_size = a;
  50.             indexes[id] = current_id;
  51.  
  52.         }
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement