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 
167 // Circumvent bug https://github.com/ros/roscpp_core/issues/130 which manifests only on ARM GCC 9.3
168 #if defined(__aarch64__) && __GNUC__ == 9 && __GNUC_MINOR__ == 3
169 #define ROS_SERIALIZATION_GCC_9_3_DISABLE_VECTORIZE __attribute__((optimize("no-tree-vectorize")))
170 #else
171 #define ROS_SERIALIZATION_GCC_9_3_DISABLE_VECTORIZE
172 #endif
173 
177 template<typename T>
179 {
181 }
182 
183 #define ROS_CREATE_SIMPLE_SERIALIZER(Type) \
184  template<> struct Serializer<Type> \
185  { \
186  template<typename Stream> inline static void write(Stream& stream, const Type v) \
187  { \
188  memcpy(stream.advance(sizeof(v)), &v, sizeof(v) ); \
189  } \
190  \
191  template<typename Stream> inline static void read(Stream& stream, Type& v) \
192  { \
193  memcpy(&v, stream.advance(sizeof(v)), sizeof(v) ); \
194  } \
195  \
196  inline static uint32_t serializedLength(const Type&) \
197  { \
198  return sizeof(Type); \
199  } \
200 };
201 
212 
213 
216 template<> struct Serializer<bool>
217 {
218  template<typename Stream> inline static void write(Stream& stream, const bool v)
219  {
220  uint8_t b = static_cast<uint8_t>(v);
221  memcpy(stream.advance(1), &b, 1 );
222  }
223 
224  template<typename Stream> inline static void read(Stream& stream, bool& v)
225  {
226  uint8_t b;
227  memcpy(&b, stream.advance(1), 1 );
228  v = static_cast<bool>(b);
229  }
230 
231  inline static uint32_t serializedLength(bool)
232  {
233  return 1;
234  }
235 };
236 
240 template<class ContainerAllocator>
241 struct Serializer<std::basic_string<char, std::char_traits<char>, ContainerAllocator> >
242 {
243  typedef std::basic_string<char, std::char_traits<char>, ContainerAllocator> StringType;
244 
245  template<typename Stream>
246  inline static void write(Stream& stream, const StringType& str)
247  {
248  size_t len = str.size();
249  stream.next(static_cast<uint32_t>(len));
250 
251  if (len > 0)
252  {
253  memcpy(stream.advance(static_cast<uint32_t>(len)), str.data(), len);
254  }
255  }
256 
257  template<typename Stream>
258  inline static void read(Stream& stream, StringType& str)
259  {
260  uint32_t len;
261  stream.next(len);
262  if (len > 0)
263  {
264  str = StringType(reinterpret_cast<char*>(stream.advance(len)), len);
265  }
266  else
267  {
268  str.clear();
269  }
270  }
271 
272  inline static uint32_t serializedLength(const StringType& str)
273  {
274  return 4 + static_cast<uint32_t>(str.size());
275  }
276 };
277 
281 template<>
283 {
284  template<typename Stream>
285  inline static void write(Stream& stream, const ros::Time& v)
286  {
287  stream.next(v.sec);
288  stream.next(v.nsec);
289  }
290 
291  template<typename Stream>
292  inline static void read(Stream& stream, ros::Time& v)
293  {
294  stream.next(v.sec);
295  stream.next(v.nsec);
296  }
297 
298  inline static uint32_t serializedLength(const ros::Time&)
299  {
300  return 8;
301  }
302 };
303 
307 template<>
309 {
310  template<typename Stream>
311  inline static void write(Stream& stream, const ros::Duration& v)
312  {
313  stream.next(v.sec);
314  stream.next(v.nsec);
315  }
316 
317  template<typename Stream>
318  inline static void read(Stream& stream, ros::Duration& v)
319  {
320  stream.next(v.sec);
321  stream.next(v.nsec);
322  }
323 
324  inline static uint32_t serializedLength(const ros::Duration&)
325  {
326  return 8;
327  }
328 };
329 
333 template<typename T, class ContainerAllocator, class Enabled = void>
335 {};
336 
340 template<typename T, class ContainerAllocator>
341 struct VectorSerializer<T, ContainerAllocator, typename boost::disable_if<mt::IsFixedSize<T> >::type >
342 {
343  typedef std::vector<T, typename std::allocator_traits<ContainerAllocator>::template rebind_alloc<T>> VecType;
344  typedef typename VecType::iterator IteratorType;
345  typedef typename VecType::const_iterator ConstIteratorType;
346 
347  template<typename Stream>
348  inline static void write(Stream& stream, const VecType& v)
349  {
350  stream.next(static_cast<uint32_t>(v.size()));
351  ConstIteratorType it = v.begin();
352  ConstIteratorType end = v.end();
353  for (; it != end; ++it)
354  {
355  stream.next(*it);
356  }
357  }
358 
359  template<typename Stream>
360  inline static void read(Stream& stream, VecType& v)
361  {
362  uint32_t len;
363  stream.next(len);
364  v.resize(len);
365  IteratorType it = v.begin();
366  IteratorType end = v.end();
367  for (; it != end; ++it)
368  {
369  stream.next(*it);
370  }
371  }
372 
373  inline static uint32_t serializedLength(const VecType& v)
374  {
375  uint32_t size = 4;
376  ConstIteratorType it = v.begin();
377  ConstIteratorType end = v.end();
378  for (; it != end; ++it)
379  {
380  size += serializationLength(*it);
381  }
382 
383  return size;
384  }
385 };
386 
390 template<typename T, class ContainerAllocator>
391 struct VectorSerializer<T, ContainerAllocator, typename boost::enable_if<mt::IsSimple<T> >::type >
392 {
393  typedef std::vector<T, typename std::allocator_traits<ContainerAllocator>::template rebind_alloc<T>> VecType;
394  typedef typename VecType::iterator IteratorType;
395  typedef typename VecType::const_iterator ConstIteratorType;
396 
397  template<typename Stream>
398  inline static void write(Stream& stream, const VecType& v)
399  {
400  uint32_t len = static_cast<uint32_t>(v.size());
401  stream.next(len);
402  if (!v.empty())
403  {
404  const uint32_t data_len = len * static_cast<uint32_t>(sizeof(T));
405  memcpy(stream.advance(data_len), &v.front(), data_len);
406  }
407  }
408 
409  template<typename Stream>
410  inline static void read(Stream& stream, VecType& v)
411  {
412  uint32_t len;
413  stream.next(len);
414  v.resize(len);
415 
416  if (len > 0)
417  {
418  const uint32_t data_len = static_cast<uint32_t>(sizeof(T)) * len;
419  memcpy(static_cast<void*>(&v.front()), stream.advance(data_len), data_len);
420  }
421  }
422 
423  inline static uint32_t serializedLength(const VecType& v)
424  {
425  return 4 + v.size() * static_cast<uint32_t>(sizeof(T));
426  }
427 };
428 
432 template<typename T, class ContainerAllocator>
433 struct VectorSerializer<T, ContainerAllocator, typename boost::enable_if<mpl::and_<mt::IsFixedSize<T>, mpl::not_<mt::IsSimple<T> > > >::type >
434 {
435  typedef std::vector<T, typename std::allocator_traits<ContainerAllocator>::template rebind_alloc<T>> VecType;
436  typedef typename VecType::iterator IteratorType;
437  typedef typename VecType::const_iterator ConstIteratorType;
438 
439  template<typename Stream>
440  inline static void write(Stream& stream, const VecType& v)
441  {
442  stream.next(static_cast<uint32_t>(v.size()));
443  ConstIteratorType it = v.begin();
444  ConstIteratorType end = v.end();
445  for (; it != end; ++it)
446  {
447  stream.next(*it);
448  }
449  }
450 
451  template<typename Stream>
452  inline static void read(Stream& stream, VecType& v)
453  {
454  uint32_t len;
455  stream.next(len);
456  v.resize(len);
457  IteratorType it = v.begin();
458  IteratorType end = v.end();
459  for (; it != end; ++it)
460  {
461  stream.next(*it);
462  }
463  }
464 
465  inline static uint32_t serializedLength(const VecType& v)
466  {
467  uint32_t size = 4;
468  if (!v.empty())
469  {
470  uint32_t len_each = serializationLength(v.front());
471  size += len_each * static_cast<uint32_t>(v.size());
472  }
473 
474  return size;
475  }
476 };
477 
481 template<typename T, class ContainerAllocator, typename Stream>
482 inline void serialize(Stream& stream, const std::vector<T, ContainerAllocator>& t)
483 {
485 }
486 
490 template<typename T, class ContainerAllocator, typename Stream>
491 inline void deserialize(Stream& stream, std::vector<T, ContainerAllocator>& t)
492 {
494 }
495 
499 template<typename T, class ContainerAllocator>
500 inline uint32_t serializationLength(const std::vector<T, ContainerAllocator>& t)
501 {
503 }
504 
508 template<typename T, size_t N, class Enabled = void>
510 {};
511 
515 template<typename T, size_t N>
516 struct ArraySerializer<T, N, typename boost::disable_if<mt::IsFixedSize<T> >::type>
517 {
518  typedef boost::array<T, N > ArrayType;
519  typedef typename ArrayType::iterator IteratorType;
520  typedef typename ArrayType::const_iterator ConstIteratorType;
521 
522  template<typename Stream>
523  inline static void write(Stream& stream, const ArrayType& v)
524  {
525  ConstIteratorType it = v.begin();
526  ConstIteratorType end = v.end();
527  for (; it != end; ++it)
528  {
529  stream.next(*it);
530  }
531  }
532 
533  template<typename Stream>
534  inline static void read(Stream& stream, ArrayType& v)
535  {
536  IteratorType it = v.begin();
537  IteratorType end = v.end();
538  for (; it != end; ++it)
539  {
540  stream.next(*it);
541  }
542  }
543 
544  inline static uint32_t serializedLength(const ArrayType& v)
545  {
546  uint32_t size = 0;
547  ConstIteratorType it = v.begin();
548  ConstIteratorType end = v.end();
549  for (; it != end; ++it)
550  {
551  size += serializationLength(*it);
552  }
553 
554  return size;
555  }
556 };
557 
561 template<typename T, size_t N>
562 struct ArraySerializer<T, N, typename boost::enable_if<mt::IsSimple<T> >::type>
563 {
564  typedef boost::array<T, N > ArrayType;
565  typedef typename ArrayType::iterator IteratorType;
566  typedef typename ArrayType::const_iterator ConstIteratorType;
567 
568  template<typename Stream>
569  inline static void write(Stream& stream, const ArrayType& v)
570  {
571  const uint32_t data_len = N * sizeof(T);
572  memcpy(stream.advance(data_len), &v.front(), data_len);
573  }
574 
575  template<typename Stream>
576  inline static void read(Stream& stream, ArrayType& v)
577  {
578  const uint32_t data_len = N * sizeof(T);
579  memcpy(&v.front(), stream.advance(data_len), data_len);
580  }
581 
582  inline static uint32_t serializedLength(const ArrayType&)
583  {
584  return N * sizeof(T);
585  }
586 };
587 
591 template<typename T, size_t N>
592 struct ArraySerializer<T, N, typename boost::enable_if<mpl::and_<mt::IsFixedSize<T>, mpl::not_<mt::IsSimple<T> > > >::type>
593 {
594  typedef boost::array<T, N > ArrayType;
595  typedef typename ArrayType::iterator IteratorType;
596  typedef typename ArrayType::const_iterator ConstIteratorType;
597 
598  template<typename Stream>
599  inline static void write(Stream& stream, const ArrayType& v)
600  {
601  ConstIteratorType it = v.begin();
602  ConstIteratorType end = v.end();
603  for (; it != end; ++it)
604  {
605  stream.next(*it);
606  }
607  }
608 
609  template<typename Stream>
610  inline static void read(Stream& stream, ArrayType& v)
611  {
612  IteratorType it = v.begin();
613  IteratorType end = v.end();
614  for (; it != end; ++it)
615  {
616  stream.next(*it);
617  }
618  }
619 
620  inline static uint32_t serializedLength(const ArrayType& v)
621  {
622  return serializationLength(v.front()) * N;
623  }
624 };
625 
629 template<typename T, size_t N, typename Stream>
630 inline void serialize(Stream& stream, const boost::array<T, N>& t)
631 {
632  ArraySerializer<T, N>::write(stream, t);
633 }
634 
638 template<typename T, size_t N, typename Stream>
639 inline void deserialize(Stream& stream, boost::array<T, N>& t)
640 {
641  ArraySerializer<T, N>::read(stream, t);
642 }
643 
647 template<typename T, size_t N>
648 inline uint32_t serializationLength(const boost::array<T, N>& t)
649 {
651 }
652 
656 namespace stream_types
657 {
659 {
663 };
664 }
666 
671 {
672  /*
673  * \brief Returns a pointer to the current position of the stream
674  */
675  inline uint8_t* getData() { return data_; }
681  ROS_FORCE_INLINE uint8_t* advance(uint32_t len)
682  {
683  uint8_t* old_data = data_;
684  data_ += len;
685  if (data_ > end_)
686  {
687  // Throwing directly here causes a significant speed hit due to the extra code generated
688  // for the throw statement
690  }
691  return old_data;
692  }
693 
697  inline uint32_t getLength() { return static_cast<uint32_t>(end_ - data_); }
698 
699 protected:
700  Stream(uint8_t* _data, uint32_t _count)
701  : data_(_data)
702  , end_(_data + _count)
703  {}
704 
705 private:
706  uint8_t* data_;
707  uint8_t* end_;
708 };
709 
714 {
715  static const StreamType stream_type = stream_types::Input;
716 
717  IStream(uint8_t* data, uint32_t count)
718  : Stream(data, count)
719  {}
720 
724  template<typename T>
726  {
727  deserialize(*this, t);
728  }
729 
730  template<typename T>
732  {
733  deserialize(*this, t);
734  return *this;
735  }
736 };
737 
742 {
743  static const StreamType stream_type = stream_types::Output;
744 
745  OStream(uint8_t* data, uint32_t count)
746  : Stream(data, count)
747  {}
748 
752  template<typename T>
753  ROS_FORCE_INLINE void next(const T& t)
754  {
755  serialize(*this, t);
756  }
757 
758  template<typename T>
760  {
761  serialize(*this, t);
762  return *this;
763  }
764 };
765 
773 {
774  static const StreamType stream_type = stream_types::Length;
775 
777  : count_(0)
778  {}
779 
783  template<typename T>
784  ROS_FORCE_INLINE void next(const T& t)
785  {
786  count_ += serializationLength(t);
787  }
788 
792  ROS_FORCE_INLINE uint32_t advance(uint32_t len)
793  {
794  uint32_t old = count_;
795  count_ += len;
796  return old;
797  }
798 
802  inline uint32_t getLength() { return count_; }
803 
804 private:
805  uint32_t count_;
806 };
807 
811 template<typename M>
812 inline SerializedMessage serializeMessage(const M& message)
813 {
815  uint32_t len = serializationLength(message);
816  m.num_bytes = len + 4;
817  m.buf.reset(new uint8_t[m.num_bytes]);
818 
819  OStream s(m.buf.get(), static_cast<uint32_t>(m.num_bytes));
820  serialize(s, static_cast<uint32_t>(m.num_bytes) - 4);
821  m.message_start = s.getData();
822  serialize(s, message);
823 
824  return m;
825 }
826 
830 template<typename M>
831 inline SerializedMessage serializeServiceResponse(bool ok, const M& message)
832 {
834 
835  if (ok)
836  {
837  uint32_t len = serializationLength(message);
838  m.num_bytes = len + 5;
839  m.buf.reset(new uint8_t[m.num_bytes]);
840 
841  OStream s(m.buf.get(), static_cast<uint32_t>(m.num_bytes));
842  serialize(s, static_cast<uint8_t>(ok));
843  serialize(s, static_cast<uint32_t>(m.num_bytes) - 5);
844  serialize(s, message);
845  }
846  else
847  {
848  uint32_t len = serializationLength(message);
849  m.num_bytes = len + 1;
850  m.buf.reset(new uint8_t[m.num_bytes]);
851 
852  // The intended use for failure is serializeServiceResponse<uint32_t>(false, 0);
853  // The 0 written here as a message is read as message length in the deserialization
854  // code in ServiceServerLink::onResponseOkAndLength(). Although this is a little
855  // misuse of the API, it works.
856  OStream s(m.buf.get(), static_cast<uint32_t>(m.num_bytes));
857  serialize(s, static_cast<uint8_t>(ok));
858  serialize(s, message);
859  }
860 
861  return m;
862 }
863 
867 template<typename M>
868 inline void deserializeMessage(const SerializedMessage& m, M& message)
869 {
870  IStream s(m.message_start, static_cast<uint32_t>(m.num_bytes - (m.message_start - m.buf.get())));
871  deserialize(s, message);
872 }
873 
874 // Additional serialization traits
875 
876 template<typename M>
878 {
881 };
882 
887 template<typename M>
889 {
890  static void notify(const PreDeserializeParams<M>&) { }
891 };
892 
893 } // namespace serialization
894 
895 } // namespace ros
896 
897 #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:243
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:544
ros::serialization::OStream
Output stream.
Definition: serialization.h:741
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:877
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:343
ros::serialization::Serializer< std::basic_string< char, std::char_traits< char >, ContainerAllocator > >::read
static void read(Stream &stream, StringType &str)
Definition: serialization.h:258
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_GCC_9_3_DISABLE_VECTORIZE
#define ROS_SERIALIZATION_GCC_9_3_DISABLE_VECTORIZE
Definition: serialization.h:171
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:394
ros::serialization::Stream::end_
uint8_t * end_
Definition: serialization.h:707
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:440
ros::serialization::LStream::advance
ROS_FORCE_INLINE uint32_t advance(uint32_t len)
increment the length by len
Definition: serialization.h:792
ros
ros::serialization::serializeServiceResponse
SerializedMessage serializeServiceResponse(bool ok, const M &message)
Serialize a service response.
Definition: serialization.h:831
ros::serialization::PreDeserialize::notify
static void notify(const PreDeserializeParams< M > &)
Definition: serialization.h:890
roscpp_serialization_macros.h
time.h
ros::serialization::Stream::data_
uint8_t * data_
Definition: serialization.h:706
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:569
ros::serialization::VectorSerializer
Vector serializer. Default implementation does nothing.
Definition: serialization.h:334
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:435
ros::serialization::ArraySerializer< T, N, typename boost::enable_if< mt::IsSimple< T > >::type >::ConstIteratorType
ArrayType::const_iterator ConstIteratorType
Definition: serialization.h:566
DurationBase< Duration >::nsec
int32_t nsec
ros::serialization::Stream
Stream base-class, provides common functionality for IStream and OStream.
Definition: serialization.h:670
builtin_message_traits.h
ros::serialization::LStream::getLength
uint32_t getLength()
Get the total length of this tream.
Definition: serialization.h:802
boost
ros::serialization::Serializer< ros::Duration >::serializedLength
static uint32_t serializedLength(const ros::Duration &)
Definition: serialization.h:324
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:681
ros::serialization::IStream
Input stream.
Definition: serialization.h:713
ros::serialization::ArraySerializer< T, N, typename boost::disable_if< mt::IsFixedSize< T > >::type >::IteratorType
ArrayType::iterator IteratorType
Definition: serialization.h:519
ros::serialization::LStream::count_
uint32_t count_
Definition: serialization.h:805
ros::serialization::VectorSerializer< T, ContainerAllocator, typename boost::disable_if< mt::IsFixedSize< T > >::type >::serializedLength
static uint32_t serializedLength(const VecType &v)
Definition: serialization.h:373
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:393
ros::serialization::VectorSerializer< T, ContainerAllocator, typename boost::disable_if< mt::IsFixedSize< T > >::type >::read
static void read(Stream &stream, VecType &v)
Definition: serialization.h:360
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:594
ros::serialization::Serializer< std::basic_string< char, std::char_traits< char >, ContainerAllocator > >::serializedLength
static uint32_t serializedLength(const StringType &str)
Definition: serialization.h:272
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:523
ros::serialization::VectorSerializer< T, ContainerAllocator, typename boost::enable_if< mt::IsSimple< T > >::type >::ConstIteratorType
VecType::const_iterator ConstIteratorType
Definition: serialization.h:395
ros::serialization::PreDeserialize
called by the SubscriptionCallbackHelper after a message is instantiated but before that message is d...
Definition: serialization.h:888
ros::serialization::Stream::Stream
Stream(uint8_t *_data, uint32_t _count)
Definition: serialization.h:700
ros::serialization::ArraySerializer< T, N, typename boost::enable_if< mt::IsSimple< T > >::type >::IteratorType
ArrayType::iterator IteratorType
Definition: serialization.h:565
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:452
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:345
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:437
ros::serialization::Serializer< std::basic_string< char, std::char_traits< char >, ContainerAllocator > >::write
static void write(Stream &stream, const StringType &str)
Definition: serialization.h:246
ros::serialization::stream_types::StreamType
StreamType
Definition: serialization.h:658
ros::serialization::Serializer< bool >::write
static void write(Stream &stream, const bool v)
Definition: serialization.h:218
ros::serialization::StreamType
stream_types::StreamType StreamType
Definition: serialization.h:665
ros::serialization::ArraySerializer
Array serializer, default implementation does nothing.
Definition: serialization.h:509
ros::serialization::IStream::operator>>
ROS_FORCE_INLINE IStream & operator>>(T &t)
Definition: serialization.h:731
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:398
ros::serialization::VectorSerializer< T, ContainerAllocator, typename boost::disable_if< mt::IsFixedSize< T > >::type >::IteratorType
VecType::iterator IteratorType
Definition: serialization.h:344
ros::serialization::VectorSerializer< T, ContainerAllocator, typename boost::enable_if< mt::IsSimple< T > >::type >::serializedLength
static uint32_t serializedLength(const VecType &v)
Definition: serialization.h:423
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:879
ros::serialization::Serializer< ros::Duration >::read
static void read(Stream &stream, ros::Duration &v)
Definition: serialization.h:318
ros::serialization::IStream::next
ROS_FORCE_INLINE void next(T &t)
Deserialize an item from this input stream.
Definition: serialization.h:725
ros::serialization::ArraySerializer< T, N, typename boost::enable_if< mt::IsSimple< T > >::type >::ArrayType
boost::array< T, N > ArrayType
Definition: serialization.h:564
ros::serialization::LStream::LStream
LStream()
Definition: serialization.h:776
ros::serialization::Serializer< bool >::read
static void read(Stream &stream, bool &v)
Definition: serialization.h:224
ros::serialization::OStream::OStream
OStream(uint8_t *data, uint32_t count)
Definition: serialization.h:745
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:596
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:582
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:772
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:753
ros::serialization::Serializer< ros::Time >::serializedLength
static uint32_t serializedLength(const ros::Time &)
Definition: serialization.h:298
ros::serialization::PreDeserializeParams::connection_header
boost::shared_ptr< std::map< std::string, std::string > > connection_header
Definition: serialization.h:880
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:784
ros::Time
ros::serialization::Stream::getLength
uint32_t getLength()
Returns the amount of space left in the stream.
Definition: serialization.h:697
ros::serialization::Serializer< bool >::serializedLength
static uint32_t serializedLength(bool)
Definition: serialization.h:231
ros::serialization::Serializer< ros::Duration >::write
static void write(Stream &stream, const ros::Duration &v)
Definition: serialization.h:311
ros::serialization::serializationLength
uint32_t ROS_SERIALIZATION_GCC_9_3_DISABLE_VECTORIZE serializationLength(const T &t)
Determine the serialized length of an object.
Definition: serialization.h:178
std
ros::serialization::stream_types::Input
@ Input
Definition: serialization.h:660
ros::serialization::ArraySerializer< T, N, typename boost::disable_if< mt::IsFixedSize< T > >::type >::ConstIteratorType
ArrayType::const_iterator ConstIteratorType
Definition: serialization.h:520
ros::serialization::ArraySerializer< T, N, typename boost::enable_if< mt::IsSimple< T > >::type >::read
static void read(Stream &stream, ArrayType &v)
Definition: serialization.h:576
ros::serialization::ArraySerializer< T, N, typename boost::disable_if< mt::IsFixedSize< T > >::type >::ArrayType
boost::array< T, N > ArrayType
Definition: serialization.h:518
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:595
ROS_CREATE_SIMPLE_SERIALIZER
#define ROS_CREATE_SIMPLE_SERIALIZER(Type)
Definition: serialization.h:183
ros::serialization::serializeMessage
SerializedMessage serializeMessage(const M &message)
Serialize a message.
Definition: serialization.h:812
ros::serialization::stream_types::Output
@ Output
Definition: serialization.h:661
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:348
ros::serialization::Serializer< ros::Time >::write
static void write(Stream &stream, const ros::Time &v)
Definition: serialization.h:285
ros::serialization::ArraySerializer< T, N, typename boost::disable_if< mt::IsFixedSize< T > >::type >::read
static void read(Stream &stream, ArrayType &v)
Definition: serialization.h:534
ros::serialization::Stream::getData
uint8_t * getData()
Definition: serialization.h:675
ros::serialization::IStream::IStream
IStream(uint8_t *data, uint32_t count)
Definition: serialization.h:717
ros::serialization::Serializer< ros::Time >::read
static void read(Stream &stream, ros::Time &v)
Definition: serialization.h:292
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:610
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:465
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:620
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:436
types.h
ros::serialization::stream_types::Length
@ Length
Definition: serialization.h:662
ros::serialization::OStream::operator<<
ROS_FORCE_INLINE OStream & operator<<(const T &t)
Definition: serialization.h:759
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:868
ros::serialization::VectorSerializer< T, ContainerAllocator, typename boost::enable_if< mt::IsSimple< T > >::type >::read
static void read(Stream &stream, VecType &v)
Definition: serialization.h:410
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:599
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, Dirk Thomas
autogenerated on Sat Jun 17 2023 02:32:40