Пример #1
0
void char_helper_stitch(
    nested_type_formatting_assistant& a,
    const formattables::nested_type_info& t) {
a.stream() << std::endl;
a.stream() << t.name() << " create_" << t.identifiable_name() << "(const unsigned int position) {" << std::endl;
a.stream() << "    return static_cast<" << t.name() << ">(((position % 95) + 32) == 34) ? 35 : ((position % 95) + 32);" << std::endl;
a.stream() << "}" << std::endl;
}
void domain_type_helper_stitch(
    nested_type_formatting_assistant& a,
    const formattables::nested_type_info& t,
    const bool as_pointer) {
a.stream() << std::endl;
a.stream() << t.complete_name() << (as_pointer ? "*" : "") << std::endl;
a.stream() << "create_" << t.complete_identifiable_name() << (as_pointer ? "_ptr" : "") << "(const unsigned int position) {" << std::endl;
a.stream() << "    return " << t.complete_name() << "_generator::create" << (as_pointer ? "_ptr" : "") << "(position);" << std::endl;
a.stream() << "}" << std::endl;
}
Пример #3
0
void path_helper_stitch(
    formatters::nested_type_formatting_assistant& fa,
    const formattables::nested_type_info& t) {    
fa.stream() << std::endl;
fa.stream() << t.complete_name() << std::endl;
fa.stream() << "create_" << t.complete_identifiable_name() << "(const unsigned int position) {" << std::endl;
fa.stream() << "    std::ostringstream s;" << std::endl;
fa.stream() << "    s << \"/a/path/number_\" << position;" << std::endl;
fa.stream() << "    return " << t.name() << "(s.str());" << std::endl;
fa.stream() << "}" << std::endl;
}
Пример #4
0
void optional_helper_stitch(
    formatters::nested_type_formatting_assistant& fa,
    const formattables::nested_type_info& t) {
    
    const auto containee(t.children().front());
fa.stream() << std::endl;
fa.stream() << t.complete_name() << std::endl;
fa.stream() << "create_" << t.complete_identifiable_name() << "(unsigned int position) {" << std::endl;
fa.stream() << "    " << t.complete_name() << " r(" << std::endl;
fa.stream() << "        create_" << containee.complete_identifiable_name() << "(position));" << std::endl;
fa.stream() << "    return r;" << std::endl;
fa.stream() << "}" << std::endl;
}
Пример #5
0
void smart_pointer_helper_stitch(
    formatters::nested_type_formatting_assistant& fa,
    const formattables::nested_type_info& t) {
    

    const auto containee(t.children().front());
fa.stream() << std::endl;
fa.stream() << "inline std::size_t hash_" << t.complete_identifiable_name() << "(const " << t.complete_name() << "& v) {" << std::endl;
fa.stream() << "    std::size_t seed(0);" << std::endl;
    if (!fa.requires_hashing_helper_method(containee))
fa.stream() << "    combine(seed, *v);" << std::endl;
    else
fa.stream() << "    combine(seed, hash_" << containee.complete_identifiable_name() << "(*v));" << std::endl;
fa.stream() << "    return seed;" << std::endl;
fa.stream() << "}" << std::endl;
}
Пример #6
0
void helper_methods_formatter::recursive_helper_method_creator(
    formatters::nested_type_formatting_assistant& fa,
    const formattables::nested_type_info& t,
    std::unordered_set<std::string>& types_done) const {

    if (types_done.find(t.complete_identifiable_name()) != types_done.end())
        return;

    for (const auto c : t.children())
        recursive_helper_method_creator(fa, c, types_done);

    if (t.is_smart_pointer())
        smart_pointer_helper(fa, t);

    types_done.insert(t.complete_identifiable_name());
}
Пример #7
0
void path_helper_stitch(
    formatters::nested_type_formatting_assistant& fa,
    const formattables::nested_type_info& t) {    
fa.stream() << std::endl;
fa.stream() << "inline std::size_t hash_" << t.complete_identifiable_name() << "(const " << t.complete_name() << "& v) {" << std::endl;
fa.stream() << "    std::size_t seed(0);" << std::endl;
fa.stream() << "    combine(seed, v.generic_string());" << std::endl;
fa.stream() << "    return seed;" << std::endl;
fa.stream() << "}" << std::endl;
}
Пример #8
0
void time_duration_helper_stitch(
    formatters::nested_type_formatting_assistant& fa,
    const formattables::nested_type_info& t) {
    fa.stream() << std::endl;
    fa.stream() << "inline std::size_t hash_" << t.complete_identifiable_name() << "(const " << t.complete_name() << "& v) {" << std::endl;
    fa.stream() << "    std::size_t seed(0);" << std::endl;
    fa.stream() << "    seed = static_cast<std::size_t>(v.total_seconds());" << std::endl;
    fa.stream() << "    return seed;" << std::endl;
    fa.stream() << "}" << std::endl;
}
Пример #9
0
void helper_methods_formatter::smart_pointer_helper(
    formatters::nested_type_formatting_assistant& fa,
    const formattables::nested_type_info& t) const {
    const auto children(t.children());
    if (children.size() != 1) {
        BOOST_LOG_SEV(lg, error) << invalid_smart_pointer;
        BOOST_THROW_EXCEPTION(formatting_error(invalid_smart_pointer));
    }
    smart_pointer_helper_stitch(fa, t);
}
Пример #10
0
void pair_helper_stitch(
    formatters::nested_type_formatting_assistant& fa,
    const formattables::nested_type_info& t) {

    {
        auto snf(fa.make_scoped_namespace_formatter(t));
        const auto first(t.children().front());
        const auto second(t.children().back());
fa.stream() << std::endl;
fa.stream() << "inline std::ostream& operator<<(std::ostream& s, const " << t.complete_name() << "& v) {" << std::endl;
fa.stream() << "    s << \"{ \" << \"\\\"__type__\\\": \" << \"\\\"" << t.name() << "\\\"\" << \", \";" << std::endl;
fa.stream() << std::endl;
fa.stream() << "    s << \"\\\"first\\\": \" << " << fa.streaming_for_type(first, "v.first") << " << \", \";" << std::endl;
fa.stream() << "    s << \"\\\"second\\\": \" << " << fa.streaming_for_type(second, "v.second") << ";" << std::endl;
fa.stream() << "    s << \" }\";" << std::endl;
fa.stream() << "    return s;" << std::endl;
fa.stream() << "}" << std::endl;
fa.stream() << std::endl;
    }
fa.stream() << std::endl;
}
Пример #11
0
void pair_helper_stitch(
    formatters::nested_type_formatting_assistant& fa,
    const formattables::nested_type_info& t) {

    const auto first(t.children().front());
    const auto second(t.children().back());
fa.stream() << std::endl;
fa.stream() << "inline std::size_t hash_" << t.complete_identifiable_name() << "(const " << t.complete_name() << "& v) {" << std::endl;
fa.stream() << "    std::size_t seed(0);" << std::endl;
fa.stream() << std::endl;
    if (!fa.requires_hashing_helper_method(first))
fa.stream() << "    combine(seed, v.first);" << std::endl;
    else
fa.stream() << "    combine(seed, hash_" << first.complete_identifiable_name() << "(v.first));" << std::endl;

    if (!fa.requires_hashing_helper_method(second))
fa.stream() << "    combine(seed, v.second);" << std::endl;
    else
fa.stream() << "    combine(seed, hash_" << second.complete_identifiable_name() << "(v.second));" << std::endl;
fa.stream() << "    return seed;" << std::endl;
fa.stream() << "}" << std::endl;
}
Пример #12
0
void smart_pointer_helper_stitch(
    formatters::nested_type_formatting_assistant& fa,
    const formattables::nested_type_info& t) {
    
    {
        auto snf(fa.make_scoped_namespace_formatter(t));
        const auto containee(t.children().front());
fa.stream() << std::endl;
fa.stream() << "inline std::ostream& operator<<(std::ostream& s, const " << t.complete_name() << "& v) {" << std::endl;
fa.stream() << "    s << \"{ \" << \"\\\"__type__\\\": \" << \"\\\"" << t.name() << "\\\"\" << \", \"" << std::endl;
fa.stream() << "      << \"\\\"memory\\\": \" << \"\\\"\" << static_cast<void*>(v.get()) << \"\\\"\" << \", \";" << std::endl;
fa.stream() << std::endl;
fa.stream() << "    if (v)" << std::endl;
fa.stream() << "        s << \"\\\"data\\\": \" << " << fa.streaming_for_type(containee, "*v") << ";" << std::endl;
fa.stream() << "    else" << std::endl;
fa.stream() << "        s << \"\\\"data\\\": \"\"\\\"<empty>\\\"\";" << std::endl;
fa.stream() << "    s << \" }\";" << std::endl;
fa.stream() << "    return s;" << std::endl;
fa.stream() << "}" << std::endl;
fa.stream() << std::endl;
    }
fa.stream() << std::endl;
}
Пример #13
0
void variant_helper_stitch(
    nested_type_formatting_assistant& a,
    const formattables::nested_type_info& t) {

    {
        auto snf(a.make_scoped_namespace_formatter(t.namespaces()));
a.stream() << std::endl;
a.stream() << "struct " << t.complete_identifiable_name() << "_visitor : public boost::static_visitor<> {" << std::endl;
a.stream() << "    " << t.complete_identifiable_name() << "_visitor(std::ostream& s) : stream_(s) {" << std::endl;
a.stream() << "        s << \"{ \" << \"\\\"__type__\\\": \" << \"\\\"" << t.name() << "\\\"\" << \", \";" << std::endl;
a.stream() << "        s << \"\\\"data\\\": \";" << std::endl;
a.stream() << "    }" << std::endl;
a.stream() << std::endl;
a.stream() << "    ~" << t.complete_identifiable_name() << "_visitor() { stream_ << \" }\"; }" << std::endl;
        for (const auto& c : t.children()) {
a.stream() << std::endl;
a.stream() << "    void operator()(const " << c.name() << (c.is_primitive() ? "" : "&") << " v) const {" << std::endl;
            if (c.is_primitive()) {
a.stream() << "        stream_ << \"{ \" << \"\\\"__type__\\\": \" << \"\\\"" << c.name() << "\\\"\" << \", \";" << std::endl;
a.stream() << "        stream_ << \"\\\"value\\\": \";" << std::endl;
a.stream() << "        stream_ << " << a.streaming_for_type(c, "v") << ";" << std::endl;
a.stream() << "        stream_ << \" }\";" << std::endl;
            } else
a.stream() << "        stream_ << " << a.streaming_for_type(c, "v") << ";" << std::endl;
a.stream() << "    }" << std::endl;
        }
a.stream() << std::endl;
a.stream() << "private:" << std::endl;
a.stream() << "    std::ostream& stream_;" << std::endl;
a.stream() << "};" << std::endl;
a.stream() << std::endl;
a.stream() << "inline std::ostream& operator<<(std::ostream& s, const " << t.complete_name() << "& v) {" << std::endl;
a.stream() << "    boost::apply_visitor(" << t.complete_identifiable_name() << "_visitor(s), v);" << std::endl;
a.stream() << "    return s;" << std::endl;
a.stream() << "}" << std::endl;
a.stream() << std::endl;
    }
a.stream() << std::endl;
}
Пример #14
0
void variant_helper_stitch(
    nested_type_formatting_assistant& a,
    const formattables::nested_type_info& t) {
a.stream() << std::endl;
a.stream() << t.complete_name() << std::endl;
a.stream() << "create_" << t.complete_identifiable_name() << "(unsigned int position) {" << std::endl;
a.stream() << "    " << t.complete_name() << " r;" << std::endl;
a.stream() << std::endl;
    unsigned int i(0);
    for (const auto& c : t.children()) {
        if (i == 0)
a.stream() << "    if (position == 0 || ((position % " << t.children().size() << ") == 0))" << std::endl;
        else if (i == 1)
a.stream() << "    else if (position == 1 || ((position % " << t.children().size() + 1 << ") == 0))" << std::endl;
        else
a.stream() << "    else if ((position % " << i << ") == 0)" << std::endl;
a.stream() << "        r = create_" << c.complete_identifiable_name() << "(position);" << std::endl;
        ++i;
    }
a.stream() << std::endl;
a.stream() << "    return r;" << std::endl;
a.stream() << "}" << std::endl;
}