diff options
| author | Mike Buland <eichlan@xagasoft.com> | 2012-03-25 20:00:08 +0000 |
|---|---|---|
| committer | Mike Buland <eichlan@xagasoft.com> | 2012-03-25 20:00:08 +0000 |
| commit | 469bbcf0701e1eb8a6670c23145b0da87357e178 (patch) | |
| tree | b5b062a16e46a6c5d3410b4e574cd0cc09057211 /src/stable/stream.cpp | |
| parent | ee1b79396076edc4e30aefb285fada03bb45e80d (diff) | |
| download | libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.gz libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.bz2 libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.xz libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.zip | |
Code is all reorganized. We're about ready to release. I should write up a
little explenation of the arrangement.
Diffstat (limited to 'src/stable/stream.cpp')
| -rw-r--r-- | src/stable/stream.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/stable/stream.cpp b/src/stable/stream.cpp new file mode 100644 index 0000000..58641cc --- /dev/null +++ b/src/stable/stream.cpp | |||
| @@ -0,0 +1,53 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2007-2011 Xagasoft, All rights reserved. | ||
| 3 | * | ||
| 4 | * This file is part of the libbu++ library and is released under the | ||
| 5 | * terms of the license contained in the file LICENSE. | ||
| 6 | */ | ||
| 7 | |||
| 8 | #include "bu/stream.h" | ||
| 9 | |||
| 10 | Bu::Stream::Stream() | ||
| 11 | { | ||
| 12 | } | ||
| 13 | |||
| 14 | Bu::Stream::~Stream() | ||
| 15 | { | ||
| 16 | } | ||
| 17 | |||
| 18 | Bu::String Bu::Stream::readLine() | ||
| 19 | { | ||
| 20 | Bu::String 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 | |||
| 33 | Bu::String Bu::Stream::readAll() | ||
| 34 | { | ||
| 35 | Bu::String sRet; | ||
| 36 | char buf[4096]; | ||
| 37 | |||
| 38 | while( !isEos() ) | ||
| 39 | { | ||
| 40 | int iRead = read( buf, 4096 ); | ||
| 41 | if( iRead == 0 ) | ||
| 42 | return sRet; | ||
| 43 | sRet.append( buf, iRead ); | ||
| 44 | } | ||
| 45 | |||
| 46 | return sRet; | ||
| 47 | } | ||
| 48 | |||
| 49 | Bu::size Bu::Stream::write( const Bu::String &sBuf ) | ||
| 50 | { | ||
| 51 | return write( sBuf.getStr(), sBuf.getSize() ); | ||
| 52 | } | ||
| 53 | |||
