示例#1
0
void json_hydrator::read_module_path(const boost::property_tree::ptree& pt,
    model& m, qname& qn) const {
    const auto i(pt.find(module_path_key));
    if (i == pt.not_found())
        return;

    for (auto j(i->second.begin()); j != i->second.end(); ++j) {
        const auto module_name(j->second.get_value<std::string>());
        qn.module_path().push_back(module_name);

        qname module_qn;
        module_qn.simple_name(module_name);
        module_qn.model_name(model_name(m));
        auto mp(qn.module_path());
        mp.pop_back();
        module_qn.module_path(mp);

        const auto i(m.modules().find(module_qn));
        if (i == m.modules().end()) {
            module mod;
            mod.name(module_qn);
            mod.origin_type(m.origin_type());
            mod.generation_type(m.generation_type());
            m.modules().insert(std::make_pair(module_qn, mod));
        }
    }
}
示例#2
0
void json_hydrator::
read_element(const boost::property_tree::ptree& pt, model& m) const {
    qname qn;
    qn.model_name(model_name(m));
    read_module_path(pt, m, qn);

    const auto simple_name_value(pt.get<std::string>(simple_name_key));
    qn.simple_name(simple_name_value);

    const auto documentation(pt.get_optional<std::string>(documentation_key));

    const auto lambda([&](type& t) {
            BOOST_LOG_SEV(lg, debug) << "Processing type: "
                                     << sml::string_converter::convert(qn);
            t.name(qn);
            t.origin_type(m.origin_type());
            t.generation_type(m.generation_type());

            if (documentation)
                t.documentation(*documentation);

            const auto scope(dynamic::scope_types::entity);
            t.extensions(create_dynamic_extensions(pt, scope));
        });

    const auto meta_type_value(pt.get<std::string>(meta_type_key));
    if (meta_type_value == meta_type_object_value) {
        object o;
        lambda(o);

        const auto ot(pt.get_optional<std::string>(object_type_key));
        o.object_type(to_object_type(ot));
        m.objects().insert(std::make_pair(qn, o));
    } else if (meta_type_value == meta_type_primitive_value) {
        primitive p;
        lambda(p);
        m.primitives().insert(std::make_pair(qn, p));
    }
    else {
        BOOST_LOG_SEV(lg, error) << invalid_meta_type << meta_type_value;
        BOOST_THROW_EXCEPTION(
            hydration_error(invalid_meta_type + meta_type_value));
    }
}
示例#3
0
std::size_t model_hasher::hash(const model& v) {
    std::size_t seed(0);

    combine(seed, v.documentation());
    combine(seed, v.extensions());
    combine(seed, v.name());
    combine(seed, v.generation_type());
    combine(seed, v.origin_type());
    combine(seed, hash_boost_optional_dogen_tack_name(v.containing_module()));
    combine(seed, hash_std_unordered_map_dogen_tack_name_dogen_tack_origin_types(v.references()));
    combine(seed, hash_std_unordered_set_dogen_tack_name(v.leaves()));
    combine(seed, hash_std_unordered_map_dogen_tack_name_dogen_tack_module(v.modules()));
    combine(seed, hash_std_unordered_map_dogen_tack_name_dogen_tack_concept(v.concepts()));
    combine(seed, hash_std_unordered_map_dogen_tack_name_dogen_tack_primitive(v.primitives()));
    combine(seed, hash_std_unordered_map_dogen_tack_name_dogen_tack_enumeration(v.enumerations()));
    combine(seed, hash_std_unordered_map_dogen_tack_name_dogen_tack_object(v.objects()));
    combine(seed, v.is_target());
    combine(seed, v.has_generatable_types());

    return seed;
}