string.cpp
Go to the documentation of this file.
1 
4 /*****************************************************************************
5 ** Includes
6 *****************************************************************************/
7 
10 #include "../../include/mm_core_msgs/string.hpp"
11 #include "../../include/mm_core_msgs/test_identifiers.hpp"
12 
13 /*****************************************************************************
14 ** Namespaces
15 *****************************************************************************/
16 
17 namespace mm_messages {
18 
19 /*****************************************************************************
20 ** Implementation
21 *****************************************************************************/
22 
23 void Message<std::string>::encode(const std::string& s, ByteArray& buffer) {
24  // publishers always send empty buffers, but in case others use this
25  if(!buffer.empty()) {
26  buffer.clear();
27  }
28  buffer.insert(buffer.end(), s.begin(), s.end());
29 }
30 
31 std::string Message<std::string>::decode(const unsigned char* buffer, const unsigned int& size) {
32  return std::string(buffer, buffer + size); // c++0x buffer+size -> std::end(buffer)?
33 }
34 
35 } // namespace mm_messages
36 
37 //namespace mm_messages_registry_entries {
38 // const mm_messages::RegistryEntry<1, std::string> unused_packet_info_dude("Core official test message packet id for strings");
39 //}
40 MM_REGISTER_PACKET_INFO(mm_core_msgs::TestStrings, std::string, "Core official test message packet id for strings");
static void encode(const T &msg, ByteArray &buffer)
MM_REGISTER_PACKET_INFO(mm_core_msgs::TestStrings, std::string,"Core official test message packet id for strings")
std::vector< unsigned char > ByteArray
static T decode(const unsigned char *buffer, const unsigned int &size)


mm_core_msgs
Author(s): Daniel Stonier
autogenerated on Mon Jun 10 2019 13:52:12