diff --git a/include/cppast/code_generator.hpp b/include/cppast/code_generator.hpp index 84f243f..39f24b7 100644 --- a/include/cppast/code_generator.hpp +++ b/include/cppast/code_generator.hpp @@ -358,6 +358,12 @@ namespace cppast return main_entity_.value(); } + /// \effects Generates the code for the specified entity. + /// It can be used to generate additional entities while generating another one. + /// \returns Whether or not any code was generated. + /// \notes This does not affect the main entity, but otherwise behaves just like [cppast::generate_code()](). + bool generate_code(const cpp_entity& entity); + private: /// \returns The formatting options that should be used. /// The base class version has no flags set. diff --git a/src/code_generator.cpp b/src/code_generator.cpp index 557c411..eb88d96 100644 --- a/src/code_generator.cpp +++ b/src/code_generator.cpp @@ -1103,6 +1103,11 @@ namespace } } +bool code_generator::generate_code(const cpp_entity& entity) +{ + return generate_code_impl(*this, entity, cpp_public); +} + bool cppast::generate_code(code_generator& generator, const cpp_entity& e) { generator.main_entity_ = type_safe::ref(e);