Add on_container_end() function to code generator to allow injection of children
This commit is contained in:
parent
2c7b06dea9
commit
8eef31bba1
2 changed files with 22 additions and 0 deletions
|
|
@ -230,6 +230,12 @@ namespace cppast
|
|||
return gen_;
|
||||
}
|
||||
|
||||
/// \effects Calls `on_container_end()`.
|
||||
void container_end() const noexcept
|
||||
{
|
||||
gen_->on_container_end(*this, *e_);
|
||||
}
|
||||
|
||||
/// \effects Call `do_indent()` followed by `do_write_newline()` (if `print_newline` is `true`).
|
||||
void indent(bool print_newline = true) const noexcept
|
||||
{
|
||||
|
|
@ -399,6 +405,15 @@ namespace cppast
|
|||
(void)e;
|
||||
}
|
||||
|
||||
/// \effects Will be invoked after all children of a container have been generated.
|
||||
/// It can be used to inject additional children.
|
||||
/// The base class version has no effect.
|
||||
virtual void on_container_end(const output& out, const cpp_entity& e)
|
||||
{
|
||||
(void)out;
|
||||
(void)e;
|
||||
}
|
||||
|
||||
/// \effects Will be invoked when the indentation level should be increased by one.
|
||||
/// The level change must be applied on the next call to `do_write_newline()`.
|
||||
virtual void do_indent() = 0;
|
||||
|
|
|
|||
|
|
@ -88,6 +88,8 @@ namespace
|
|||
if (!need_sep)
|
||||
// file empty, write newl
|
||||
output << newl;
|
||||
else
|
||||
output.container_end();
|
||||
}
|
||||
return static_cast<bool>(output);
|
||||
}
|
||||
|
|
@ -173,6 +175,7 @@ namespace
|
|||
output.indent();
|
||||
|
||||
write_container(output, ns, newl, cur_access);
|
||||
output.container_end();
|
||||
|
||||
output.unindent();
|
||||
output << punctuation("}") << newl;
|
||||
|
|
@ -285,6 +288,8 @@ namespace
|
|||
if (need_sep)
|
||||
output << newl;
|
||||
|
||||
output.container_end();
|
||||
|
||||
output.unindent();
|
||||
output << punctuation("};") << newl;
|
||||
}
|
||||
|
|
@ -426,6 +431,8 @@ namespace
|
|||
}
|
||||
}
|
||||
|
||||
output.container_end();
|
||||
|
||||
output.unindent();
|
||||
output << punctuation("};") << newl;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue