Commit 32f06c29 authored by Stephen Morris's avatar Stephen Morris
Browse files

[3643] Fix problem on Ubuntu and NetBSD Builds

Both Ubuntu and NetBSD builds fail because of what appears to be an error
trying to the use "equal_range" method of one of the classes associated with
the Boost multi-index container. The cause is uncertain - other systems
build successfully, so the problem might no lie here, e.g. it could be in
the compiler.  This fix attempts to side-step the problem by modifying the
affected files so as not to use this method.
parent 88f088fa
...@@ -50,13 +50,13 @@ void ...@@ -50,13 +50,13 @@ void
CfgHosts::getAllInternal(const std::vector<uint8_t>& identifier, CfgHosts::getAllInternal(const std::vector<uint8_t>& identifier,
const Host::IdentifierType& identifier_type, const Host::IdentifierType& identifier_type,
Storage& storage) const { Storage& storage) const {
// Search for the Host using the identifier and identifier type as a // Use the identifier and identifier type as a composite key.
// composite key.
const HostContainerIndex0& idx = hosts_.get<0>(); const HostContainerIndex0& idx = hosts_.get<0>();
std::pair<HostContainerIndex0::iterator, HostContainerIndex0::iterator> r = boost::tuple<const std::vector<uint8_t>, const Host::IdentifierType> t =
idx.equal_range(boost::make_tuple(identifier, identifier_type)); boost::make_tuple(identifier, identifier_type);
// Append each Host object to the storage. // 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) { ++host) {
storage.push_back(*host); storage.push_back(*host);
} }
......
...@@ -303,6 +303,10 @@ public: ...@@ -303,6 +303,10 @@ public:
/// name, or an uint32_t value, in which case it specifies a vendor /// name, or an uint32_t value, in which case it specifies a vendor
/// identifier. /// 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 key Option space name or vendor identifier.
/// @param option_code Code of the option to be returned. /// @param option_code Code of the option to be returned.
/// @tparam Selector one of: @c std::string or @c uint32_t /// @tparam Selector one of: @c std::string or @c uint32_t
...@@ -312,18 +316,21 @@ public: ...@@ -312,18 +316,21 @@ public:
template<typename Selector> template<typename Selector>
OptionDescriptor get(const Selector& key, OptionDescriptor get(const Selector& key,
const uint16_t option_code) const { const uint16_t option_code) const {
// Check for presence of options.
OptionContainerPtr options = getAll(key); OptionContainerPtr options = getAll(key);
if (!options || options->empty()) { if (!options || options->empty()) {
return (OptionDescriptor(false)); return (OptionDescriptor(false));
} }
// Some options present, locate the one we are interested in.
const OptionContainerTypeIndex& idx = options->get<1>(); const OptionContainerTypeIndex& idx = options->get<1>();
const OptionContainerTypeRange& range = idx.equal_range(option_code); OptionContainerTypeIndex::const_iterator od_itr = idx.find(option_code);
if (std::distance(range.first, range.second) == 0) { if (od_itr == idx.end()) {
return (OptionDescriptor(false)); return (OptionDescriptor(false));
} }
return (*range.first); return (*od_itr);
} }
/// @brief Converts option space name to vendor id. /// @brief Converts option space name to vendor id.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment