From 469bbcf0701e1eb8a6670c23145b0da87357e178 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sun, 25 Mar 2012 20:00:08 +0000 Subject: Code is all reorganized. We're about ready to release. I should write up a little explenation of the arrangement. --- src/stable/stream.cpp | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/stable/stream.cpp (limited to 'src/stable/stream.cpp') 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 @@ +/* + * Copyright (C) 2007-2011 Xagasoft, All rights reserved. + * + * This file is part of the libbu++ library and is released under the + * terms of the license contained in the file LICENSE. + */ + +#include "bu/stream.h" + +Bu::Stream::Stream() +{ +} + +Bu::Stream::~Stream() +{ +} + +Bu::String Bu::Stream::readLine() +{ + Bu::String sRet; + + for(;;) + { + char s; + if( read( &s, 1 ) == 0 ) + return sRet; + if( s == '\n' || s == '\r' ) + return sRet; + sRet.append( s ); + } +} + +Bu::String Bu::Stream::readAll() +{ + Bu::String sRet; + char buf[4096]; + + while( !isEos() ) + { + int iRead = read( buf, 4096 ); + if( iRead == 0 ) + return sRet; + sRet.append( buf, iRead ); + } + + return sRet; +} + +Bu::size Bu::Stream::write( const Bu::String &sBuf ) +{ + return write( sBuf.getStr(), sBuf.getSize() ); +} + -- cgit v1.2.3