2 #include <msp/strings/format.h>
11 void Buffer::storage(size_t sz, BufferUsage u)
16 throw incompatible_data("Buffer::storage");
20 throw invalid_argument("Buffer::storage");
28 void Buffer::data(const void *d)
30 return sub_data(0, size, d);
33 void Buffer::sub_data(size_t off, size_t sz, const void *d)
36 throw invalid_operation("Buffer::sub_data");
37 if(off>size || off+sz>size)
38 throw out_of_range("Buffer::sub_data");
40 BufferBackend::sub_data(off, sz, d);
43 void Buffer::require_size(size_t req_sz) const
46 throw buffer_too_small(format("buffer has %d bytes; %d required", size, req_sz));
51 if(!can_map() || mapped)
52 throw invalid_operation("Buffer::map");
53 void *result = BufferBackend::map();
60 if(!can_map() || !mapped)
61 throw invalid_operation("Buffer::map");
62 bool result = BufferBackend::unmap();