Sources Pipelines Documentation

Allocators  
buffer_ref.hpp
1 #pragma once
2 
3 #include <boost/memory/memory_block.hpp>
4 
5 #include <cstdio>
6 #include <string>
7 
8 
9 namespace boost { namespace memory {
10 
19 {
20 public:
26  template <typename pointer_type>
27  buffer_ref(pointer_type* data, size_t length);
28 
34  template <typename pointer_type>
35  buffer_ref(const pointer_type* data, size_t length);
36 
44  template <typename pointer_type>
45  buffer_ref(pointer_type* pointer);
46 
51  buffer_ref(const memory_block& block);
52 
57  buffer_ref(const std::string& s);
58 
64  template <typename reference_type>
65  reference_type as();
66 
72  template <typename pointer_type>
73  pointer_type as_pointer();
74 
78  size_t length() const;
79 
85  buffer_ref subbuf(size_t length) const;
86 
87 private:
88  void* data_;
89  size_t length_;
90 };
91 
92 } }
93 
94 #include "buffer_ref.ipp"
95 
size_t length() const
Number of bytes in the buffer.
Definition: buffer_ref.ipp:74
reference_type as()
Obtains a reference to the underlying memory block treating it as the given reference_type.
Definition: buffer_ref.ipp:56
A non-owning reference to a buffer.
Definition: buffer_ref.hpp:18
pointer_type as_pointer()
Obtains a reference to the underlying memory block treating it as a representation of the given point...
Definition: buffer_ref.ipp:67
buffer_ref subbuf(size_t length) const
Obtains a sub buffer with the given size.
Definition: buffer_ref.ipp:79
buffer_ref(pointer_type *data, size_t length)
Creates a reference through a pointer and length.
Definition: buffer_ref.ipp:9
Represents an allocated memory block.