Exemplo n.º 1
0
boost::filesystem::path path_derivatives_factory::
make_inclusion_path(const settings::path_settings& ps,
    const yarn::name& n) const {
    BOOST_LOG_SEV(lg, debug) << "Making inclusion path for: " << n.qualified();

    boost::filesystem::path r;

    /* Header files require both the external module path and the
     * model module path in the file name path.
     */
    if (ps.file_type() == formatters::file_types::cpp_header) {
        for (const auto& m : n.location().external_modules())
            r /= m;

        const auto& mmp(n.location().model_modules());
        r /= boost::algorithm::join(mmp, dot);
    }

    /* If there is a facet directory, and it is configured to
     * contribute to the file name path, add it.
     */
    if (!ps.facet_directory().empty() && !ps.disable_facet_directories())
        r /= ps.facet_directory();

    // Add the module path of the modules internal to this model.
    for (const auto& m : n.location().internal_modules())
        r /= m;

    /* Modules other than the model module contribute their simple
     * names to the directories.
     */
    if (n != model_.name()) {
        const auto i(model_.elements().find(n.qualified()));
        if (i != model_.elements().end() && is<yarn::module>(i->second))
            r /= n.simple();
    }

    // handle the file name.
    std::ostringstream stream;
    stream << n.simple();

    if (!ps.formatter_postfix().empty())
        stream << underscore << ps.formatter_postfix();

    if (!ps.facet_postfix().empty())
        stream << underscore << ps.facet_postfix();

    if (ps.file_type() == formatters::file_types::cpp_header)
        stream << dot << ps.header_file_extension();
    else if (ps.file_type() == formatters::file_types::cpp_implementation)
        stream << dot << ps.implementation_file_extension();

    r /= stream.str();

    BOOST_LOG_SEV(lg, debug) << "Done making the inclusion path. Result: " << r;
    return r;
}
Exemplo n.º 2
0
std::list<std::string> name_builder::
namespace_list(const yarn::name& n, const bool detect_model_name) const {
    const auto& l(n.location());
    std::list<std::string> r(l.external_modules());

    for (const auto& m : l.model_modules())
        r.push_back(m);

    for (const auto& m : l.internal_modules())
        r.push_back(m);

    if (!detect_model_name)
        return r;

    /* if the name belongs to the model's module, we need to remove the
     * module's simple name from the module path (it is in both the
     * module path and it is also the module's simple name).
     */
    const bool no_internal_modules(l.internal_modules().empty());
    const bool has_model_modules(!l.model_modules().empty());
    const bool is_model_name(no_internal_modules && has_model_modules &&
        n.simple() == l.model_modules().back());

    if (is_model_name)
        r.pop_back();

    return r;
}
Exemplo n.º 3
0
std::string name_builder::
qualified_name(const yarn::name& n) const {
    std::list<std::string> l(namespace_list(n, true));
    l.push_back(n.simple());
    return boost::algorithm::join(l, scope_operator);
}