cgv
Loading...
Searching...
No Matches
line_break.cxx
1
#include "line_break.h"
2
3
namespace
cgv
{
4
namespace
os {
5
std::istream& safe_getline(std::istream& is, std::string& line)
6
{
7
line.clear();
8
std::istream::sentry se(is,
true
);
9
std::streambuf* sb = is.rdbuf();
10
11
for
(;;) {
12
int
c = sb->sbumpc();
13
switch
(c) {
14
case
'\n'
:
15
return
is;
16
case
'\r'
:
17
if
(sb->sgetc() ==
'\n'
)
18
sb->sbumpc();
19
return
is;
20
case
std::streambuf::traits_type::eof():
21
// Also handle the case when the last line has no line ending
22
if (line.empty())
23
is.setstate(std::ios::eofbit);
24
return
is;
25
default
:
26
line += (char)c;
27
}
28
}
29
}
30
}
31
}
cgv
the cgv namespace
Definition
print.h:11
cgv
os
line_break.cxx
Generated by
1.9.8