00001 /* -*- mode: c++; c-basic-offset: 4; -*- */ 00002 #ifndef SENDS_BUFFER_HH 00003 #define SENDS_BUFFER_HH 00004 00005 namespace sends { 00006 00007 class buffer_pool; 00008 00016 class buffer { 00017 public: 00020 typedef unsigned long size_type; 00021 public: 00028 buffer(size_type length); 00029 00033 ~buffer(void); 00034 00039 size_type capacity(void) const; 00040 00044 void clear(void); 00045 00050 const char* data(void) const; 00051 00056 char* data(void); 00057 00061 void free(void); 00062 00068 char& operator[](size_type inx); 00069 00075 char operator[](size_type inx) const; 00076 00081 void power_clean(void); 00082 00087 void purge(void); 00088 00096 size_type push(size_type n); 00097 00105 void resize(size_type n); 00106 00115 void reserve(size_type n); 00116 00121 void set_pool(buffer_pool* pool); 00122 00127 size_type size(void) const; 00128 00129 private: 00130 buffer_pool* mFreeList; 00131 char* mData; 00132 size_type mLength; 00133 size_type mCapacity; 00134 }; 00135 00136 inline buffer::size_type 00137 buffer::capacity(void) const { 00138 return mCapacity; 00139 } 00140 00141 inline char* 00142 buffer::data(void) { 00143 return mData; 00144 } 00145 00146 inline const char* 00147 buffer::data(void) const { 00148 return mData; 00149 } 00150 00151 inline char 00152 buffer::operator[](size_type inx) const { 00153 return mData[inx]; 00154 } 00155 00156 inline char& 00157 buffer::operator[](size_type inx) { 00158 return mData[inx]; 00159 } 00160 00161 inline buffer::size_type 00162 buffer::size(void) const { 00163 return mLength; 00164 } 00165 00166 00167 } 00168 00169 #endif // !defined(SENDS_BUFFER_HH)
1.5.5