llbufferstream.h

Go to the documentation of this file.
00001 
00034 #ifndef LL_LLBUFFERSTREAM_H
00035 #define LL_LLBUFFERSTREAM_H
00036 
00037 #include <iosfwd>
00038 #include <iostream>
00039 #include "llbuffer.h"
00040 
00047 class LLBufferStreamBuf : public std::streambuf
00048 {
00049 public:
00050         LLBufferStreamBuf(
00051                 const LLChannelDescriptors& channels,
00052                 LLBufferArray* buffer);
00053         virtual ~LLBufferStreamBuf();
00054 
00055 protected:
00056 #if( LL_WINDOWS || __GNUC__ > 2 )
00057         typedef std::streambuf::pos_type pos_type;
00058         typedef std::streambuf::off_type off_type;
00059 #endif
00060 
00061         /* @name streambuf vrtual implementations
00062          */
00064         /*
00065          * @brief called when we hit the end of input
00066          *
00067          * @return Returns the character at the current position or EOF.
00068          */
00069         virtual int underflow();
00070 
00071         /*
00072          * @brief called when we hit the end of output
00073          *
00074          * @param c The character to store at the current put position
00075          * @return Returns EOF if the function failed. Any other value on success.
00076          */
00077         virtual int overflow(int c);
00078 
00079         /*
00080          * @brief synchronize the buffer
00081          *
00082          * @return Returns 0 on success or -1 on failure.
00083          */
00084         virtual int sync();
00085 
00086         /*
00087          * @brief Seek to an offset position in a stream.
00088          *
00089          * @param off Offset value relative to way paramter
00090          * @param way The seek direction. One of ios::beg, ios::cur, and ios::end.
00091          * @param which Which pointer to modify. One of ios::in, ios::out,
00092          * or both masked together.
00093          * @return Returns the new position or an invalid position on failure.
00094          */
00095 #if( LL_WINDOWS || __GNUC__ > 2)
00096         virtual pos_type seekoff(
00097                 off_type off,
00098                 std::ios::seekdir way,
00099                 std::ios::openmode which);
00100 #else
00101         virtual streampos seekoff(
00102                 streamoff off,
00103                 std::ios::seekdir way,
00104                 std::ios::openmode which);
00105 #endif
00106 
00107         /*
00108          * @brief Get s sequence of characters from the input
00109          *
00110          * @param dst Pointer to a block of memory to accept the characters
00111          * @param length Number of characters to be read
00112          * @return Returns the number of characters read
00113          */
00114         //virtual streamsize xsgetn(char* dst, streamsize length);
00115 
00116         /*
00117          * @brief Write some characters to output
00118          *
00119          * @param src Pointer to a sequence of characters to be output
00120          * @param length Number of characters to be put
00121          * @return Returns the number of characters written
00122          */
00123         //virtual streamsize xsputn(char* src, streamsize length);
00125 
00126 protected:
00127         // This channels we are working on.
00128         LLChannelDescriptors mChannels;
00129 
00130         // The buffer we work on
00131         LLBufferArray* mBuffer;
00132 };
00133 
00134 
00144 class LLBufferStream : public std::iostream
00145 {
00146 public:
00147         LLBufferStream(
00148                 const LLChannelDescriptors& channels,
00149                 LLBufferArray* buffer);
00150         ~LLBufferStream();
00151 
00152 protected:
00153         LLBufferStreamBuf mStreamBuf;
00154 };
00155 
00156 
00157 #endif // LL_LLBUFFERSTREAM_H

Generated on Thu Jul 1 06:08:20 2010 for Second Life Viewer by  doxygen 1.4.7