Add on_container_end() function to code generator to allow injection of children

This commit is contained in:
Jonathan Müller 2017-12-14 19:08:22 +01:00
commit 8eef31bba1
2 changed files with 22 additions and 0 deletions

View file

@ -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;