Beispiel #1
0
void char_helper::
format(assistant& a, const formattables::helper_properties& hp) const {
    const auto d(hp.current());
    const auto qn(d.name_tree_qualified());
    const auto ident(d.name_tree_identifiable());
a.stream() << std::endl;
a.stream() << qn << " create_" << ident << "(const unsigned int position) {" << std::endl;
a.stream() << "    return static_cast<" << qn << ">(((position % 95) + 32) == 34) ? 35 : ((position % 95) + 32);" << std::endl;
a.stream() << "}" << std::endl;
}
Beispiel #2
0
void optional_helper::
format(assistant& a, const formattables::helper_properties& hp) const {
    const auto d(hp.current());
    const auto qn(d.name_tree_qualified());
    const auto ident(d.name_tree_identifiable());
    const auto containee(hp.direct_descendants().front());
a.stream() << std::endl;
a.stream() << "inline std::size_t hash_" << ident << "(const " << qn << "& v) {" << std::endl;
a.stream() << "    std::size_t seed(0);" << std::endl;
a.stream() << std::endl;
a.stream() << "    if (!v)" << std::endl;
a.stream() << "        return seed;" << std::endl;
a.stream() << std::endl;
    if (!containee.requires_hashing_helper())
a.stream() << "    combine(seed, *v);" << std::endl;
    else
a.stream() << "    combine(seed, hash_" << containee.name_tree_identifiable() << "(*v));" << std::endl;
a.stream() << "    return seed;" << std::endl;
a.stream() << "}" << std::endl;
}
Beispiel #3
0
void associative_container_helper::
format(assistant& a, const formattables::helper_properties& hp) const {
    const auto d(hp.current());
    const auto qn(d.name_tree_qualified());
    const auto ident(d.name_tree_identifiable());
a.stream() << std::endl;
a.stream() << qn << " create_" << ident << "(unsigned int position) {" << std::endl;
a.stream() << "    " << qn << " r;" << std::endl;
a.stream() << "    for (unsigned int i(0); i < 4; ++i) {" << std::endl;
    if (hp.direct_descendants().size() == 1) {
        const auto containee(hp.direct_descendants().front());
a.stream() << "        r.insert(create_" << containee.name_tree_identifiable() << "(position + i));" << std::endl;
    } else if (hp.direct_descendants().size() == 2) {
        const auto key(hp.direct_descendants().front());
        const auto value(hp.direct_descendants().back());
a.stream() << "        r.insert(std::make_pair(create_" << key.name_tree_identifiable() << "(position + i), create_" << value.name_tree_identifiable() << "(position + i)));" << std::endl;
    }
a.stream() << "    }" << std::endl;
a.stream() << "    return r;" << std::endl;
a.stream() << "}" << std::endl;
}
Beispiel #4
0
void associative_container_helper::
format(assistant& a, const formattables::helper_properties& hp) const {
    const auto d(hp.current());
    const auto qn(d.name_tree_qualified());
    const auto ident(d.name_tree_identifiable());

    if (hp.direct_descendants().size() == 2) {
        const auto key(hp.direct_descendants().front());
        const auto value(hp.direct_descendants().back());
a.stream() << std::endl;
a.stream() << "inline std::size_t hash_" << ident << "(const " << qn << "& v) {" << std::endl;
a.stream() << "    std::size_t seed(0);" << std::endl;
a.stream() << "    for (const auto i : v) {" << std::endl;
        if (!key.requires_hashing_helper())
a.stream() << "        combine(seed, i.first);" << std::endl;
        else
a.stream() << "        combine(seed, hash_" << key.name_tree_identifiable() << "(i.first));" << std::endl;

        if (!(value.requires_hashing_helper()))
a.stream() << "        combine(seed, i.second);" << std::endl;
        else
a.stream() << "        combine(seed, hash_" << value.name_tree_identifiable() << "(i.second));" << std::endl;
a.stream() << "    }" << std::endl;
a.stream() << "    return seed;" << std::endl;
a.stream() << "}" << std::endl;
    } else {
        const auto containee(hp.direct_descendants().front());
a.stream() << std::endl;
a.stream() << "inline std::size_t hash_" << ident << "(const " << qn << "& v) {" << std::endl;
a.stream() << "    std::size_t seed(0);" << std::endl;
a.stream() << "    for (const auto i : v) {" << std::endl;
    if (!containee.requires_hashing_helper())
a.stream() << "        combine(seed, i);" << std::endl;
    else
a.stream() << "        combine(seed, hash_" << containee.name_tree_identifiable() << "(i));" << std::endl;
a.stream() << "    }" << std::endl;
a.stream() << "    return seed;" << std::endl;
a.stream() << "}" << std::endl;
    }
}
Beispiel #5
0
void ptime_helper::
format(assistant& a, const formattables::helper_properties& hp) const {
    const auto d(hp.current());
    const auto qn(d.name_tree_qualified());
    const auto ident(d.name_tree_identifiable());
a.stream() << std::endl;
a.stream() << qn << std::endl;
a.stream() << "create_" << ident << "(const unsigned int position) {" << std::endl;
a.stream() << "    unsigned int day(1 + (position % 27));" << std::endl;
a.stream() << "    using boost::gregorian::date;" << std::endl;
a.stream() << "    using boost::posix_time::ptime;" << std::endl;
a.stream() << "    using boost::posix_time::time_duration;" << std::endl;
a.stream() << "    date d(2002, 2, day);" << std::endl;
a.stream() << "    ptime r(d, time_duration(1,2,3));" << std::endl;
a.stream() << "    return r;" << std::endl;
a.stream() << "}" << std::endl;
}