diff options
author | Mike Buland <eichlan@xagasoft.com> | 2009-09-18 19:37:06 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2009-09-18 19:37:06 +0000 |
commit | de3f8f4f6eab5d5c873c91cc93a01fe2e8a82363 (patch) | |
tree | bbc4c7fdce44cf40e071222837ccf195f067ab82 /src/stream.cpp | |
parent | f27b485eaf1088fa4895d1af4aee9abc2b801872 (diff) | |
download | libbu++-de3f8f4f6eab5d5c873c91cc93a01fe2e8a82363.tar.gz libbu++-de3f8f4f6eab5d5c873c91cc93a01fe2e8a82363.tar.bz2 libbu++-de3f8f4f6eab5d5c873c91cc93a01fe2e8a82363.tar.xz libbu++-de3f8f4f6eab5d5c873c91cc93a01fe2e8a82363.zip |
Added a handy readLine function, I've been meaning to do this for a while.
Diffstat (limited to 'src/stream.cpp')
-rw-r--r-- | src/stream.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/stream.cpp b/src/stream.cpp index 290afb3..01edb38 100644 --- a/src/stream.cpp +++ b/src/stream.cpp | |||
@@ -15,6 +15,21 @@ Bu::Stream::~Stream() | |||
15 | { | 15 | { |
16 | } | 16 | } |
17 | 17 | ||
18 | Bu::FString Bu::Stream::readLine() | ||
19 | { | ||
20 | Bu::FString sRet; | ||
21 | |||
22 | for(;;) | ||
23 | { | ||
24 | char s; | ||
25 | if( read( &s, 1 ) == 0 ) | ||
26 | return sRet; | ||
27 | if( s == '\n' || s == '\r' ) | ||
28 | return sRet; | ||
29 | sRet.append( s ); | ||
30 | } | ||
31 | } | ||
32 | |||
18 | size_t Bu::Stream::write( const Bu::FString &sBuf ) | 33 | size_t Bu::Stream::write( const Bu::FString &sBuf ) |
19 | { | 34 | { |
20 | return write( sBuf.getStr(), sBuf.getSize() ); | 35 | return write( sBuf.getStr(), sBuf.getSize() ); |