/** * @brief Add comparable support for qnames. * * This is required as part of the current (very sub-optimal) * implementation of concept processing. */ inline bool operator<(const qname& lhs, const qname& rhs) { return lhs.model_name() < rhs.model_name() || (lhs.model_name() == rhs.model_name() && (lhs.external_module_path() < rhs.external_module_path() || (lhs.external_module_path() == rhs.external_module_path() && (lhs.simple_name() < rhs.simple_name())))); }
std::string string_converter::convert(const qname& qn) { std::ostringstream s; for (const auto& m : qn.external_module_path()) s << "<" << m << ">"; if (!qn.model_name().empty()) s << "<" << qn.model_name() << ">"; for (const auto& m : qn.module_path()) s << "<" << m << ">"; if (!qn.simple_name().empty()) s << "<" << qn.simple_name() << ">"; return s.str(); }
boost::optional<qname> containing_module(model& m, const qname& qn) { if (qn.model_name().empty() || qn.simple_name() == m.name().model_name()) { BOOST_LOG_SEV(lg, debug) << "Type has no containing module: " << string_converter::convert(qn); return boost::optional<qname>(); } qname module_qn; module_qn.model_name(qn.model_name()); if (qn.module_path().empty()) { module_qn.simple_name(qn.model_name()); } else { module_qn.simple_name(qn.module_path().back()); module_qn.module_path(qn.module_path()); module_qn.module_path().pop_back(); } const auto i(m.modules().find(module_qn)); if (i != m.modules().end()) return module_qn; BOOST_LOG_SEV(lg, debug) << "Could not find containing module: " << string_converter::convert(module_qn); return boost::optional<qname>();; }