| 22 | } |
| 23 | |
| 24 | std::string StringStream::next() |
| 25 | { |
| 26 | /* skip separators */ |
| 27 | while (cin->peek() != EOF) { |
| 28 | if (endl != "" && cin->peek() == '\n') { cin->drop(); return endl; } |
| 29 | if (multiLine && cin->peek() == '\\') { |
| 30 | cin->drop(); |
| 31 | if (cin->peek() == '\n') { cin->drop(); continue; } |
| 32 | cin->unget(); |
| 33 | } |
| 34 | if (!isSeparator(cin->peek())) break; |
| 35 | cin->drop(); |
| 36 | } |
| 37 | |
| 38 | /* parse everything until the next separator */ |
| 39 | std::vector<char> str; str.reserve(64); |
| 40 | while (cin->peek() != EOF && !isSeparator(cin->peek())) { |
| 41 | int c = cin->get(); |
| 42 | if (!isValidChar(c)) throw std::runtime_error("invalid character "+std::string(1,c)+" in input"); |
| 43 | str.push_back((char)c); |
| 44 | } |
| 45 | str.push_back(0); |
| 46 | return std::string(str.data()); |
| 47 | } |
| 48 | } |