Working on a cross-platform project in C++, which must read input files in a very simple format:
MESSAGE_NAME "Message text"
ANOTHER_GOOD_MESSAGE "This is another message"
…
I wonder if somebody has or knows a library (a header file) for handling inputs that may be in Windows format or Linux format.
What’s wrong with
#include <fstream>?Of course, it’s conceivable that a Windows implementation would fail to
recognize Unix line endings (but I’ve yet to see one that doesn’t), or
that a Unix implementation has problems with the extra
'\r'—myusual solution is to read the files in binary mode, and strip out any
'\r'by hand. (I read into a classLinefor this, which overloadsoperator>>to callgetlineand then remove any trailing'\r'.)