section array render bugfix

This commit is contained in:
Daniel Sipka 2015-04-11 13:55:59 +02:00
parent 4c43b33291
commit 95ec6728af
4 changed files with 31 additions and 18 deletions

View file

@ -5,16 +5,19 @@ using namespace mstch;
visitor::render_section::render_section(
render_context& context,
const std::string& section):
const std::string& section,
std::set<flag> flags):
context(context),
section(section)
section(section),
flags(flags)
{
}
std::string visitor::render_section::operator()(
const boost::blank& blank) const
{
return "";
return render_context(mstch::object{{".", mstch::node{}}}, context)
.render(section);
}
std::string visitor::render_section::operator()(const int& i) const {
@ -29,14 +32,17 @@ std::string visitor::render_section::operator()(const std::string& str) const {
return render_context(mstch::object{{".", str}}, context).render(section);
}
std::string visitor::render_section::operator()(const array& arr) const {
std::ostringstream out;
for (auto& item: arr)
out << render_context(mstch::object{{".", item}}, context)
.render(section);
return out.str();
}
std::string visitor::render_section::operator()(const object& obj) const {
return render_context(obj, context).render(section);
}
std::string visitor::render_section::operator()(const array& a) const {
std::ostringstream out;
if(flags.find(flag::keep_array) != flags.end())
out << render_context(mstch::object{{".", a}}, context).render(section);
else
for (auto& item: a)
out << boost::apply_visitor(
render_section(context, section, {flag::keep_array}), item);
return out.str();
}