C++ Library containing a lot of needful things: Stack Trace, Command Line Parser, Resource Handling, Configuration Files, Unix Command Execution, Directories, Regular Expressions, Tokenizer, Function Trace, Standard Extensions.
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
796 B
42 lines
796 B
20 years ago
|
/** @file
|
||
|
|
||
|
$Id$
|
||
|
|
||
|
$Date$
|
||
|
$Author$
|
||
|
|
||
|
@copy © Marc Wäckerlin
|
||
|
@license LGPL, see file <a href="license.html">COPYING</a>
|
||
|
|
||
|
$Log$
|
||
20 years ago
|
Revision 1.2 2004/12/14 20:21:21 marc
|
||
|
bugfix, now it works for empty lines
|
||
|
|
||
20 years ago
|
Revision 1.1 2004/10/13 11:18:33 marc
|
||
|
getline reads a whole line from a stream
|
||
|
|
||
|
|
||
|
*/
|
||
|
|
||
13 years ago
|
#include <stdext.hxx>
|
||
20 years ago
|
|
||
|
std::string mrw::getline(std::istream& is, char d) {
|
||
|
std::string s;
|
||
20 years ago
|
mrw::getline(is, s, d);
|
||
20 years ago
|
return s;
|
||
|
}
|
||
|
|
||
|
std::istream& mrw::getline(std::istream& is, std::string& s, char d) {
|
||
|
char buf[255];
|
||
|
char c;
|
||
|
s.clear();
|
||
|
do {
|
||
20 years ago
|
if (is) {
|
||
|
if (is.get(buf, 255, d)) s += buf;
|
||
|
is.clear(); // is.get fails if line is empty
|
||
20 years ago
|
if (is.get(c) && c!=d) s+=c;
|
||
|
}
|
||
|
} while (is.good() && !is.eof() && c!=d);
|
||
|
return is;
|
||
|
}
|