libqi-api  release-2.5.3-2016-11-18
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
binarycodec.hpp
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 _QI_TYPE_BINARYCODEC_HPP_
8 #define _QI_TYPE_BINARYCODEC_HPP_
9 
10 #include <qi/atomic.hpp>
11 
12 #include <qi/api.hpp>
13 #include <boost/function.hpp>
14 #include <qi/buffer.hpp>
15 #include <qi/anyvalue.hpp>
16 #include <qi/type/metaobject.hpp>
17 
18 namespace qi {
19 
22  {
24  : transmitMetaObject(true),
26  {}
27 
33  static const qi::uint32_t notCached = 0xFFFFFFFF;
34  };
35 
36  class StreamContext;
37 
39  using DeserializeObjectCallback = boost::function<AnyObject(const ObjectSerializationInfo&)>;
40 
42  using SerializeObjectCallback = boost::function<ObjectSerializationInfo(const AnyObject&)>;
43 
44  template <typename T>
47  StreamContext* streamContext = 0
48  );
49 
57  QI_API void encodeBinary(qi::Buffer *buf, const AutoAnyReference &gvp, SerializeObjectCallback onObject=SerializeObjectCallback(), StreamContext* ctx=0);
58 
59 
70 
71  template <typename T>
72  AnyReference decodeBinary(qi::BufferReader *buf, T* value, DeserializeObjectCallback onObject, StreamContext* ctx) {
73  return decodeBinary(buf, AnyReference::fromPtr(value), onObject, ctx);
74  }
75 }
76 
77 #endif // _QITYPE_BINARYCODEC_HPP_
AnyReference decodeBinary(qi::BufferReader *buf, T *value, DeserializeObjectCallback onObject=DeserializeObjectCallback(), StreamContext *streamContext=0)
Definition: binarycodec.hpp:72
#define QI_API
Definition: api.hpp:33
uint32_t uint32_t
Definition: types.hpp:65
boost::function< AnyObject(const ObjectSerializationInfo &)> DeserializeObjectCallback
Type of callback invoked by sdeerializer when it encounters an object.
Definition: binarycodec.hpp:39
void encodeBinary(qi::Buffer *buf, const AutoAnyReference &gvp, SerializeObjectCallback onObject=SerializeObjectCallback(), StreamContext *ctx=0)
static const qi::uint32_t notCached
Definition: binarycodec.hpp:33
dll import/export and compiler message
Informations passed when serializing an object.
Definition: binarycodec.hpp:21
boost::function< ObjectSerializationInfo(const AnyObject &)> SerializeObjectCallback
Type of callback invoked by serializer when it encounters an object.
Definition: binarycodec.hpp:42
Class to read const buffer. <includename>qi/buffer.hpp</includename> This class is intendeed to rea...
Definition: buffer.hpp:224
static AnyReference fromPtr(const T *ptr)
Class to store buffer. <includename>qi/buffer.hpp</includename> .
Definition: buffer.hpp:76
Description of the signals and methods accessible on an ObjectTypeInterface.
Definition: metaobject.hpp:25