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;
}
Beispiel #2
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;
}
Beispiel #3
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;
}
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;
}
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;
}