serialization.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009, Willow Garage, Inc.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  * * Redistributions of source code must retain the above copyright notice,
7  * this list of conditions and the following disclaimer.
8  * * Redistributions in binary form must reproduce the above copyright
9  * notice, this list of conditions and the following disclaimer in the
10  * documentation and/or other materials provided with the distribution.
11  * * Neither the names of Willow Garage, Inc. nor the names of its
12  * contributors may be used to endorse or promote products derived from
13  * this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  * POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #ifndef ROSCPP_SERIALIZATION_H
29 #define ROSCPP_SERIALIZATION_H
30 
32 
33 #include <ros/types.h>
34 #include <ros/time.h>
35 
36 #include "serialized_message.h"
37 #include "ros/message_traits.h"
39 #include "ros/exception.h"
40 #include "ros/datatypes.h"
41 
42 #include <vector>
43 #include <map>
44 #include <memory>
45 
46 #include <boost/array.hpp>
47 #include <boost/call_traits.hpp>
48 #include <boost/utility/enable_if.hpp>
49 #include <boost/mpl/and.hpp>
50 #include <boost/mpl/or.hpp>
51 #include <boost/mpl/not.hpp>
52 
53 #include <cstring>
54 
55 #define ROS_NEW_SERIALIZATION_API 1
56 
74 #define ROS_DECLARE_ALLINONE_SERIALIZER \
75  template<typename Stream, typename T> \
76  inline static void write(Stream& stream, const T& t) \
77  { \
78  allInOne<Stream, const T&>(stream, t); \
79  } \
80  \
81  template<typename Stream, typename T> \
82  inline static void read(Stream& stream, T& t) \
83  { \
84  allInOne<Stream, T&>(stream, t); \
85  } \
86  \
87  template<typename T> \
88  inline static uint32_t serializedLength(const T& t) \
89  { \
90  LStream stream; \
91  allInOne<LStream, const T&>(stream, t); \
92  return stream.getLength(); \
93  }
94 
95 namespace ros
96 {
97 namespace serialization
98 {
99 namespace mt = message_traits;
100 namespace mpl = boost::mpl;
101 
103 {
104 public:
105  StreamOverrunException(const std::string& what)
106  : Exception(what)
107  {}
108 };
109 
111 
119 template<typename T>
121 {
125  template<typename Stream>
126  inline static void write(Stream& stream, typename boost::call_traits<T>::param_type t)
127  {
128  t.serialize(stream.getData(), 0);
129  }
130 
134  template<typename Stream>
135  inline static void read(Stream& stream, typename boost::call_traits<T>::reference t)
136  {
137  t.deserialize(stream.getData());
138  }
139 
143  inline static uint32_t serializedLength(typename boost::call_traits<T>::param_type t)
144  {
145  return t.serializationLength();
146  }
147 };
148 
152 template<typename T, typename Stream>
153 inline void serialize(Stream& stream, const T& t)
154 {
155  Serializer<T>::write(stream, t);
156 }
157 
161 template<typename T, typename Stream>
162 inline void deserialize(Stream& stream, T& t)
163 {
164  Serializer<T>::read(stream, t);
165 }
166 
170 template<typename T>
171 inline uint32_t serializationLength(const T& t)
172 {
174 }
175 
176 #define ROS_CREATE_SIMPLE_SERIALIZER(Type) \
177  template<> struct Serializer<Type> \
178  { \
179  template<typename Stream> inline static void write(Stream& stream, const Type v) \
180  { \
181  memcpy(stream.advance(sizeof(v)), &v, sizeof(v) ); \
182  } \
183  \
184  template<typename Stream> inline static void read(Stream& stream, Type& v) \
185  { \
186  memcpy(&v, stream.advance(sizeof(v)), sizeof(v) ); \
187  } \
188  \
189  inline static uint32_t serializedLength(const Type&) \
190  { \
191  return sizeof(Type); \
192  } \
193 };
194 
205 
206 
209 template<> struct Serializer<bool>
210 {
211  template<typename Stream> inline static void write(Stream& stream, const bool v)
212  {
213  uint8_t b = static_cast<uint8_t>(v);
214  memcpy(stream.advance(1), &b, 1 );
215  }
216 
217  template<typename Stream> inline static void read(Stream& stream, bool& v)
218  {
219  uint8_t b;
220  memcpy(&b, stream.advance(1), 1 );
221  v = static_cast<bool>(b);
222  }
223 
224  inline static uint32_t serializedLength(bool)
225  {
226  return 1;
227  }
228 };
229 
233 template<class ContainerAllocator>
234 struct Serializer<std::basic_string<char, std::char_traits<char>, ContainerAllocator> >
235 {
236  typedef std::basic_string<char, std::char_traits<char>, ContainerAllocator> StringType;
237 
238  template<typename Stream>
239  inline static void write(Stream& stream, const StringType& str)
240  {
241  size_t len = str.size();
242  stream.next(static_cast<uint32_t>(len));
243 
244  if (len > 0)
245  {
246  memcpy(stream.advance(static_cast<uint32_t>(len)), str.data(), len);
247  }
248  }
249 
250  template<typename Stream>
251  inline static void read(Stream& stream, StringType& str)
252  {
253  uint32_t len;
254  stream.next(len);
255  if (len > 0)
256  {
257  str = StringType(reinterpret_cast<char*>(stream.advance(len)), len);
258  }
259  else
260  {
261  str.clear();
262  }
263  }
264 
265  inline static uint32_t serializedLength(const StringType& str)
266  {
267  return 4 + static_cast<uint32_t>(str.size());
268  }
269 };
270 
274 template<>
276 {
277  template<typename Stream>
278  inline static void write(Stream& stream, const ros::Time& v)
279  {
280  stream.next(v.sec);
281  stream.next(v.nsec);
282  }
283 
284  template<typename Stream>
285  inline static void read(Stream& stream, ros::Time& v)
286  {
287  stream.next(v.sec);
288  stream.next(v.nsec);
289  }
290 
291  inline static uint32_t serializedLength(const ros::Time&)
292  {
293  return 8;
294  }
295 };
296 
300 template<>
302 {
303  template<typename Stream>
304  inline static void write(Stream& stream, const ros::Duration& v)
305  {
306  stream.next(v.sec);
307  stream.next(v.nsec);
308  }
309 
310  template<typename Stream>
311  inline static void read(Stream& stream, ros::Duration& v)
312  {
313  stream.next(v.sec);
314  stream.next(v.nsec);
315  }
316 
317  inline static uint32_t serializedLength(const ros::Duration&)
318  {
319  return 8;
320  }
321 };
322 
326 template<typename T, class ContainerAllocator, class Enabled = void>
328 {};
329 
333 template<typename T, class ContainerAllocator>
334 struct VectorSerializer<T, ContainerAllocator, typename boost::disable_if<mt::IsFixedSize<T> >::type >
335 {
336  typedef std::vector<T, typename std::allocator_traits<ContainerAllocator>::template rebind_alloc<T>> VecType;
337  typedef typename VecType::iterator IteratorType;
338  typedef typename VecType::const_iterator ConstIteratorType;
339 
340  template<typename Stream>
341  inline static void write(Stream& stream, const VecType& v)
342  {
343  stream.next(static_cast<uint32_t>(v.size()));
344  ConstIteratorType it = v.begin();
345  ConstIteratorType end = v.end();
346  for (; it != end; ++it)
347  {
348  stream.next(*it);
349  }
350  }
351 
352  template<typename Stream>
353  inline static void read(Stream& stream, VecType& v)
354  {
355  uint32_t len;
356  stream.next(len);
357  v.resize(len);
358  IteratorType it = v.begin();
359  IteratorType end = v.end();
360  for (; it != end; ++it)
361  {
362  stream.next(*it);
363  }
364  }
365 
366  inline static uint32_t serializedLength(const VecType& v)
367  {
368  uint32_t size = 4;
369  ConstIteratorType it = v.begin();
370  ConstIteratorType end = v.end();
371  for (; it != end; ++it)
372  {
373  size += serializationLength(*it);
374  }
375 
376  return size;
377  }
378 };
379 
383 template<typename T, class ContainerAllocator>
384 struct VectorSerializer<T, ContainerAllocator, typename boost::enable_if<mt::IsSimple<T> >::type >
385 {
386  typedef std::vector<T, typename std::allocator_traits<ContainerAllocator>::template rebind_alloc<T>> VecType;
387  typedef typename VecType::iterator IteratorType;
388  typedef typename VecType::const_iterator ConstIteratorType;
389 
390  template<typename Stream>
391  inline static void write(Stream& stream, const VecType& v)
392  {
393  uint32_t len = static_cast<uint32_t>(v.size());
394  stream.next(len);
395  if (!v.empty())
396  {
397  const uint32_t data_len = len * static_cast<uint32_t>(sizeof(T));
398  memcpy(stream.advance(data_len), &v.front(), data_len);
399  }
400  }
401 
402  template<typename Stream>
403  inline static void read(Stream& stream, VecType& v)
404  {
405  uint32_t len;
406  stream.next(len);
407  v.resize(len);
408 
409  if (len > 0)
410  {
411  const uint32_t data_len = static_cast<uint32_t>(sizeof(T)) * len;
412  memcpy(static_cast<void*>(&v.front()), stream.advance(data_len), data_len);
413  }
414  }
415 
416  inline static uint32_t serializedLength(const VecType& v)
417  {
418  return 4 + v.size() * static_cast<uint32_t>(sizeof(T));
419  }
420 };
421 
425 template<typename T, class ContainerAllocator>
426 struct VectorSerializer<T, ContainerAllocator, typename boost::enable_if<mpl::and_<mt::IsFixedSize<T>, mpl::not_<mt::IsSimple<T> > > >::type >
427 {
428  typedef std::vector<T, typename std::allocator_traits<ContainerAllocator>::template rebind_alloc<T>> VecType;
429  typedef typename VecType::iterator IteratorType;
430  typedef typename VecType::const_iterator ConstIteratorType;
431 
432  template<typename Stream>
433  inline static void write(Stream& stream, const VecType& v)
434  {
435  stream.next(static_cast<uint32_t>(v.size()));
436  ConstIteratorType it = v.begin();
437  ConstIteratorType end = v.end();
438  for (; it != end; ++it)
439  {
440  stream.next(*it);
441  }
442  }
443 
444  template<typename Stream>
445  inline static void read(Stream& stream, VecType& v)
446  {
447  uint32_t len;
448  stream.next(len);
449  v.resize(len);
450  IteratorType it = v.begin();
451  IteratorType end = v.end();
452  for (; it != end; ++it)
453  {
454  stream.next(*it);
455  }
456  }
457 
458  inline static uint32_t serializedLength(const VecType& v)
459  {
460  uint32_t size = 4;
461  if (!v.empty())
462  {
463  uint32_t len_each = serializationLength(v.front());
464  size += len_each * static_cast<uint32_t>(v.size());
465  }
466 
467  return size;
468  }
469 };
470 
474 template<typename T, class ContainerAllocator, typename Stream>
475 inline void serialize(Stream& stream, const std::vector<T, ContainerAllocator>& t)
476 {
478 }
479 
483 template<typename T, class ContainerAllocator, typename Stream>
484 inline void deserialize(Stream& stream, std::vector<T, ContainerAllocator>& t)
485 {
487 }
488 
492 template<typename T, class ContainerAllocator>
493 inline uint32_t serializationLength(const std::vector<T, ContainerAllocator>& t)
494 {
496 }
497 
501 template<typename T, size_t N, class Enabled = void>
503 {};
504 
508 template<typename T, size_t N>
509 struct ArraySerializer<T, N, typename boost::disable_if<mt::IsFixedSize<T> >::type>
510 {
511  typedef boost::array<T, N > ArrayType;
512  typedef typename ArrayType::iterator IteratorType;
513  typedef typename ArrayType::const_iterator ConstIteratorType;
514 
515  template<typename Stream>
516  inline static void write(Stream& stream, const ArrayType& v)
517  {
518  ConstIteratorType it = v.begin();
519  ConstIteratorType end = v.end();
520  for (; it != end; ++it)
521  {
522  stream.next(*it);
523  }
524  }
525 
526  template<typename Stream>
527  inline static void read(Stream& stream, ArrayType& v)
528  {
529  IteratorType it = v.begin();
530  IteratorType end = v.end();
531  for (; it != end; ++it)
532  {
533  stream.next(*it);
534  }
535  }
536 
537  inline static uint32_t serializedLength(const ArrayType& v)
538  {
539  uint32_t size = 0;
540  ConstIteratorType it = v.begin();
541  ConstIteratorType end = v.end();
542  for (; it != end; ++it)
543  {
544  size += serializationLength(*it);
545  }
546 
547  return size;
548  }
549 };
550 
554 template<typename T, size_t N>
555 struct ArraySerializer<T, N, typename boost::enable_if<mt::IsSimple<T> >::type>
556 {
557  typedef boost::array<T, N > ArrayType;
558  typedef typename ArrayType::iterator IteratorType;
559  typedef typename ArrayType::const_iterator ConstIteratorType;
560 
561  template<typename Stream>
562  inline static void write(Stream& stream, const ArrayType& v)
563  {
564  const uint32_t data_len = N * sizeof(T);
565  memcpy(stream.advance(data_len), &v.front(), data_len);
566  }
567 
568  template<typename Stream>
569  inline static void read(Stream& stream, ArrayType& v)
570  {
571  const uint32_t data_len = N * sizeof(T);
572  memcpy(&v.front(), stream.advance(data_len), data_len);
573  }
574 
575  inline static uint32_t serializedLength(const ArrayType&)
576  {
577  return N * sizeof(T);
578  }
579 };
580 
584 template<typename T, size_t N>
585 struct ArraySerializer<T, N, typename boost::enable_if<mpl::and_<mt::IsFixedSize<T>, mpl::not_<mt::IsSimple<T> > > >::type>
586 {
587  typedef boost::array<T, N > ArrayType;
588  typedef typename ArrayType::iterator IteratorType;
589  typedef typename ArrayType::const_iterator ConstIteratorType;
590 
591  template<typename Stream>
592  inline static void write(Stream& stream, const ArrayType& v)
593  {
594  ConstIteratorType it = v.begin();
595  ConstIteratorType end = v.end();
596  for (; it != end; ++it)
597  {
598  stream.next(*it);
599  }
600  }
601 
602  template<typename Stream>
603  inline static void read(Stream& stream, ArrayType& v)
604  {
605  IteratorType it = v.begin();
606  IteratorType end = v.end();
607  for (; it != end; ++it)
608  {
609  stream.next(*it);
610  }
611  }
612 
613  inline static uint32_t serializedLength(const ArrayType& v)
614  {
615  return serializationLength(v.front()) * N;
616  }
617 };
618 
622 template<typename T, size_t N, typename Stream>
623 inline void serialize(Stream& stream, const boost::array<T, N>& t)
624 {
625  ArraySerializer<T, N>::write(stream, t);
626 }
627 
631 template<typename T, size_t N, typename Stream>
632 inline void deserialize(Stream& stream, boost::array<T, N>& t)
633 {
634  ArraySerializer<T, N>::read(stream, t);
635 }
636 
640 template<typename T, size_t N>
641 inline uint32_t serializationLength(const boost::array<T, N>& t)
642 {
644 }
645 
649 namespace stream_types
650 {
652 {
656 };
657 }
659 
664 {
665  /*
666  * \brief Returns a pointer to the current position of the stream
667  */
668  inline uint8_t* getData() { return data_; }
674  ROS_FORCE_INLINE uint8_t* advance(uint32_t len)
675  {
676  uint8_t* old_data = data_;
677  data_ += len;
678  if (data_ > end_)
679  {
680  // Throwing directly here causes a significant speed hit due to the extra code generated
681  // for the throw statement
683  }
684  return old_data;
685  }
686 
690  inline uint32_t getLength() { return static_cast<uint32_t>(end_ - data_); }
691 
692 protected:
693  Stream(uint8_t* _data, uint32_t _count)
694  : data_(_data)
695  , end_(_data + _count)
696  {}
697 
698 private:
699  uint8_t* data_;
700  uint8_t* end_;
701 };
702 
707 {
708  static const StreamType stream_type = stream_types::Input;
709 
710  IStream(uint8_t* data, uint32_t count)
711  : Stream(data, count)
712  {}
713 
717  template<typename T>
719  {
720  deserialize(*this, t);
721  }
722 
723  template<typename T>
725  {
726  deserialize(*this, t);
727  return *this;
728  }
729 };
730 
735 {
736  static const StreamType stream_type = stream_types::Output;
737 
738  OStream(uint8_t* data, uint32_t count)
739  : Stream(data, count)
740  {}
741 
745  template<typename T>
746  ROS_FORCE_INLINE void next(const T& t)
747  {
748  serialize(*this, t);
749  }
750 
751  template<typename T>
753  {
754  serialize(*this, t);
755  return *this;
756  }
757 };
758 
766 {
767  static const StreamType stream_type = stream_types::Length;
768 
770  : count_(0)
771  {}
772 
776  template<typename T>
777  ROS_FORCE_INLINE void next(const T& t)
778  {
779  count_ += serializationLength(t);
780  }
781 
785  ROS_FORCE_INLINE uint32_t advance(uint32_t len)
786  {
787  uint32_t old = count_;
788  count_ += len;
789  return old;
790  }
791 
795  inline uint32_t getLength() { return count_; }
796 
797 private:
798  uint32_t count_;
799 };
800 
804 template<typename M>
805 inline SerializedMessage serializeMessage(const M& message)
806 {
808  uint32_t len = serializationLength(message);
809  m.num_bytes = len + 4;
810  m.buf.reset(new uint8_t[m.num_bytes]);
811 
812  OStream s(m.buf.get(), static_cast<uint32_t>(m.num_bytes));
813  serialize(s, static_cast<uint32_t>(m.num_bytes) - 4);
814  m.message_start = s.getData();
815  serialize(s, message);
816 
817  return m;
818 }
819 
823 template<typename M>
824 inline SerializedMessage serializeServiceResponse(bool ok, const M& message)
825 {
827 
828  if (ok)
829  {
830  uint32_t len = serializationLength(message);
831  m.num_bytes = len + 5;
832  m.buf.reset(new uint8_t[m.num_bytes]);
833 
834  OStream s(m.buf.get(), static_cast<uint32_t>(m.num_bytes));
835  serialize(s, static_cast<uint8_t>(ok));
836  serialize(s, static_cast<uint32_t>(m.num_bytes) - 5);
837  serialize(s, message);
838  }
839  else
840  {
841  uint32_t len = serializationLength(message);
842  m.num_bytes = len + 1;
843  m.buf.reset(new uint8_t[m.num_bytes]);
844 
845  OStream s(m.buf.get(), static_cast<uint32_t>(m.num_bytes));
846  serialize(s, static_cast<uint8_t>(ok));
847  serialize(s, message);
848  }
849 
850  return m;
851 }
852 
856 template<typename M>
857 inline void deserializeMessage(const SerializedMessage& m, M& message)
858 {
859  IStream s(m.message_start, static_cast<uint32_t>(m.num_bytes - (m.message_start - m.buf.get())));
860  deserialize(s, message);
861 }
862 
863 // Additional serialization traits
864 
865 template<typename M>
867 {
870 };
871 
876 template<typename M>
878 {
879  static void notify(const PreDeserializeParams<M>&) { }
880 };
881 
882 } // namespace serialization
883 
884 } // namespace ros
885 
886 #endif // ROSCPP_SERIALIZATION_H
ros::serialization::Serializer< std::basic_string< char, std::char_traits< char >, ContainerAllocator > >::StringType
std::basic_string< char, std::char_traits< char >, ContainerAllocator > StringType
Definition: serialization.h:236
datatypes.h
ros::serialization::ArraySerializer< T, N, typename boost::disable_if< mt::IsFixedSize< T > >::type >::serializedLength
static uint32_t serializedLength(const ArrayType &v)
Definition: serialization.h:537
ros::serialization::OStream
Output stream.
Definition: serialization.h:734
ros::SerializedMessage
Definition: serialized_message.h:39
ros::SerializedMessage::message_start
uint8_t * message_start
Definition: serialized_message.h:44
ros::serialization::PreDeserializeParams
Definition: serialization.h:866
ros::serialization::VectorSerializer< T, ContainerAllocator, typename boost::disable_if< mt::IsFixedSize< T > >::type >::VecType
std::vector< T, typename std::allocator_traits< ContainerAllocator >::template rebind_alloc< T > > VecType
Definition: serialization.h:336
ros::serialization::Serializer< std::basic_string< char, std::char_traits< char >, ContainerAllocator > >::read
static void read(Stream &stream, StringType &str)
Definition: serialization.h:251
ros::serialization::Serializer::serializedLength
static uint32_t serializedLength(typename boost::call_traits< T >::param_type t)
Determine the serialized length of an object.
Definition: serialization.h:143
ros::serialization::Serializer::write
static void write(Stream &stream, typename boost::call_traits< T >::param_type t)
Write an object to the stream. Normally the stream passed in here will be a ros::serialization::OStre...
Definition: serialization.h:126
boost::shared_ptr< M >
ros::serialization::VectorSerializer< T, ContainerAllocator, typename boost::enable_if< mt::IsSimple< T > >::type >::IteratorType
VecType::iterator IteratorType
Definition: serialization.h:387
ros::serialization::Stream::end_
uint8_t * end_
Definition: serialization.h:700
ros::serialization::VectorSerializer< T, ContainerAllocator, typename boost::enable_if< mpl::and_< mt::IsFixedSize< T >, mpl::not_< mt::IsSimple< T > > > >::type >::write
static void write(Stream &stream, const VecType &v)
Definition: serialization.h:433
ros::serialization::LStream::advance
ROS_FORCE_INLINE uint32_t advance(uint32_t len)
increment the length by len
Definition: serialization.h:785
ros
ros::serialization::serializeServiceResponse
SerializedMessage serializeServiceResponse(bool ok, const M &message)
Serialize a service response.
Definition: serialization.h:824
ros::serialization::PreDeserialize::notify
static void notify(const PreDeserializeParams< M > &)
Definition: serialization.h:879
roscpp_serialization_macros.h
time.h
ros::serialization::Stream::data_
uint8_t * data_
Definition: serialization.h:699
ros::serialization::ArraySerializer< T, N, typename boost::enable_if< mt::IsSimple< T > >::type >::write
static void write(Stream &stream, const ArrayType &v)
Definition: serialization.h:562
ros::serialization::VectorSerializer
Vector serializer. Default implementation does nothing.
Definition: serialization.h:327
ros::serialization::VectorSerializer< T, ContainerAllocator, typename boost::enable_if< mpl::and_< mt::IsFixedSize< T >, mpl::not_< mt::IsSimple< T > > > >::type >::VecType
std::vector< T, typename std::allocator_traits< ContainerAllocator >::template rebind_alloc< T > > VecType
Definition: serialization.h:428
ros::serialization::ArraySerializer< T, N, typename boost::enable_if< mt::IsSimple< T > >::type >::ConstIteratorType
ArrayType::const_iterator ConstIteratorType
Definition: serialization.h:559
DurationBase< Duration >::nsec
int32_t nsec
ros::serialization::Stream
Stream base-class, provides common functionality for IStream and OStream.
Definition: serialization.h:663
builtin_message_traits.h
ros::serialization::LStream::getLength
uint32_t getLength()
Get the total length of this tream.
Definition: serialization.h:795
boost
ros::serialization::Serializer< ros::Duration >::serializedLength
static uint32_t serializedLength(const ros::Duration &)
Definition: serialization.h:317
ros::Exception
ros::serialization::Stream::advance
ROS_FORCE_INLINE uint8_t * advance(uint32_t len)
Advances the stream, checking bounds, and returns a pointer to the position before it was advanced.
Definition: serialization.h:674
ros::serialization::IStream
Input stream.
Definition: serialization.h:706
ros::serialization::ArraySerializer< T, N, typename boost::disable_if< mt::IsFixedSize< T > >::type >::IteratorType
ArrayType::iterator IteratorType
Definition: serialization.h:512
ros::serialization::LStream::count_
uint32_t count_
Definition: serialization.h:798
ros::serialization::VectorSerializer< T, ContainerAllocator, typename boost::disable_if< mt::IsFixedSize< T > >::type >::serializedLength
static uint32_t serializedLength(const VecType &v)
Definition: serialization.h:366
ros::serialization::VectorSerializer< T, ContainerAllocator, typename boost::enable_if< mt::IsSimple< T > >::type >::VecType
std::vector< T, typename std::allocator_traits< ContainerAllocator >::template rebind_alloc< T > > VecType
Definition: serialization.h:386
ros::serialization::VectorSerializer< T, ContainerAllocator, typename boost::disable_if< mt::IsFixedSize< T > >::type >::read
static void read(Stream &stream, VecType &v)
Definition: serialization.h:353
ros::serialization::ArraySerializer< T, N, typename boost::enable_if< mpl::and_< mt::IsFixedSize< T >, mpl::not_< mt::IsSimple< T > > > >::type >::ArrayType
boost::array< T, N > ArrayType
Definition: serialization.h:587
ros::serialization::Serializer< std::basic_string< char, std::char_traits< char >, ContainerAllocator > >::serializedLength
static uint32_t serializedLength(const StringType &str)
Definition: serialization.h:265
ROSCPP_SERIALIZATION_DECL
#define ROSCPP_SERIALIZATION_DECL
Definition: roscpp_serialization_macros.h:52
ros::serialization::ArraySerializer< T, N, typename boost::disable_if< mt::IsFixedSize< T > >::type >::write
static void write(Stream &stream, const ArrayType &v)
Definition: serialization.h:516
ros::serialization::VectorSerializer< T, ContainerAllocator, typename boost::enable_if< mt::IsSimple< T > >::type >::ConstIteratorType
VecType::const_iterator ConstIteratorType
Definition: serialization.h:388
ros::serialization::PreDeserialize
called by the SubscriptionCallbackHelper after a message is instantiated but before that message is d...
Definition: serialization.h:877
ros::serialization::Stream::Stream
Stream(uint8_t *_data, uint32_t _count)
Definition: serialization.h:693
ros::serialization::ArraySerializer< T, N, typename boost::enable_if< mt::IsSimple< T > >::type >::IteratorType
ArrayType::iterator IteratorType
Definition: serialization.h:558
ros::serialization::VectorSerializer< T, ContainerAllocator, typename boost::enable_if< mpl::and_< mt::IsFixedSize< T >, mpl::not_< mt::IsSimple< T > > > >::type >::read
static void read(Stream &stream, VecType &v)
Definition: serialization.h:445
serialized_message.h
message_traits.h
ros::serialization::VectorSerializer< T, ContainerAllocator, typename boost::disable_if< mt::IsFixedSize< T > >::type >::ConstIteratorType
VecType::const_iterator ConstIteratorType
Definition: serialization.h:338
ros::serialization::VectorSerializer< T, ContainerAllocator, typename boost::enable_if< mpl::and_< mt::IsFixedSize< T >, mpl::not_< mt::IsSimple< T > > > >::type >::ConstIteratorType
VecType::const_iterator ConstIteratorType
Definition: serialization.h:430
ros::serialization::Serializer< std::basic_string< char, std::char_traits< char >, ContainerAllocator > >::write
static void write(Stream &stream, const StringType &str)
Definition: serialization.h:239
ros::serialization::stream_types::StreamType
StreamType
Definition: serialization.h:651
ros::serialization::Serializer< bool >::write
static void write(Stream &stream, const bool v)
Definition: serialization.h:211
ros::serialization::StreamType
stream_types::StreamType StreamType
Definition: serialization.h:658
ros::serialization::ArraySerializer
Array serializer, default implementation does nothing.
Definition: serialization.h:502
ros::serialization::IStream::operator>>
ROS_FORCE_INLINE IStream & operator>>(T &t)
Definition: serialization.h:724
ros::serialization::VectorSerializer< T, ContainerAllocator, typename boost::enable_if< mt::IsSimple< T > >::type >::write
static void write(Stream &stream, const VecType &v)
Definition: serialization.h:391
ros::serialization::VectorSerializer< T, ContainerAllocator, typename boost::disable_if< mt::IsFixedSize< T > >::type >::IteratorType
VecType::iterator IteratorType
Definition: serialization.h:337
ros::serialization::VectorSerializer< T, ContainerAllocator, typename boost::enable_if< mt::IsSimple< T > >::type >::serializedLength
static uint32_t serializedLength(const VecType &v)
Definition: serialization.h:416
ros::serialization::StreamOverrunException::StreamOverrunException
StreamOverrunException(const std::string &what)
Definition: serialization.h:105
ros::serialization::PreDeserializeParams::message
boost::shared_ptr< M > message
Definition: serialization.h:868
ros::serialization::Serializer< ros::Duration >::read
static void read(Stream &stream, ros::Duration &v)
Definition: serialization.h:311
ros::serialization::IStream::next
ROS_FORCE_INLINE void next(T &t)
Deserialize an item from this input stream.
Definition: serialization.h:718
ros::serialization::ArraySerializer< T, N, typename boost::enable_if< mt::IsSimple< T > >::type >::ArrayType
boost::array< T, N > ArrayType
Definition: serialization.h:557
ros::serialization::LStream::LStream
LStream()
Definition: serialization.h:769
ros::serialization::Serializer< bool >::read
static void read(Stream &stream, bool &v)
Definition: serialization.h:217
ros::serialization::OStream::OStream
OStream(uint8_t *data, uint32_t count)
Definition: serialization.h:738
ros::SerializedMessage::num_bytes
size_t num_bytes
Definition: serialized_message.h:43
ros::serialization::ArraySerializer< T, N, typename boost::enable_if< mpl::and_< mt::IsFixedSize< T >, mpl::not_< mt::IsSimple< T > > > >::type >::ConstIteratorType
ArrayType::const_iterator ConstIteratorType
Definition: serialization.h:589
TimeBase< Time, Duration >::sec
uint32_t sec
ros::serialization::ArraySerializer< T, N, typename boost::enable_if< mt::IsSimple< T > >::type >::serializedLength
static uint32_t serializedLength(const ArrayType &)
Definition: serialization.h:575
TimeBase< Time, Duration >::nsec
uint32_t nsec
ros::serialization::Serializer::read
static void read(Stream &stream, typename boost::call_traits< T >::reference t)
Read an object from the stream. Normally the stream passed in here will be a ros::serialization::IStr...
Definition: serialization.h:135
ros::serialization::deserialize
void deserialize(Stream &stream, T &t)
Deserialize an object. Stream here should normally be a ros::serialization::IStream.
Definition: serialization.h:162
ros::serialization::LStream
Length stream.
Definition: serialization.h:765
ros::serialization::serialize
void serialize(Stream &stream, const T &t)
Serialize an object. Stream here should normally be a ros::serialization::OStream.
Definition: serialization.h:153
ros::serialization::StreamOverrunException
Definition: serialization.h:102
ros::serialization::OStream::next
ROS_FORCE_INLINE void next(const T &t)
Serialize an item to this output stream.
Definition: serialization.h:746
ros::serialization::Serializer< ros::Time >::serializedLength
static uint32_t serializedLength(const ros::Time &)
Definition: serialization.h:291
ros::serialization::PreDeserializeParams::connection_header
boost::shared_ptr< std::map< std::string, std::string > > connection_header
Definition: serialization.h:869
ros::serialization::LStream::next
ROS_FORCE_INLINE void next(const T &t)
Add the length of an item to this length stream.
Definition: serialization.h:777
ros::Time
ros::serialization::Stream::getLength
uint32_t getLength()
Returns the amount of space left in the stream.
Definition: serialization.h:690
ros::serialization::Serializer< bool >::serializedLength
static uint32_t serializedLength(bool)
Definition: serialization.h:224
ros::serialization::Serializer< ros::Duration >::write
static void write(Stream &stream, const ros::Duration &v)
Definition: serialization.h:304
std
ros::serialization::stream_types::Input
@ Input
Definition: serialization.h:653
ros::serialization::ArraySerializer< T, N, typename boost::disable_if< mt::IsFixedSize< T > >::type >::ConstIteratorType
ArrayType::const_iterator ConstIteratorType
Definition: serialization.h:513
ros::serialization::ArraySerializer< T, N, typename boost::enable_if< mt::IsSimple< T > >::type >::read
static void read(Stream &stream, ArrayType &v)
Definition: serialization.h:569
ros::serialization::ArraySerializer< T, N, typename boost::disable_if< mt::IsFixedSize< T > >::type >::ArrayType
boost::array< T, N > ArrayType
Definition: serialization.h:511
ros::serialization::ArraySerializer< T, N, typename boost::enable_if< mpl::and_< mt::IsFixedSize< T >, mpl::not_< mt::IsSimple< T > > > >::type >::IteratorType
ArrayType::iterator IteratorType
Definition: serialization.h:588
ROS_CREATE_SIMPLE_SERIALIZER
#define ROS_CREATE_SIMPLE_SERIALIZER(Type)
Definition: serialization.h:176
ros::serialization::serializeMessage
SerializedMessage serializeMessage(const M &message)
Serialize a message.
Definition: serialization.h:805
ros::serialization::stream_types::Output
@ Output
Definition: serialization.h:654
ros::serialization::VectorSerializer< T, ContainerAllocator, typename boost::disable_if< mt::IsFixedSize< T > >::type >::write
static void write(Stream &stream, const VecType &v)
Definition: serialization.h:341
ros::serialization::Serializer< ros::Time >::write
static void write(Stream &stream, const ros::Time &v)
Definition: serialization.h:278
ros::serialization::ArraySerializer< T, N, typename boost::disable_if< mt::IsFixedSize< T > >::type >::read
static void read(Stream &stream, ArrayType &v)
Definition: serialization.h:527
ros::serialization::Stream::getData
uint8_t * getData()
Definition: serialization.h:668
ros::serialization::IStream::IStream
IStream(uint8_t *data, uint32_t count)
Definition: serialization.h:710
ros::serialization::Serializer< ros::Time >::read
static void read(Stream &stream, ros::Time &v)
Definition: serialization.h:285
ros::serialization::throwStreamOverrun
ROSCPP_SERIALIZATION_DECL void throwStreamOverrun()
Definition: serialization.cpp:34
ros::serialization::ArraySerializer< T, N, typename boost::enable_if< mpl::and_< mt::IsFixedSize< T >, mpl::not_< mt::IsSimple< T > > > >::type >::read
static void read(Stream &stream, ArrayType &v)
Definition: serialization.h:603
ros::serialization::VectorSerializer< T, ContainerAllocator, typename boost::enable_if< mpl::and_< mt::IsFixedSize< T >, mpl::not_< mt::IsSimple< T > > > >::type >::serializedLength
static uint32_t serializedLength(const VecType &v)
Definition: serialization.h:458
ros::serialization::ArraySerializer< T, N, typename boost::enable_if< mpl::and_< mt::IsFixedSize< T >, mpl::not_< mt::IsSimple< T > > > >::type >::serializedLength
static uint32_t serializedLength(const ArrayType &v)
Definition: serialization.h:613
ros::serialization::VectorSerializer< T, ContainerAllocator, typename boost::enable_if< mpl::and_< mt::IsFixedSize< T >, mpl::not_< mt::IsSimple< T > > > >::type >::IteratorType
VecType::iterator IteratorType
Definition: serialization.h:429
ros::serialization::serializationLength
uint32_t serializationLength(const T &t)
Determine the serialized length of an object.
Definition: serialization.h:171
types.h
ros::serialization::stream_types::Length
@ Length
Definition: serialization.h:655
ros::serialization::OStream::operator<<
ROS_FORCE_INLINE OStream & operator<<(const T &t)
Definition: serialization.h:752
ros::Duration
ROS_FORCE_INLINE
#define ROS_FORCE_INLINE
ros::serialization::deserializeMessage
void deserializeMessage(const SerializedMessage &m, M &message)
Deserialize a message. If includes_length is true, skips the first 4 bytes.
Definition: serialization.h:857
ros::serialization::VectorSerializer< T, ContainerAllocator, typename boost::enable_if< mt::IsSimple< T > >::type >::read
static void read(Stream &stream, VecType &v)
Definition: serialization.h:403
ros::SerializedMessage::buf
boost::shared_array< uint8_t > buf
Definition: serialized_message.h:42
DurationBase< Duration >::sec
int32_t sec
ros::serialization::ArraySerializer< T, N, typename boost::enable_if< mpl::and_< mt::IsFixedSize< T >, mpl::not_< mt::IsSimple< T > > > >::type >::write
static void write(Stream &stream, const ArrayType &v)
Definition: serialization.h:592
ros::serialization::Serializer
Templated serialization class. Default implementation provides backwards compatibility with old messa...
Definition: serialization.h:120
exception.h


roscpp_serialization
Author(s): Josh Faust
autogenerated on Thu May 5 2022 02:31:37