QString PropertyMap::makeChecksum(property_map const& _properties) { QString _merged; _merged += QString("%1").arg(_properties.size()); for (auto& _property : _properties) { _merged += _property.first; _merged += makeChecksum(_property.second); } return makeChecksum(_merged); }
static inline void merge_property_maps(property_map& mp, const property_map& mp2, bool subtract = false) { property_map newmp; newmp.reserve(mp.size() + mp2.size()); std::size_t i = 0; std::size_t j = 0; while(i != mp.size() && j != mp2.size()) { if(mp[i].first < mp2[j].first) { newmp.push_back(mp[i]); ++i; } else if(mp[i].first > mp2[j].first) { newmp.push_back(mp2[j]); if(subtract) newmp.back().second *= -1; ++j; } else { int count = mp[i].second; if(subtract) count -= mp2[j].second; else count += mp2[j].second; if(count) { newmp.push_back(mp[i]); newmp.back().second = count; } ++i; ++j; } } while(i != mp.size()) { newmp.push_back(mp[i]); ++i; } while(j != mp2.size()) { newmp.push_back(mp2[j]); if(subtract) newmp.back().second *= -1; ++j; } mp.swap(newmp); }
// Encode cached maps to the pn_data_t, always used an empty() value for an empty map void flush() { if (!properties.empty()) properties.value(); if (!annotations.empty()) annotations.value(); if (!instructions.empty()) instructions.value(); }
void clear() { properties.clear(); annotations.clear(); instructions.clear(); }
impl(pn_message_t *msg) { body.reset(pn_message_body(msg)); properties.reset(pn_message_properties(msg)); annotations.reset(pn_message_annotations(msg)); instructions.reset(pn_message_instructions(msg)); }
void attach_property(property_map& properties, const name_t& name, T&& value) { properties.insert(name, std::make_unique<property<T>>(value)); }