libqi-api  2.0.6.8
/home/opennao/work/master/sdk/libqi/qi/buffer.hpp
Go to the documentation of this file.
00001 #pragma once
00002 /*
00003 **  Copyright (C) 2012 Aldebaran Robotics
00004 **  See COPYING for the license
00005 */
00006 
00007 #ifndef _QI_BUFFER_HPP_
00008 #define _QI_BUFFER_HPP_
00009 
00010 # include <qi/api.hpp>
00011 # include <qi/types.hpp>
00012 # include <boost/shared_ptr.hpp>
00013 # include <vector>
00014 # include <cstddef>
00015 
00016 #ifdef _MSC_VER
00017 #  pragma warning( push )
00018 #  pragma warning( disable: 4251 )
00019 #endif
00020 
00021 namespace qi
00022 {
00023   class BufferPrivate;
00024 
00026   class QI_API Buffer
00027   {
00028   public:
00030     Buffer();
00032     Buffer(const Buffer& b);
00034     Buffer& operator = (const Buffer& b);
00035 
00037     bool write(const void *data, size_t size);
00038 
00040     size_t addSubBuffer(const Buffer& buffer);
00042     bool   hasSubBuffer(size_t offset) const;
00044     const  Buffer& subBuffer(size_t offset) const;
00045 
00047     size_t size() const;
00049     size_t totalSize() const;
00050 
00052     const std::vector<std::pair<size_t, Buffer> >& subBuffers() const;
00053 
00055     void* reserve(size_t size);
00057     void  clear();
00058 
00060     void* data();
00062     const void* data() const;
00063 
00065     const void* read(size_t offset = 0, size_t length = 0) const;
00067     size_t read(void* buffer, size_t offset = 0, size_t length = 0) const;
00068 
00069   private:
00070     friend class BufferReader;
00071     // CS4251
00072     boost::shared_ptr<BufferPrivate> _p;
00073   };
00074 
00075   namespace details {
00076     QI_API void printBuffer(std::ostream& stream, const Buffer& buffer);
00077   }
00078 }
00079 
00080 #ifdef _MSC_VER
00081 #  pragma warning( pop )
00082 #endif
00083 
00084 #endif  // _QI_BUFFER_HPP_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines