1. while(file >> line)
  2. {
  3. words.push_back(line);
  4. }
  5. for(int i = 0; i < words.size(); i++)
  6. {
  7. if(words.at(i).substr(0, 1) == "[" && words.at(i) != "[header]")
  8. layers.push_back(words.at(i));
  9. if(words.at(i).substr(0, 4) == "type")
  10. {
  11. temp = words.at(i);
  12. temp.substr(4, 1);
  13. types.push_back(temp);
  14. }
  15. if(words.at(i) == "[header]")
  16. {
  17. map_width = words.at(i+1).substr(6, words.at(i+1).size());
  18. map_height = words.at(i+2).substr(7, words.at(i+1).size());
  19. stringstream(map_width) >> width;
  20. stringstream(map_height) >> height;
  21. }
  22. if(words.at(i) == "type=background")
  23. {
  24. for(int j = i+1; j <= height + (i+1); j++)
  25. {
  26. int l = 0, m = 1, number = 0, extracted;
  27. string extracted_line = words.at(j);
  28. for(int k = 0; k <= extracted_line.size(); k++)
  29. {
  30. cout << number << endl;
  31. string ph_character = words.at(j).substr(l, m);
  32. if(ph_character == ",")
  33. {
  34. number = 0;
  35. break;
  36. }
  37. if(ph_character == "0") cout << "Found 0.\n";
  38. stringstream(ph_character) >> extracted;
  39. number = (number*10) + extracted;
  40. switch(number)
  41. {
  42. case 1:
  43. //cout << "Found 1" << endl;
  44. break;
  45. case 4:
  46. cout << "Found 4" << endl;
  47. break;
  48. }
  49. l++; m++;
  50. }
  51. }
  52. }
  53. }
  54. file.close();
  55. }