00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00020 #ifndef flc_file_string_H
00021 #define flc_file_string_H
00022
00023 #include <falcon/string.h>
00024 #include <falcon/stream.h>
00025
00026 namespace Falcon {
00027
00028 class FALCON_DYN_CLASS StringStream: public Stream
00029 {
00030 private:
00031 class Buffer;
00032 Buffer* m_b;
00033
00034
00035 protected:
00036 uint32 m_pos;
00037 virtual int64 seek( int64 pos, e_whence whence );
00038
00039 void setBuffer( const String &source );
00040 void setBuffer( const char* source, int size=-1 );
00041 bool detachBuffer();
00042
00043 public:
00044 StringStream( int32 size=0 );
00045 StringStream( const String &strbuf );
00046 StringStream( const StringStream &strbuf );
00047
00048 virtual ~StringStream();
00049
00050 virtual bool close();
00051 virtual int32 read( void *buffer, int32 size );
00052 virtual bool readString( String &dest, uint32 size );
00053 virtual int32 write( const void *buffer, int32 size );
00054 virtual bool writeString( const String &source, uint32 begin = 0, uint32 end = csh::npos );
00055 virtual bool put( uint32 chr );
00056 virtual bool get( uint32 &chr );
00057 virtual int32 readAvailable( int32 msecs, const Sys::SystemData *sysData = 0 );
00058 virtual int32 writeAvailable( int32 msecs, const Sys::SystemData *sysData = 0 );
00059
00060 virtual int64 tell();
00061 virtual bool truncate( int64 pos=-1 );
00062
00063 uint32 length() const;
00064 uint32 allocated() const;
00065 byte *data() const;
00066
00067 virtual bool errorDescription( ::Falcon::String &description ) const;
00068
00073 void transfer( StringStream &strbuf );
00074
00081 void getString( String &target ) const;
00082
00089 String *getString() const
00090 {
00091 String *temp = new String;
00092 getString( *temp );
00093 return temp;
00094 }
00095
00102 CoreString *getCoreString() const
00103 {
00104 CoreString *temp = new CoreString;
00105 getString( *temp );
00106 return temp;
00107 }
00108
00109
00120 String *closeToString();
00121
00126 CoreString *closeToCoreString();
00127
00134 bool closeToString( String &target );
00135
00144 byte *closeToBuffer();
00145
00146 virtual int64 lastError() const;
00147 virtual FalconData *clone() const;
00148 virtual void gcMark( uint32 mark ) {}
00149 };
00150
00151 }
00152
00153 #endif
00154
00155