8 #ifndef BOOSTER_AIO_BUFFER_H 9 #define BOOSTER_AIO_BUFFER_H 23 template<
typename Po
inter>
48 std::pair<entry const *,size_t>
get()
const 64 void add(Pointer p,
size_t s)
75 vec_.push_back(entry_);
107 for(
size_t i=0;i<vec_.size();i++)
114 std::vector<entry> vec_;
137 for(
unsigned i=0;i<data.second;i++)
138 add(data.first[i].ptr,data.first[i].size);
148 tmp.
add(reinterpret_cast<char const *>(p),n);
157 tmp.
add(reinterpret_cast<char *>(p),n);
165 return buffer(&d.front(),d.size());
172 return buffer(&d.front(),d.size());
179 return buffer(d.c_str(),d.size());
185 template<
typename Buffer>
186 Buffer advance(Buffer
const &buf,
size_t n)
189 typename Buffer::buffer_data_type data=buf.
get();
190 while(data.second > 0 && n > 0) {
191 if(data.first->size <= n) {
192 n-= data.first->size;
197 res.add(data.first->ptr + n,data.first->size - n);
203 while(data.second > 0) {
204 res.add(data.first->ptr,data.first->size);
210 template<
typename Buffer>
211 void add(Buffer &left,Buffer
const &right)
213 typename Buffer::buffer_data_type data=right.get();
214 for(
unsigned i=0;i<data.second;i++)
215 left.add(data.first[i].ptr,data.first[i].size);
228 return details::advance(buf,n);
237 return details::advance(buf,n);
244 buf = details::advance(buf,n);
252 buf = details::advance(buf,n);
261 details::add(tmp,b2);
278 details::add(tmp,b2);
A mutable buffer - a buffer for read operations.
Definition: buffer.h:120
bool empty() const
Definition: buffer.h:84
const_buffer & operator+=(const_buffer &buf, size_t n)
Definition: buffer.h:242
An immutable buffer - buffer for write operations.
Definition: buffer.h:128
This is a base class that represents a buffer - a set of contiguous chunks of memory that can be tran...
Definition: buffer.h:24
const_buffer operator+(const_buffer const &buf, size_t n)
Definition: buffer.h:226
const_buffer(mutable_buffer const &other)
Definition: buffer.h:134
buffer_impl()
Definition: buffer.h:37
std::pair< entry const *, size_t > get() const
Definition: buffer.h:48
size_t bytes_count() const
Definition: buffer.h:100
size_t size() const
Definition: buffer.h:92
Booster library namespace. The library that implements Boost Like API in ABI backward compatible way...
Definition: application.h:23
const_buffer buffer(void const *p, size_t n)
Definition: buffer.h:145
std::pair< entry const *, size_t > buffer_data_type
A pair that defined the chunk.
Definition: buffer.h:43
void add(Pointer p, size_t s)
Definition: buffer.h:64