static inline bool addAliasImpl(PathNode &node, std::string const &source, AliasPriority priority) { if (!aliasNeedsUpdate(node, source, priority)) { return false; } elements::AliasElement elt; elt.setSource(source); elt.priority() = priority; node.value() = elt; return true; }
/// @brief Determine if the node needs updating given that we want to add an /// alias there pointing to source with the given automatic status. static inline bool aliasNeedsUpdate(PathNode &node, std::string const &source, AliasPriority priority) { elements::AliasElement *elt = boost::get<elements::AliasElement>(&node.value()); if (nullptr == elt) { /// Always replace non-aliases return true; } if (priority > elt->priority()) { /// We're a higher-priority (manual vs automatic for instance), so /// override return true; } if (priority == elt->priority() && source != elt->getSource()) { /// Same automatic status, different source: replace/update return true; } return false; }