41 #include <boost/python.hpp>
44 #include <type_traits>
48 namespace py_bindings_tools
51 class ByteString :
public boost::python::object
55 BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(
ByteString, boost::python::object)
74 template <typename T, typename std::enable_if<ros::message_traits::IsMessage<T>::value,
int>::type = 0>
80 PyBytes_GET_SIZE(ptr()));
88 static_assert(
sizeof(uint8_t) ==
sizeof(
char),
"ros/python buffer layout mismatch");
93 throw std::runtime_error(
"Underlying python object is not a Bytes/String instance");
102 template <
typename T>
105 return ByteString(msg);
109 template <
typename T>
112 data.deserialize(msg);
126 struct object_manager_traits<
moveit::py_bindings_tools::ByteString>
127 #if PY_VERSION_HEX >= 0x03000000
128 : pytype_object_manager_traits<&PyBytes_Type, moveit::py_bindings_tools::ByteString>
130 : pytype_object_manager_traits<&PyString_Type, moveit::py_bindings_tools::ByteString>