void wamp_hello_details::unmarshal(const msgpack::object& object) { std::unordered_map<std::string, msgpack::object> details; object.convert(&details); auto details_itr = details.find("roles"); if (details_itr == details.end()) { return; } std::unordered_map<std::string, msgpack::object> roles; details_itr->second.convert(roles); for (const auto& roles_itr : roles) { std::unordered_map<std::string, msgpack::object> properties; roles_itr.second.convert(properties); wamp_role_features features; auto properties_itr = properties.find("features"); if (properties_itr != properties.end()) { std::unordered_map<std::string, bool> attributes; properties_itr->second.convert(attributes); features.set_attributes(std::move(attributes)); } wamp_role_type role_type = role_type_from_string(roles_itr.first); wamp_role role(role_type); role.set_features(std::move(features)); add_role(std::move(role)); } }
/** * Add a member to the relation. * * @param type The type (node, way, or relation). * @param ref The ID of the member. * @param role The role of the member. * @param role_length Length of the role (without \0 termination). * @param full_member Optional pointer to the member object. If it * is available a copy will be added to the * relation. * @throws std:length_error If role_length is greater than * osmium::max_osm_string_length */ void add_member(osmium::item_type type, object_id_type ref, const char* role, const size_t role_length, const osmium::OSMObject* full_member = nullptr) { osmium::RelationMember* member = reserve_space_for<osmium::RelationMember>(); new (member) osmium::RelationMember(ref, type, full_member != nullptr); add_size(sizeof(RelationMember)); add_role(*member, role, role_length); if (full_member) { add_item(full_member); } }
/** * Add role to buffer. * * @param member Relation member object where the length of the role * will be set. * @param role Role. */ void add_role(osmium::RelationMember& member, const std::string& role) { add_role(member, role.data(), static_cast_with_assert<string_size_type>(role.size() + 1)); }
/** * Add role to buffer. * * @param member Relation member object where the length of the role * will be set. * @param role \0-terminated role. */ void add_role(osmium::RelationMember& member, const char* role) { add_role(member, role, static_cast_with_assert<string_size_type>(std::strlen(role) + 1)); }