mstch/src/visitor/render_section.cpp
2015-04-16 11:41:57 +02:00

57 lines
1.7 KiB
C++

#include "render_section.hpp"
using namespace mstch;
visitor::render_section::render_section(
render_context& ctx, const template_type& section, flag p_flag):
ctx(ctx), section(section), m_flag(p_flag)
{
}
std::string visitor::render_section::operator()(
const boost::blank& blank) const
{
return render_context::push(ctx, {{".", {}}}).render(section);
}
std::string visitor::render_section::operator()(const int& i) const {
return render_context::push(ctx, {{".", i}}).render(section);
}
std::string visitor::render_section::operator()(const bool& b) const {
return render_context::push(ctx, {{".", b}}).render(section);
}
std::string visitor::render_section::operator()(const std::string& str) const {
return render_context::push(ctx, {{".", str}}).render(section);
}
std::string visitor::render_section::operator()(const object& obj) const {
return render_context::push(ctx, obj).render(section);
}
std::string visitor::render_section::operator()(const array& a) const {
std::string out;
if(m_flag == flag::keep_array)
out += render_context::push(ctx, {{".", a}}).render(section);
else
for (auto& item: a)
out += boost::apply_visitor(
render_section(ctx, section, flag::keep_array), item);
return out;
}
std::string visitor::render_section::operator()(
const string_lambda& lambda) const
{
return lambda();
}
std::string visitor::render_section::operator()(
const renderer_lambda& lambda) const
{
return "";
/*return (lambda())(section, [&](const std::string& text) {
return render_context::push(ctx).render(text);
}); TODO ! */
}