PageRenderTime 30ms CodeModel.GetById 23ms app.highlight 5ms RepoModel.GetById 0ms app.codeStats 0ms

/cln-1.3.2/src/base/string/input/cl_st_get1.cc

#
C++ | 34 lines | 21 code | 8 blank | 5 comment | 3 complexity | 65fcf51edcb95ecad280a159da816980 MD5 | raw file
Possible License(s): GPL-2.0
 1// cl_fget().
 2
 3// General includes.
 4#include "base/cl_sysdep.h"
 5
 6// Specification.
 7#include "cln/string.h"
 8
 9
10// Implementation.
11
12#include "cln/io.h"
13#include "base/string/cl_spushstring.h"
14
15namespace cln {
16
17const cl_string cl_fget (std::istream& stream, char delim)
18{
19	var cl_spushstring buffer;
20	// Handling of eofp is tricky: EOF is reached when (!stream.good()) || (stream.eof()).
21	while (stream.good()) {
22		var int c = stream.get();
23		if (stream.eof())
24			break;
25		if (c==delim) {
26			stream.unget();
27			break;
28		}
29		buffer.push(c);
30	}
31	return buffer.contents();
32}
33
34}  // namespace cln