fork download
  1. std::istream& operator>>(std::istream& file, first& obj)
  2. {
  3. std::string symbol;
  4. while(file >> symbol)
  5. {
  6. if (symbol[0] == '#')
  7. {
  8. std::getline(file, symbol);
  9. }
  10. else if (symbol == FIRSTTAGEND)
  11. {
  12. break;
  13. }
  14. else if (symbol == FILEPATH)
  15. {
  16. if (!(file >> '=' >> obj.filename))
  17. std::cerr << symbol << " is incorrectly formatted";
  18. }
  19. else if (symbol == SCALE)
  20. {
  21. if (! (file >> '=' >> obj.scale) )
  22. std::cerr << symbol << " is incorrectly formatted";
  23. }
  24. else
  25. { //not a member: failure
  26. std::cerr << symbol << " is not a member of first";
  27. file.setstate(file.rdstate() | std::ios::badbit);
  28. break;
  29. }
  30. }
  31. return file;
  32. }
  33.  
  34. std::istream& operator>>(std::istream& file, InputDeck& obj)
  35. {
  36. std::string symbol;
  37. while(file >> symbol)
  38. {
  39. if (symbol[0] == '#')
  40. {
  41. std::getline(file, symbol);
  42. }
  43. else if (symbol == FIRSTTAGBEG)
  44. {
  45. inputMesh t;
  46. if (file >> t)
  47. obj.mesh.push_back(t);
  48. }
  49. else
  50. {
  51. obj.errorH(symbol + " is not a member of the input deck.", 1);
  52. file.setstate(file.rdstate() | std::ios::badbit);
  53. }
  54. }
  55. return file;
  56. }
  57.  
  58. bool InputDeck::readFile(std::string filename)
  59. {
  60. std::ifstream infile;
  61. infile.open(filename.c_str());
  62. infile >> *this;
  63. return true;
  64. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty