Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef PARSER_H
- #define PARSER_H
- #include <iostream>
- #include <sstream>
- template <class T>
- class Parser {
- private:
- std::istream& _in;
- std::string _stopLine;
- std::string currentString;
- public:
- Parser(std::istream& in, std::string stopLine) :
- _in(in), _stopLine(stopLine)
- {
- }
- inline bool readNext(T& element)
- {
- std::cin >> element;
- std::stringstream stream;
- stream << element;
- stream >> currentString;
- if (currentString != _stopLine)
- {
- return true;
- }
- return false;
- }
- };
- #endif //!PARSER_H
Add Comment
Please, Sign In to add comment