/** @file $Id$ $Date$ $Author$ @copy © Marc Wäckerlin @license LGPL, see file COPYING $Log$ Revision 1.2 2004/12/14 20:21:21 marc bugfix, now it works for empty lines Revision 1.1 2004/10/13 11:18:33 marc getline reads a whole line from a stream */ #include std::string mrw::getline(std::istream& is, char d) { std::string s; mrw::getline(is, s, d); return s; } std::istream& mrw::getline(std::istream& is, std::string& s, char d) { char buf[255]; char c; s.clear(); do { if (is) { if (is.get(buf, 255, d)) s += buf; is.clear(); // is.get fails if line is empty if (is.get(c) && c!=d) s+=c; } } while (is.good() && !is.eof() && c!=d); return is; }