Something like istream::getline() but with alternative delim characters?

c++, getline, istream, text-parsing

Solution

Unfortunately there is no way to have multiple "line endings". What you can do is read the line with e.g. `std::getline` and put it in an `std::istringstream` and use `std::getline` (with the `';'` separator) in a loop on the `istringstream`.

Although you could check the Boost iostreams library to see it it has functionality for it.

Problem

What's the cleanest way of getting the effect of `istream::getline(string, 256, '\n' OR ';')`? I know it's quite straightforward to write a loop, but I feel that I might be missing something. Am I? What I used: ``` while ((is.peek() != '\n') && (is.peek() != ';')) stringstream.put(is.get()); ```

Original source

Related problems