00001
00002
00003
00004 #ifndef AITOOLS_INVERTEDINDEX_BYTE_BUFFER_HPP
00005 #define AITOOLS_INVERTEDINDEX_BYTE_BUFFER_HPP
00006
00007 #include <iostream>
00008 #include <new>
00009
00010 namespace aitools {
00011 namespace invertedindex {
00012
00023 class ByteBuffer {
00024
00025 public:
00026
00031 ByteBuffer(size_t size = 0) throw (std::bad_alloc);
00032
00036 ByteBuffer(const ByteBuffer& buffer) throw (std::bad_alloc);
00037
00041 ~ByteBuffer();
00042
00043 public:
00044
00049 size_t capacity() const;
00050
00055 void clear();
00056
00061 char* data();
00062
00067 const char* data() const;
00068
00073 bool empty() const;
00074
00079 void free();
00080
00084 ByteBuffer& operator=(const ByteBuffer& buffer) throw (std::bad_alloc);
00085
00086 bool operator==(const ByteBuffer& buffer) const;
00087
00088 bool operator!=(const ByteBuffer& buffer) const;
00089
00094 void resize(size_t size) throw (std::bad_alloc);
00095
00100 size_t size() const;
00101
00102 private:
00103
00104 char* data_;
00105 size_t capacity_;
00106 size_t size_;
00107
00108 };
00109
00110 }
00111 }
00112
00116 namespace std {
00117
00118 ostream&
00119 operator<<(ostream& os, const aitools::invertedindex::ByteBuffer& buffer);
00120 }
00121
00122 #endif // AITOOLS_INVERTEDINDEX_BYTE_BUFFER_HPP