CfgHosts::getAllInternal(const std::vector<uint8_t>& identifier,
const Host::IdentifierType& identifier_type,
Storage& storage) const {
- // Search for the Host using the identifier and identifier type as a
- // composite key.
+ // Use the identifier and identifier type as a composite key.
const HostContainerIndex0& idx = hosts_.get<0>();
- std::pair<HostContainerIndex0::iterator, HostContainerIndex0::iterator> r =
- idx.equal_range(boost::make_tuple(identifier, identifier_type));
+ boost::tuple<const std::vector<uint8_t>, const Host::IdentifierType> t =
+ boost::make_tuple(identifier, identifier_type);
+
// Append each Host object to the storage.
- for (HostContainerIndex0::iterator host = r.first; host != r.second;
+ for (HostContainerIndex0::iterator host = idx.lower_bound(t); host != idx.upper_bound(t);
++host) {
storage.push_back(*host);
}
/// name, or an uint32_t value, in which case it specifies a vendor
/// identifier.
///
+ /// @note If there are multiple options with the same key, only one will
+ /// be returned. No indication will be given of the presence of others,
+ /// and the instance returned is not determinable.
+ ///
/// @param key Option space name or vendor identifier.
/// @param option_code Code of the option to be returned.
/// @tparam Selector one of: @c std::string or @c uint32_t
template<typename Selector>
OptionDescriptor get(const Selector& key,
const uint16_t option_code) const {
+
+ // Check for presence of options.
OptionContainerPtr options = getAll(key);
if (!options || options->empty()) {
return (OptionDescriptor(false));
}
+ // Some options present, locate the one we are interested in.
const OptionContainerTypeIndex& idx = options->get<1>();
- const OptionContainerTypeRange& range = idx.equal_range(option_code);
- if (std::distance(range.first, range.second) == 0) {
+ OptionContainerTypeIndex::const_iterator od_itr = idx.find(option_code);
+ if (od_itr == idx.end()) {
return (OptionDescriptor(false));
}
- return (*range.first);
+ return (*od_itr);
}
/// @brief Converts option space name to vendor id.