00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __NL_SMART_BUFFER
00024 #define __NL_SMART_BUFFER
00025
00026 #include <stdlib.h>
00027
00028 #include <netlink/core.h>
00029 #include <netlink/util.h>
00030 #include <netlink/socket.h>
00031
00032
00033 NL_NAMESPACE
00034
00035
00045 class SmartBuffer {
00046
00047 private:
00048
00049 void* _buffer;
00050 size_t _usedSize;
00051 size_t _allocSize;
00052 double _reallocRatio;
00053
00054 public:
00055
00056 SmartBuffer(size_t allocSize = DEFAULT_SMARTBUFFER_SIZE, double reallocRatio = DEFAULT_SMARTBUFFER_REALLOC_RATIO);
00057 ~SmartBuffer();
00058
00059 const void* operator*() const;
00060 const char* operator[](size_t index) const;
00061
00062 const void* buffer() const;
00063 size_t size() const;
00064
00065 void read(Socket* socket);
00066
00067 void clear();
00068 };
00069
00070 #include <netlink/smart_buffer.inline.h>
00071
00072 NL_NAMESPACE_END
00073
00074 #endif