parent
e929ed1dc4
commit
38f6f02c76
2 changed files with 97 additions and 1 deletions
@ -0,0 +1,44 @@ |
||||
/** @file
|
||||
|
||||
$Id$ |
||||
|
||||
$Date$ |
||||
$Author$ |
||||
|
||||
@copy © Marc Wäckerlin |
||||
@license LGPL, see file <a href="license.html">COPYING</a> |
||||
|
||||
$Log$ |
||||
Revision 1.1 2004/10/13 11:18:33 marc |
||||
getline reads a whole line from a stream |
||||
|
||||
|
||||
*/ |
||||
|
||||
#include <stdext.hpp> |
||||
|
||||
std::string mrw::getline(std::istream& is, char d) { |
||||
char buf[255]; |
||||
char c; |
||||
std::string s; |
||||
do { |
||||
if (is && is.get(buf, 255, d)) { |
||||
s += buf; |
||||
if (is.get(c) && c!=d) s+=c; |
||||
} |
||||
} while (is.good() && !is.eof() && c!=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 && is.get(buf, 255, d)) { |
||||
s += buf; |
||||
if (is.get(c) && c!=d) s+=c; |
||||
} |
||||
} while (is.good() && !is.eof() && c!=d); |
||||
return is; |
||||
} |
Loading…
Reference in new issue