5

does anyone know of a good C++ template engine? Since, my aim is to try to generate C++ and Python code, given a template and a description of what needs to be filled in that template, in short, I'm trying to do something like cayenne but for C++ and Python, using a C++ processor. Since it would be usefull for my other projects to automate the generation of persistence code.

Thanks in advance.

4 Answers 4

5

Have you had a look at Cheetah. We have been using Cheetah for a large Code generation project in QA and it has been working well for us.

Sign up to request clarification or add additional context in comments.

4 Comments

I fly a cheetah. They're kind of fugly but I like it.
Thanks, even if cheetah is in python, it's ok, since the template is only to be used by the generation tool, and that will probably have an UI, to ease the creation of templates, so python actually fits better in this case.
Unfortunately the Cheetah development looks dead. It will not be upgraded to python3.
The original Cheetah was forked and Cheetah 3 does support python3 github.com/CheetahTemplate3/cheetah3
4

Inja (https://github.com/pantor/inja) is a template engine for C++. It is header-only and quite simple, but works well for me.

Comments

1

Not sure of your precise requirements, but I've created a very lightweight templating engine at https://github.com/hughperkins/Jinja2CppLight

  • handles variable substitution
  • for loops
    • including nested for loops
  • very lightweight: no dependencies on qt, boost, etc ...

Comments

0

AtomWeaver is a target-agnostic generator: you can target any language or mix of languages in a single template. Template programming is done via Lua scripts though.

This generator implements a generative modeling approach (named ABSE): You can build a model by using small bits (the templates) and save it as a project. Then you can then evolve the model and/or the templates.

1 Comment

AtomWeaver seems dead

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.