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

Renders C++ sources out of Sen type sets. Stateful (caches the loaded inja templates), so prefer reusing one instance across calls when possible. More...

#include <cpp.h>

Public Types

using FileContents = std::map<std::filesystem::path, std::string>
 Map of relative output path -> rendered file contents. Keys are produced from the type set's parentDirectory joined with the per-file stem (one .h, one .cpp per type set rendered).

Public Member Functions

 CppGenerator ()
 ~CppGenerator ()
FileContents generate (const sen::lang::TypeSet &typeSet, const CppOptions &opts={})
 Renders the types header + impl source for the supplied type set. When opts.recursive is true, transitively imported sets are rendered too and merged into the returned map. Recursion is cycle-safe via a visited-set keyed on TypeSet*. Two distinct type sets resolving to the same parentDirectory / fileName are deduplicated; first-written body wins.
std::string generateExports (const CppExportsOptions &opts)
 Renders the package exports source file (sen_exported_types.cpp).

Detailed Description

Renders C++ sources out of Sen type sets. Stateful (caches the loaded inja templates), so prefer reusing one instance across calls when possible.

Member Typedef Documentation

◆ FileContents

using sen::gen::CppGenerator::FileContents = std::map<std::filesystem::path, std::string>

Map of relative output path -> rendered file contents. Keys are produced from the type set's parentDirectory joined with the per-file stem (one .h, one .cpp per type set rendered).

Constructor & Destructor Documentation

◆ CppGenerator()

sen::gen::CppGenerator::CppGenerator ( )

◆ ~CppGenerator()

sen::gen::CppGenerator::~CppGenerator ( )

Member Function Documentation

◆ generate()

FileContents sen::gen::CppGenerator::generate ( const sen::lang::TypeSet & typeSet,
const CppOptions & opts = {} )
nodiscard

Renders the types header + impl source for the supplied type set. When opts.recursive is true, transitively imported sets are rendered too and merged into the returned map. Recursion is cycle-safe via a visited-set keyed on TypeSet*. Two distinct type sets resolving to the same parentDirectory / fileName are deduplicated; first-written body wins.

◆ generateExports()

std::string sen::gen::CppGenerator::generateExports ( const CppExportsOptions & opts)
nodiscard

Renders the package exports source file (sen_exported_types.cpp).


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