예제 #1
0
void extractor::recurse_nested_qnames(const sml::nested_qname& nqn,
    relationships& rel, bool& is_pointer) const {

    const auto qn(nqn.type());
    if (is_pointer)
        rel.forward_decls().insert(qn);
    else
        rel.names().insert(qn);

    bool found(false);
    const auto i(model_.primitives().find(qn));
    if (i != model_.primitives().end()) {
        found = true;
        is_pointer = false;
    }

    if (!found) {
        const auto j(model_.enumerations().find(qn));
        if (j != model_.enumerations().end()) {
            is_pointer = false;
            found = true;
        }
    }

    if (!found) {
        const auto k(model_.objects().find(qn));
        if (k == 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)));
        }

        using sml::value_object;
        const auto vo(boost::dynamic_pointer_cast<value_object>(k->second));

        if (vo) {
            const auto ac(sml::value_object_types::associative_container);
            if (vo->type() == ac && nqn.children().size() >= 1)
                rel.keys().insert(nqn.children().front().type());

            const auto sp(sml::value_object_types::smart_pointer);
            is_pointer = vo->type() == sp;
        }
    }

    const auto sn(qn.simple_name());
    if (sn == bool_type || sn == double_type || sn == float_type)
        rel.requires_stream_manipulators(true);
    else if (sn == std_.type(std_types::string))
        rel.has_std_string(true);
    else if (sn == boost_.type(boost_types::variant))
        rel.has_variant(true);
    else if (sn == std_.type(std_types::pair))
        rel.has_std_pair(true);

    for (const auto c : nqn.children())
        recurse_nested_qnames(c, rel, is_pointer);
}
예제 #2
0
std::size_t relationships_hasher::hash(const relationships&v) {
    std::size_t seed(0);

    combine(seed, hash_std_unordered_set_dogen_sml_qname(v.names()));
    combine(seed, hash_std_unordered_set_dogen_sml_qname(v.forward_decls()));
    combine(seed, hash_std_unordered_set_dogen_sml_qname(v.keys()));
    combine(seed, hash_std_unordered_set_dogen_sml_qname(v.leaves()));
    combine(seed, v.has_std_string());
    combine(seed, v.has_variant());
    combine(seed, v.is_parent());
    combine(seed, v.is_child());
    combine(seed, v.requires_stream_manipulators());
    combine(seed, v.has_std_pair());
    combine(seed, hash_boost_optional_dogen_sml_qname(v.visitor()));

    return seed;
}