string.cpp
Go to the documentation of this file.
00001 
00004 /*****************************************************************************
00005 ** Includes
00006 *****************************************************************************/
00007 
00008 #include <mm_messages/registry.hpp>
00009 #include <ecl/containers/stencil.hpp>
00010 #include "../../include/mm_core_msgs/string.hpp"
00011 #include "../../include/mm_core_msgs/test_identifiers.hpp"
00012 
00013 /*****************************************************************************
00014 ** Namespaces
00015 *****************************************************************************/
00016 
00017 namespace mm_messages {
00018 
00019 /*****************************************************************************
00020 ** Implementation
00021 *****************************************************************************/
00022 
00023 void Message<std::string>::encode(const std::string& s, ByteArray& buffer) {
00024   // publishers always send empty buffers, but in case others use this
00025   if(!buffer.empty()) {
00026     buffer.clear();
00027   }
00028   buffer.insert(buffer.end(), s.begin(), s.end());
00029 }
00030 
00031 std::string Message<std::string>::decode(const unsigned char* buffer, const unsigned int& size) {
00032   return std::string(buffer, buffer + size);  // c++0x buffer+size -> std::end(buffer)?
00033 }
00034 
00035 } // namespace mm_messages
00036 
00037 //namespace mm_messages_registry_entries {
00038 //    const mm_messages::RegistryEntry<1, std::string> unused_packet_info_dude("Core official test message packet id for strings");
00039 //}
00040 MM_REGISTER_PACKET_INFO(mm_core_msgs::TestStrings, std::string, "Core official test message packet id for strings");


mm_core_msgs
Author(s): Daniel Stonier
autogenerated on Thu Jun 6 2019 21:13:21