relationships extractor::extract_inheritance_graph(const sml::qname& qn) const { BOOST_LOG_SEV(lg, debug) << "Extracting inheritance graph for " << qn.simple_name(); relationships r; auto i(model_.objects().find(qn)); if (i == model_.objects().end()) { BOOST_LOG_SEV(lg, error) << qname_could_not_be_found << qn; BOOST_THROW_EXCEPTION(extraction_error(qname_could_not_be_found + boost::lexical_cast<std::string>(qn))); } BOOST_LOG_SEV(lg, debug) << "adding type itself" << qn; r.names().insert(qn); const auto lambda([](const sml::qname& qn, const std::string& msg ) { BOOST_LOG_SEV(lg, error) << msg << qn; BOOST_THROW_EXCEPTION(extraction_error(msg + boost::lexical_cast<std::string>(qn))); }); const auto& ao(*i->second); if (ao.leaves().empty()) BOOST_LOG_SEV(lg, debug) << "type has no leaves."; for (const auto& l : ao.leaves()) { i = model_.objects().find(l); if (i == model_.objects().end()) lambda(l, qname_could_not_be_found); do { const auto& lao(*i->second); BOOST_LOG_SEV(lg, debug) << "adding " << lao.name(); r.names().insert(lao.name()); if (!lao.parent_name()) lambda(lao.name(), type_does_not_have_a_parent); i = model_.objects().find(*lao.parent_name()); if (i == model_.objects().end()) lambda(*lao.parent_name(), qname_could_not_be_found); } while (i->second->name() != qn); } BOOST_LOG_SEV(lg, debug) << "Done extracting inheritance graph for " << qn.simple_name(); return r; }
sml::qname transformer::to_qname(const std::string& n, const sml::qname& module_qn) const { auto r(to_qname(n)); auto pp(module_qn.module_path()); pp.push_back(module_qn.simple_name()); r.module_path(pp); return r; }
std::list<content_descriptor> content_descriptor_factory:: create(const sml::qname& qn, const content_types ct) const { BOOST_LOG_SEV(lg, debug) << "Creating descriptors: " << qn << " content type: " << ct; std::list<content_descriptor> r; const auto header(file_types::header); const auto main(aspect_types::main); if (ct == content_types::namespace_doc) { const auto ft(config::cpp_facet_types::types); // FIXME: hack to handle model name. if (qn.simple_name().empty()) { auto new_qn(qn); new_qn.simple_name(qn.model_name()); r.push_back(content_descriptor(header, ft, main, new_qn, ct)); } else { // content descriptors for modules must take into account the // module name itself as they are used to name the files. // if we didn't do this we'd place the file outside the // module folder. auto new_qn(qn); new_qn.module_path().push_back(qn.simple_name()); r.push_back(content_descriptor(header, ft, main, new_qn, ct)); } return r; } for (const auto ft : enabled_facets(ct)) { r.push_back(content_descriptor(header, ft, main, qn, ct)); const auto implementation(file_types::implementation); if (has_implementation(ft, ct)) r.push_back(content_descriptor(implementation, ft, main, qn, ct)); const auto forward_decls(aspect_types::forward_decls); if (has_forward_decls(ft, ct)) r.push_back(content_descriptor(header, ft, forward_decls, qn, ct)); } BOOST_LOG_SEV(lg, debug) << "Descriptors: " << r; return r; }
void extractor::properties_for_concept(const sml::qname& qn, std::list<sml::property>& properties, std::unordered_set<sml::qname>& processed_qnames) const { if (processed_qnames.find(qn) != processed_qnames.end()) return; processed_qnames.insert(qn); const auto i(model_.concepts().find(qn)); if (i == model_.concepts().end()) { const auto sn(qn.simple_name()); BOOST_LOG_SEV(lg, error) << concept_not_found << sn; BOOST_THROW_EXCEPTION(extraction_error(concept_not_found + sn)); } for (const auto& c : i->second.refines()) properties_for_concept(c, properties, processed_qnames); const auto& props(i->second.properties()); properties.insert(properties.end(), props.begin(), props.end()); }