示例#1
0
name name_factory::build_promoted_module_name(const name& model_name,
    const name& element_name) const {
    name n;
    n.simple(element_name.simple());

    const auto& l(element_name.location());
    if (!l.internal_modules().empty())
        n.location().model_modules().push_back(l.internal_modules().front());

    n.location().external_modules(model_name.location().external_modules());

    name_builder b(n);
    return b.build();
}
示例#2
0
std::list<std::string> name_flattener::flatten(const name& n) 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;
}
示例#3
0
name name_factory::build_attribute_name(const name& owner_name,
    const std::string& simple_name) const {

    location l(owner_name.location());
    l.element(owner_name.simple());

    name n;
    n.location(l);
    n.simple(simple_name);
    name_builder b(n);
    return b.build();
}
示例#4
0
name name_factory::build_element_in_model(const name& model_name,
    const std::string& simple_name) const {

    yarn::name n;
    n.simple(simple_name);

    const auto& l(model_name.location());
    n.location().model_modules(l.model_modules());
    n.location().external_modules(l.external_modules());

    name_builder b(n);
    return b.build();
}
示例#5
0
name name_factory::build_combined_element_name(const name& model_name,
    const name& partial_element_name,
    const bool populate_model_name_if_blank) const {
    name n(partial_element_name);

    const auto& l(model_name.location());
    if (populate_model_name_if_blank &&
        n.location().model_modules().empty()) {
        n.location().model_modules(l.model_modules());
    }
    n.location().external_modules(l.external_modules());

    name_builder b(n);
    return b.build();
}
示例#6
0
name name_factory::build_module_name(const name& model_name,
    const std::string& module_name,
    const std::list<std::string>& internal_modules) const {

    yarn::name n;
    n.simple(module_name);

    const auto& l(model_name.location());
    n.location().model_modules(l.model_modules());
    n.location().external_modules(l.external_modules());
    n.location().internal_modules(internal_modules);

    name_builder b(n);
    return b.build();
}
示例#7
0
void dehydrator::dehydrate_name(const name& n, std::ostream& s) const {
    formatters::utility_formatter uf(s);
    s << " { ";
    uf.insert_quoted("simple_name");
    s << " : ";
    uf.insert_quoted(n.simple());

    const auto& l(n.location());
    if (!l.internal_modules().empty()) {
        s << comma_space;
        uf.insert_quoted("internal_modules");
        s << " : ";
        uf.insert_quoted(join(l.internal_modules(), scope));
    }
    s << " } ";
}
示例#8
0
文件: merger.cpp 项目: Niam99/dogen
void merger::check_name(const std::string& model_name, const name& key,
    const name& value) const {

    if (key.location().original_model_name() != model_name) {
        std::ostringstream s;
        s << "Type does not belong to this model. Model name: '"
          << model_name << "'. Type name: "
          << key.qualified();
        BOOST_LOG_SEV(lg, error) << s.str();
        BOOST_THROW_EXCEPTION(merging_error(s.str()));
    }

    if (key != value) {
        std::ostringstream s;
        s << "Inconsistency between key and value names: "
          << " key: " << key.qualified()
          << " value: " << value.qualified();
        BOOST_LOG_SEV(lg, error) << s.str();
        BOOST_THROW_EXCEPTION(merging_error(s.str()));
    }
}
示例#9
0
name name_factory::build_module_name(const name& model_name,
    const std::list<std::string>& internal_modules) const {

    if (internal_modules.empty()) {
        BOOST_LOG_SEV(lg, error) << empty_internal_modules;
        BOOST_THROW_EXCEPTION(building_error(empty_internal_modules));
    }

    yarn::name n;
    n.simple(internal_modules.back());

    const auto& l(model_name.location());
    n.location().model_modules(l.model_modules());
    n.location().external_modules(l.external_modules());

    auto ipp(internal_modules);
    ipp.pop_back();
    n.location().internal_modules(ipp);

    name_builder b(n);
    return b.build();
}
示例#10
0
inline bool operator<(const name& lhs, const name& rhs) {
    return
        (lhs.location() < rhs.location() ||
            (lhs.location() == rhs.location() &&
                (lhs.simple() < rhs.simple())));
}