libqi-api  2.1.4.13
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 
26  class QI_API Buffer
27  {
28  public:
30  Buffer();
32  Buffer(const Buffer& b);
34  Buffer& operator = (const Buffer& b);
35 
37  bool write(const void *data, size_t size);
38 
40  size_t addSubBuffer(const Buffer& buffer);
42  bool hasSubBuffer(size_t offset) const;
44  const Buffer& subBuffer(size_t offset) const;
45 
47  size_t size() const;
49  size_t totalSize() const;
50 
52  const std::vector<std::pair<size_t, Buffer> >& subBuffers() const;
53 
55  void* reserve(size_t size);
57  void clear();
58 
60  void* data();
62  const void* data() const;
63 
65  const void* read(size_t offset = 0, size_t length = 0) const;
67  size_t read(void* buffer, size_t offset = 0, size_t length = 0) const;
68 
69  private:
70  friend class BufferReader;
71  // CS4251
72  boost::shared_ptr<BufferPrivate> _p;
73  };
74 
75  namespace details {
76  QI_API void printBuffer(std::ostream& stream, const Buffer& buffer);
77  }
78 }
79 
80 #ifdef _MSC_VER
81 # pragma warning( pop )
82 #endif
83 
84 #endif // _QI_BUFFER_HPP_
Class to read const buffer.
Class to store buffer.
Definition: buffer.hpp:26
void printBuffer(std::ostream &stream, const Buffer &buffer)
dll import/export and compiler message
#define QI_API
Definition: api.hpp:24