28 #ifndef ROSCPP_SERIALIZATION_H 29 #define ROSCPP_SERIALIZATION_H 53 #define ROS_NEW_SERIALIZATION_API 1 72 #define ROS_DECLARE_ALLINONE_SERIALIZER \ 73 template<typename Stream, typename T> \ 74 inline static void write(Stream& stream, const T& t) \ 76 allInOne<Stream, const T&>(stream, t); \ 79 template<typename Stream, typename T> \ 80 inline static void read(Stream& stream, T& t) \ 82 allInOne<Stream, T&>(stream, t); \ 85 template<typename T> \ 86 inline static uint32_t serializedLength(const T& t) \ 89 allInOne<LStream, const T&>(stream, t); \ 90 return stream.getLength(); \ 95 namespace serialization
97 namespace mt = message_traits;
123 template<
typename Stream>
126 t.serialize(stream.
getData(), 0);
132 template<
typename Stream>
135 t.deserialize(stream.
getData());
143 return t.serializationLength();
150 template<
typename T,
typename Stream>
159 template<
typename T,
typename Stream>
174 #define ROS_CREATE_SIMPLE_SERIALIZER(Type) \ 175 template<> struct Serializer<Type> \ 177 template<typename Stream> inline static void write(Stream& stream, const Type v) \ 179 *reinterpret_cast<Type*>(stream.advance(sizeof(v))) = v; \ 182 template<typename Stream> inline static void read(Stream& stream, Type& v) \ 184 v = *reinterpret_cast<Type*>(stream.advance(sizeof(v))); \ 187 inline static uint32_t serializedLength(const Type&) \ 189 return sizeof(Type); \ 193 #define ROS_CREATE_SIMPLE_SERIALIZER_ARM(Type) \ 194 template<> struct Serializer<Type> \ 196 template<typename Stream> inline static void write(Stream& stream, const Type v) \ 198 memcpy(stream.advance(sizeof(v)), &v, sizeof(v) ); \ 201 template<typename Stream> inline static void read(Stream& stream, Type& v) \ 203 memcpy(&v, stream.advance(sizeof(v)), sizeof(v) ); \ 206 inline static uint32_t serializedLength(const Type&) \ 208 return sizeof(Type); \ 212 #if defined(__arm__) || defined(__arm) 244 #if defined(__arm__) || defined(__arm) 254 #if defined(__arm__) || defined(__arm) 255 memcpy(&b, stream.
advance(1), 1 );
271 template<
class ContainerAllocator>
272 struct Serializer<
std::basic_string<char, std::char_traits<char>, ContainerAllocator> >
274 typedef std::basic_string<char, std::char_traits<char>, ContainerAllocator>
StringType;
276 template<
typename Stream>
279 size_t len = str.size();
288 template<
typename Stream>
295 str = StringType((
char*)stream.
advance(len),
len);
315 template<
typename Stream>
322 template<
typename Stream>
341 template<
typename Stream>
348 template<
typename Stream>
364 template<
typename T,
class ContainerAllocator,
class Enabled =
void>
371 template<
typename T,
class ContainerAllocator>
374 typedef std::vector<T, typename ContainerAllocator::template rebind<T>::other>
VecType;
378 template<
typename Stream>
382 ConstIteratorType
it = v.begin();
383 ConstIteratorType
end = v.end();
384 for (; it !=
end; ++
it)
390 template<
typename Stream>
396 IteratorType
it = v.begin();
397 IteratorType
end = v.end();
398 for (; it !=
end; ++
it)
407 ConstIteratorType
it = v.begin();
408 ConstIteratorType
end = v.end();
409 for (; it !=
end; ++
it)
421 template<
typename T,
class ContainerAllocator>
424 typedef std::vector<T, typename ContainerAllocator::template rebind<T>::other>
VecType;
428 template<
typename Stream>
436 memcpy(stream.
advance(data_len), &v.front(), data_len);
440 template<
typename Stream>
450 memcpy(&v.front(), stream.
advance(data_len), data_len);
463 template<
typename T,
class ContainerAllocator>
466 typedef std::vector<T, typename ContainerAllocator::template rebind<T>::other>
VecType;
470 template<
typename Stream>
474 ConstIteratorType
it = v.begin();
475 ConstIteratorType
end = v.end();
476 for (; it !=
end; ++
it)
482 template<
typename Stream>
488 IteratorType
it = v.begin();
489 IteratorType
end = v.end();
490 for (; it !=
end; ++
it)
502 size += len_each * (
uint32_t)v.size();
512 template<
typename T,
class ContainerAllocator,
typename Stream>
521 template<
typename T,
class ContainerAllocator,
typename Stream>
530 template<
typename T,
class ContainerAllocator>
539 template<
typename T,
size_t N,
class Enabled =
void>
546 template<
typename T,
size_t N>
553 template<
typename Stream>
556 ConstIteratorType
it = v.begin();
557 ConstIteratorType
end = v.end();
558 for (; it !=
end; ++
it)
564 template<
typename Stream>
567 IteratorType
it = v.begin();
568 IteratorType
end = v.end();
569 for (; it !=
end; ++
it)
578 ConstIteratorType
it = v.begin();
579 ConstIteratorType
end = v.end();
580 for (; it !=
end; ++
it)
592 template<
typename T,
size_t N>
599 template<
typename Stream>
603 memcpy(stream.
advance(data_len), &v.front(), data_len);
606 template<
typename Stream>
610 memcpy(&v.front(), stream.
advance(data_len), data_len);
615 return N *
sizeof(
T);
622 template<
typename T,
size_t N>
629 template<
typename Stream>
632 ConstIteratorType
it = v.begin();
633 ConstIteratorType
end = v.end();
634 for (; it !=
end; ++
it)
640 template<
typename Stream>
643 IteratorType
it = v.begin();
644 IteratorType
end = v.end();
645 for (; it !=
end; ++
it)
660 template<
typename T,
size_t N,
typename Stream>
669 template<
typename T,
size_t N,
typename Stream>
678 template<
typename T,
size_t N>
687 namespace stream_types
733 , end_(_data + _count)
926 #endif // ROSCPP_SERIALIZATION_H
GLenum GLuint GLenum GLsizei const GLchar * message
static uint32_t serializedLength(bool)
ArrayType::iterator IteratorType
ROS_FORCE_INLINE void next(T &t)
Deserialize an item from this input stream.
GLboolean GLboolean GLboolean b
static uint32_t serializedLength(const rs2rosinternal::Duration &)
static uint32_t serializedLength(const VecType &v)
void serialize(Stream &stream, const T &t)
Serialize an object. Stream here should normally be a rs2rosinternal::serialization::OStream.
static void read(Stream &stream, VecType &v)
called by the SubscriptionCallbackHelper after a message is instantiated but before that message is d...
std::shared_ptr< std::map< std::string, std::string > > connection_header
BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE.
SerializedMessage serializeServiceResponse(bool ok, const M &message)
Serialize a service response.
static void write(Stream &stream, const VecType &v)
static void read(Stream &stream, rs2rosinternal::Duration &v)
stream_types::StreamType StreamType
boost::detail::ct_imp< T,::std::is_pointer< T >::value,::std::is_arithmetic< T >::value,::std::is_enum< T >::value >::param_type param_type
Vector serializer. Default implementation does nothing.
VecType::const_iterator ConstIteratorType
Array serializer, default implementation does nothing.
ArrayType::const_iterator ConstIteratorType
uint32_t getLength()
Returns the amount of space left in the stream.
static uint32_t serializedLength(const ArrayType &v)
std::basic_string< char, std::char_traits< char >, ContainerAllocator > StringType
GLsizei const GLchar *const * string
ArrayType::iterator IteratorType
static void write(Stream &stream, const VecType &v)
static void notify(const PreDeserializeParams< M > &)
static void read(Stream &stream, ArrayType &v)
static void write(Stream &stream, const StringType &str)
std::array< T, N > ArrayType
static void write(Stream &stream, const bool v)
static void read(Stream &stream, ArrayType &v)
static void write(Stream &stream, const rs2rosinternal::Duration &v)
ROSCPP_SERIALIZATION_DECL void throwStreamOverrun()
static void read(Stream &stream, rs2rosinternal::Time &v)
Duration representation for use with the Time class.
Stream base-class, provides common functionality for IStream and OStream.
static uint32_t serializedLength(const VecType &v)
void deserialize(Stream &stream, T &t)
Deserialize an object. Stream here should normally be a rs2rosinternal::serialization::IStream.
VecType::iterator IteratorType
#define ROS_CREATE_SIMPLE_SERIALIZER(Type)
static uint32_t serializedLength(const ArrayType &v)
std::vector< uint8_t > buf
static uint32_t serializedLength(typename boost::call_traits< T >::param_type t)
Determine the serialized length of an object.
std::vector< T, typename ContainerAllocator::template rebind< T >::other > VecType
ROS_FORCE_INLINE uint32_t advance(uint32_t len)
increment the length by len
Base class for all exceptions thrown by ROS.
ROS_FORCE_INLINE OStream & operator<<(const T &t)
ArrayType::const_iterator ConstIteratorType
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 rs2rosinternal::serializa...
#define ROSCPP_SERIALIZATION_DECL
OStream(uint8_t *data, uint32_t count)
static void read(Stream &stream, bool &v)
ArrayType::iterator IteratorType
Time representation. May either represent wall clock time or ROS clock time.
IStream(uint8_t *data, uint32_t count)
unsigned __int64 uint64_t
VecType::const_iterator ConstIteratorType
uint32_t serializationLength(const T &t)
Determine the serialized length of an object.
ROS_FORCE_INLINE void next(const T &t)
Add the length of an item to this length stream.
std::vector< T, typename ContainerAllocator::template rebind< T >::other > VecType
static void write(Stream &stream, const ArrayType &v)
VecType::const_iterator ConstIteratorType
VecType::iterator IteratorType
static uint32_t serializedLength(const rs2rosinternal::Time &)
ROS_FORCE_INLINE void next(const T &t)
Serialize an item to this output stream.
SerializedMessage serializeMessage(const M &message)
Serialize a message.
static uint32_t serializedLength(const StringType &str)
std::array< T, N > ArrayType
static void read(Stream &stream, ArrayType &v)
Stream(uint8_t *_data, uint32_t _count)
static void write(Stream &stream, const VecType &v)
static void write(Stream &stream, const ArrayType &v)
std::array< T, N > ArrayType
VecType::iterator IteratorType
std::shared_ptr< M > message
#define ROS_CREATE_SIMPLE_SERIALIZER_ARM(Type)
static void read(Stream &stream, VecType &v)
static uint32_t serializedLength(const VecType &v)
static void write(Stream &stream, const rs2rosinternal::Time &v)
static void write(Stream &stream, const ArrayType &v)
static void read(Stream &stream, VecType &v)
uint32_t getLength()
Get the total length of this tream.
ArrayType::const_iterator ConstIteratorType
Templated serialization class. Default implementation provides backwards compatibility with old messa...
StreamOverrunException(const std::string &what)
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...
static uint32_t serializedLength(const ArrayType &)
void deserializeMessage(const SerializedMessage &m, M &message)
Deserialize a message. If includes_length is true, skips the first 4 bytes.
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 rs2rosinternal::serializ...
std::vector< T, typename ContainerAllocator::template rebind< T >::other > VecType
ROS_FORCE_INLINE IStream & operator>>(T &t)
static void read(Stream &stream, StringType &str)