void Header::write(const M_string& key_vals, boost::shared_array<uint8_t>& buffer, uint32_t& size) { // Calculate the necessary size size = 0; { M_string::const_iterator it = key_vals.begin(); M_string::const_iterator end = key_vals.end(); for (; it != end; ++it) { const std::string& key = it->first; const std::string& value = it->second; size += key.length(); size += value.length(); size += 1; // = sign size += 4; // 4-byte length } } if (size == 0) { return; } buffer.reset(new uint8_t[size]); char* ptr = (char*)buffer.get(); // Write the data { M_string::const_iterator it = key_vals.begin(); M_string::const_iterator end = key_vals.end(); for (; it != end; ++it) { const std::string& key = it->first; const std::string& value = it->second; uint32_t len = key.length() + value.length() + 1; SROS_SERIALIZE_PRIMITIVE(ptr, len); SROS_SERIALIZE_BUFFER(ptr, key.data(), key.length()); static const char equals = '='; SROS_SERIALIZE_PRIMITIVE(ptr, equals); SROS_SERIALIZE_BUFFER(ptr, value.data(), value.length()); } } ROS_ASSERT(ptr == (char*)buffer.get() + size); }
void init(const M_string& remappings) { M_string::const_iterator it = remappings.begin(); M_string::const_iterator end = remappings.end(); for (; it != end; ++it) { const std::string& left = it->first; const std::string& right = it->second; if (!left.empty() && left[0] != '_' && left != this_node::getName()) { std::string resolved_left = resolve(left, false); std::string resolved_right = resolve(right, false); g_remappings[resolved_left] = resolved_right; g_unresolved_remappings[left] = right; } } }
void init(const M_string& remappings) { M_string::const_iterator it = remappings.begin(); M_string::const_iterator end = remappings.end(); for (; it != end; ++it) { const std::string& name = it->first; const std::string& param = it->second; if (name.size() < 2) { continue; } if (name[0] == '_' && name[1] != '_') { std::string local_name = "~" + name.substr(1); bool success = false; try { int32_t i = boost::lexical_cast<int32_t>(param); param::set(names::resolve(local_name), i); success = true; } catch (boost::bad_lexical_cast&) { } if (success) { continue; } try { double d = boost::lexical_cast<double>(param); param::set(names::resolve(local_name), d); success = true; } catch (boost::bad_lexical_cast&) { } if (success) { continue; } if (param == "true" || param == "True" || param == "TRUE") { param::set(names::resolve(local_name), true); } else if (param == "false" || param == "False" || param == "FALSE") { param::set(names::resolve(local_name), false); } else { param::set(names::resolve(local_name), param); } } } XMLRPCManager::instance()->bind("paramUpdate", paramUpdateCallback); }