Sen API
Sen Libraries
Loading...
Searching...
No Matches
sen::gen::PythonGenerator Class Reference

Renders Python dataclasses out of sen type sets. Stateful (caches the loaded inja templates), so prefer reusing one instance across calls when possible. More...

#include <python.h>

Public Member Functions

 PythonGenerator ()
 ~PythonGenerator ()
std::string generateModule (const sen::lang::TypeSet &typeSet)
 Renders one Python module for the supplied type set. Imports are derived from the type set's importedSets and rendered as from <module> import * lines.

Static Public Member Functions

static void replaceInvalidCharacters (std::string &str)
 Sanitises a string so it is a valid Python identifier fragment by replacing the characters Python forbids in module/file names (., -) with underscores.

Detailed Description

Renders Python dataclasses out of sen type sets. Stateful (caches the loaded inja templates), so prefer reusing one instance across calls when possible.

Constructor & Destructor Documentation

◆ PythonGenerator()

sen::gen::PythonGenerator::PythonGenerator ( )

◆ ~PythonGenerator()

sen::gen::PythonGenerator::~PythonGenerator ( )

Member Function Documentation

◆ generateModule()

std::string sen::gen::PythonGenerator::generateModule ( const sen::lang::TypeSet & typeSet)
nodiscard

Renders one Python module for the supplied type set. Imports are derived from the type set's importedSets and rendered as from <module> import * lines.

◆ replaceInvalidCharacters()

void sen::gen::PythonGenerator::replaceInvalidCharacters ( std::string & str)
static

Sanitises a string so it is a valid Python identifier fragment by replacing the characters Python forbids in module/file names (., -) with underscores.


The documentation for this class was generated from the following file: