Advertisement
Guest User

Parser.h

a guest
Oct 3rd, 2018
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. //Parser.h
  2. #pragma once
  3.  
  4. #include <sstream>
  5.  
  6. template<typename T>
  7. class Parser{
  8.  
  9. private:
  10.     std::istream& input;
  11.     std::string stopLine;
  12. public:
  13.     Parser(std::istream& input, std::string& stopLine) : input(input), stopLine(stopLine){}
  14.     bool readNext(T& toParse){
  15.         this->input >> toParse;
  16.         std::ostringstream s;
  17.         s << toParse;
  18.         if(s.str() == this->stopLine){
  19.             return false;
  20.         }
  21.         return true;
  22.     }
  23. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement