- Aldebaran documentation |
- C++ Libraries |
- index

libqi-api 2.8.7.4

- Main Page
- Related Pages
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
buffer.hpp
Go to the documentation of this file.
1 #pragma once
2 /*
3 ** Copyright (C) 2012 Aldebaran Robotics
4 ** See COPYING for the license
5 */
6
7 #ifndef _QI_BUFFER_HPP_
8 # define _QI_BUFFER_HPP_
9
10 # include <qi/api.hpp>
11 # include <qi/types.hpp>
12 # include <boost/shared_ptr.hpp>
13 # include <vector>
14 # include <cstddef>
15
16 #ifdef _MSC_VER
17 # pragma warning( push )
18 # pragma warning( disable: 4251 )
19 #endif
20
21 namespace qi
22 {
23 class BufferPrivate;
24
76 class QI_API Buffer
77 {
78 public:
79 using size_type = qi::uint32_t;
80
82 Buffer();
83
91 Buffer(const Buffer& buffer);
98 Buffer& operator = (const Buffer& buffer);
99
105 Buffer(Buffer&& buffer);
106
112 Buffer& operator = (Buffer&& buffer);
113
120 bool write(const void *data, size_t size);
121
129 size_t addSubBuffer(const Buffer& buffer);
135 bool hasSubBuffer(size_t offset) const;
142 const Buffer& subBuffer(size_t offset) const;
143
144
150 size_t size() const;
151
157 size_t totalSize() const;
158
164 const std::vector<std::pair<size_t, Buffer> >& subBuffers() const;
165
172 void* reserve(size_t size);
176 void clear();
177
178
183 void* data();
188 const void* data() const;
189
199 const void* read(size_t offset = 0, size_t length = 0) const;
200
211 size_t read(void* buffer, size_t offset = 0, size_t length = 0) const;
212
213 bool operator==(const Buffer& b) const;
214 private:
215 friend class BufferReader;
216 // CS4251
217 boost::shared_ptr<BufferPrivate> _p;
218 };
219
227 class QI_API BufferReader
228 {
229 public:
234 explicit BufferReader(const Buffer& buf);
236 ~BufferReader();
237
244 size_t read(void *data, size_t length);
245
246
252 void *read(size_t offset);
258 bool seek(size_t offset);
266 void *peek(size_t offset) const;
267
268
273 bool hasSubBuffer() const;
279 const Buffer& subBuffer();
284 size_t position() const;
285
286 private:
287 const Buffer* _buffer;
288 size_t _cursor;
289 size_t _subCursor; // position in sub-buffers
290 };
291
292 namespace detail {
293 QI_API void printBuffer(std::ostream& stream, const Buffer& buffer);
294 }
295
296 }
297
298 #ifdef _MSC_VER
299 # pragma warning( pop )
300 #endif
301
302 #endif // _QI_BUFFER_HPP_
qi::detail::printBuffer
void printBuffer(std::ostream &stream, const Buffer &buffer)
QI_API
#define QI_API
Definition: api.hpp:33
qi::uint32_t
uint32_t uint32_t
Definition: types.hpp:65
qi::Buffer::size_type
qi::uint32_t size_type
Definition: buffer.hpp:79
api.hpp
dll import/export and compiler message
types.hpp
qi::operator==
bool operator==(const Signature &lhs, const Signature &rhs)
qi::BufferReader
Class to read const buffer. <includename>qi/buffer.hpp</includename> This class is intendeed to rea...
Definition: buffer.hpp:227
qi::Buffer
Class to store buffer. <includename>qi/buffer.hpp</includename> .
Definition: buffer.hpp:76