- 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
buffertypeinterface.hxx
Go to the documentation of this file.
1 #pragma once
2 /*
3 ** Copyright (C) 2013 Aldebaran Robotics
4 ** See COPYING for the license
5 */
6
7 #ifndef _QITYPE_DETAIL_TYPEBUFFER_HXX_
8 #define _QITYPE_DETAIL_TYPEBUFFER_HXX_
9
10 #include <qi/buffer.hpp>
11
12 namespace qi
13 {
14 class TypeBufferImpl: public RawTypeInterface
15 {
16 public:
17 std::pair<char*, size_t> get(void *storage) override
18 {
19 Buffer* b = (Buffer*)Methods::ptrFromStorage(&storage);
20
21 // TODO: sub-buffers
22 if (b->subBuffers().size() != 0)
23 qiLogError("qitype.buffertypeinterface") << "buffer has sub-buffers, Python bytearrays might be incomplete";
24
25 return std::make_pair(const_cast<char*>((const char*)b->data()), b->size());
26 }
27 void set(void** storage, const char* ptr, size_t sz) override
28 {
29 Buffer* b = (Buffer*)ptrFromStorage(storage);
30 b->clear();
31 b->write(ptr, sz);
32 }
33 using Methods = DefaultTypeImplMethods<Buffer, TypeByPointerPOD<Buffer> >;
34 _QI_BOUNCE_TYPE_METHODS(Methods);
35 };
36
37 template<> class TypeImpl<Buffer>: public TypeBufferImpl {};
38 }
39
40 #endif // _QITYPE_DETAIL_TYPEBUFFER_HXX_
qi::TypeInterface::ptrFromStorage
virtual void * ptrFromStorage(void **)=0
qi::TypeImpl
Definition: typeimpl.hxx:300
qi::Buffer::write
bool write(const void *data, size_t size)
Write data in the buffer.
qi::Buffer::subBuffers
const std::vector< std::pair< size_t, Buffer > > & subBuffers() const
Return a vector of sub-buffers of the current buffer.
qi::Buffer::data
void * data()
Return a pointer to the raw data storage of this buffer.
qi::Buffer::clear
void clear()
Erase content of buffer and remove sub-buffers whithout clearing them.
qiLogError
#define qiLogError(...)
Log in error mode.
Definition: log.hpp:120
qi::DefaultTypeImplMethods
Definition: typeimpl.hxx:228
qi::TypeBufferImpl
Definition: buffertypeinterface.hxx:14
buffer.hpp
qi::RawTypeInterface
Definition: typeinterface.hpp:127
qi::DefaultTypeImplMethods::ptrFromStorage
static void * ptrFromStorage(void **storage)
Definition: typeimpl.hxx:238
qi::TypeBufferImpl::_QI_BOUNCE_TYPE_METHODS
_QI_BOUNCE_TYPE_METHODS(Methods)
qi::Buffer::size
size_t size() const
Return the content size of this buffer not counting sub-buffers.
qi::TypeBufferImpl::set
void set(void **storage, const char *ptr, size_t sz) override
Set the buffer of data (buffer is copied)
Definition: buffertypeinterface.hxx:27
qi::Buffer
Class to store buffer. <includename>qi/buffer.hpp</includename> .
Definition: buffer.hpp:76