/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
- // cl_fget().
- // General includes.
- #include "base/cl_sysdep.h"
- // Specification.
- #include "cln/string.h"
- // Implementation.
- #include "cln/io.h"
- #include "base/string/cl_spushstring.h"
- namespace cln {
- const cl_string cl_fget (std::istream& stream, char delim)
- {
- var cl_spushstring buffer;
- // Handling of eofp is tricky: EOF is reached when (!stream.good()) || (stream.eof()).
- while (stream.good()) {
- var int c = stream.get();
- if (stream.eof())
- break;
- if (c==delim) {
- stream.unget();
- break;
- }
- buffer.push(c);
- }
- return buffer.contents();
- }
- } // namespace cln