From afb50f535dd60b485a38f1f1f692b3303e28fecc Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 28 Jun 2007 21:58:47 +0000 Subject: The FString has more things that it can do...now. --- src/client.h | 1 + src/fstring.cpp | 6 ++++++ src/fstring.h | 17 +++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/src/client.h b/src/client.h index cee558d..f228e96 100644 --- a/src/client.h +++ b/src/client.h @@ -25,6 +25,7 @@ namespace Bu Bu::FString &getInput(); Bu::FString &getOutput(); void write( const char *pData, int nBytes ); + void read( const char *pData, int nBytes ); void setProtocol( Protocol *pProto ); Bu::Protocol *getProtocol(); diff --git a/src/fstring.cpp b/src/fstring.cpp index 56d2173..0b5a970 100644 --- a/src/fstring.cpp +++ b/src/fstring.cpp @@ -12,3 +12,9 @@ template<> bool Bu::__cmpHashKeys( return a == b; } +std::ostream& operator<< (std::ostream &os, Bu::FString &val ) +{ + os.write( val.getStr(), val.getSize() ); + return os; +} + diff --git a/src/fstring.h b/src/fstring.h index bf6518b..1f21b5f 100644 --- a/src/fstring.h +++ b/src/fstring.h @@ -586,6 +586,20 @@ namespace Bu return -1; } + /** + * Remove nAmnt bytes from the front of the string. This function + * operates in O(n) time and should be used sparingly. + */ + void trimFront( long nAmnt ) + { + long nNewLen = nLength - nAmnt; + flatten(); + Chunk *pNew = newChunk( nNewLen ); + cpy( pNew->pData, pFirst->pData, nNewLen ); + clear(); + appendChunk( pNew ); + } + /** * Function the archiver calls to archive your FString. *@param ar (Archive) The archive which is archiving your FString. @@ -882,4 +896,7 @@ namespace Bu template<> bool __cmpHashKeys( const FString &a, const FString &b ); } +#include +std::ostream& operator<< (std::ostream &os, Bu::FString &val ); + #endif -- cgit v1.2.3