PageRenderTime 61ms CodeModel.GetById 36ms RepoModel.GetById 1ms 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. // General includes.
  3. #include "base/cl_sysdep.h"
  4. // Specification.
  5. #include "cln/string.h"
  6. // Implementation.
  7. #include "cln/io.h"
  8. #include "base/string/cl_spushstring.h"
  9. namespace cln {
  10. const cl_string cl_fget (std::istream& stream, char delim)
  11. {
  12. var cl_spushstring buffer;
  13. // Handling of eofp is tricky: EOF is reached when (!stream.good()) || (stream.eof()).
  14. while (stream.good()) {
  15. var int c = stream.get();
  16. if (stream.eof())
  17. break;
  18. if (c==delim) {
  19. stream.unget();
  20. break;
  21. }
  22. buffer.push(c);
  23. }
  24. return buffer.contents();
  25. }
  26. } // namespace cln