00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00026 #ifndef LIMAL_BYTEBUFFER_HPP
00027 #define LIMAL_BYTEBUFFER_HPP
00028
00029 #include <limal/config.h>
00030 #include <blocxx/COWIntrusiveReference.hpp>
00031 #include <iostream>
00032 extern "C"
00033 {
00034 #include <sys/types.h>
00035 }
00036
00037 namespace LIMAL_NAMESPACE
00038 {
00039
00040
00041
00042
00043 class ByteBufferImpl;
00044
00045
00055 class ByteBuffer
00056 {
00057 public:
00058
00062 ByteBuffer();
00063
00072 ByteBuffer(const char *str);
00073
00082 ByteBuffer(const char *ptr, size_t len);
00083
00094 ByteBuffer(const ByteBuffer &buf);
00095
00099 ~ByteBuffer();
00100
00108 void clear();
00109
00113 bool empty() const;
00114
00120 size_t size() const;
00121
00127 const char* data() const;
00128
00136 char at(size_t pos) const;
00137
00145 void append(const char *ptr, size_t len);
00146
00153 void append(char c);
00154
00155 #ifndef SWIG
00156
00167 ByteBuffer& operator=(const ByteBuffer& buf);
00168
00178 const char& operator[](size_t pos) const;
00179
00189 char& operator[](size_t pos);
00190
00202 ByteBuffer& operator+=(const ByteBuffer& buf);
00203
00204
00205
00206
00210 friend std::ostream& operator<<(std::ostream &out,
00211 const ByteBuffer &buf);
00212
00217 friend bool operator==(const ByteBuffer &l, const ByteBuffer &r);
00218
00223 friend bool operator!=(const ByteBuffer &l, const ByteBuffer &r);
00224
00229 friend bool operator<(const ByteBuffer &l, const ByteBuffer &r);
00230
00235 friend bool operator>(const ByteBuffer &l, const ByteBuffer &r);
00236
00241 friend bool operator<=(const ByteBuffer &l, const ByteBuffer &r);
00242
00247 friend bool operator>=(const ByteBuffer &l, const ByteBuffer &r);
00248
00255 friend ByteBuffer operator+(const ByteBuffer& b1, const ByteBuffer& b2);
00256
00257 #endif
00258
00259 private:
00260 blocxx::COWIntrusiveReference<ByteBufferImpl> m_impl;
00261 };
00262
00263 }
00264 #endif // LIMAL_BYTEBUFFER_HPP