00001
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef _SOCKETS_CircularBuffer_H
00031 #define _SOCKETS_CircularBuffer_H
00032
00033 #include "sockets-config.h"
00034 #include <string>
00035
00036 #ifdef SOCKETS_NAMESPACE
00037 namespace SOCKETS_NAMESPACE {
00038 #endif
00039
00040
00041 class Socket;
00042
00047 class CircularBuffer
00048 {
00049 public:
00050 CircularBuffer(Socket& owner,size_t size);
00051 ~CircularBuffer();
00052
00054 bool Write(const char *p,size_t l);
00056 bool Read(char *dest,size_t l);
00058 bool Remove(size_t l);
00060 std::string ReadString(size_t l);
00061
00063 size_t GetLength();
00065 const char *GetStart();
00067 size_t GetL();
00069 size_t Space();
00070
00072 unsigned long ByteCounter(bool clear = false);
00073
00074 private:
00075 Socket& GetOwner() const;
00076 CircularBuffer(const CircularBuffer& s) : m_owner( s.GetOwner() ) {}
00077 CircularBuffer& operator=(const CircularBuffer& ) { return *this; }
00078 Socket& m_owner;
00079 char *buf;
00080 size_t m_max;
00081 size_t m_q;
00082 size_t m_b;
00083 size_t m_t;
00084 unsigned long m_count;
00085 };
00086
00087
00088 #ifdef SOCKETS_NAMESPACE
00089 }
00090 #endif
00091
00092
00093
00094 #endif // _SOCKETS_CircularBuffer_H