tree-gen
C++ code generator for tree structures
Functions
tree_gen::cpp Namespace Reference

Detailed Description

Namespace for C++ code generation.

Functions

void format_doc (std::ofstream &stream, const std::string &doc, const std::string &indent="", const std::string &annotation="")
 Formats a C++ docstring. More...
 
void generate_enum (std::ofstream &header, Nodes &nodes)
 Generates the node type enumeration. More...
 
void generate_typecast_function (std::ofstream &header, std::ofstream &source, const std::string &clsname, Node &into, bool allowed)
 Generates an as_<type> function. More...
 
void generate_base_class (std::ofstream &header, std::ofstream &source, Nodes &nodes, bool with_serdes, const std::string &support_ns)
 Generates the base class for the nodes. More...
 
void generate_deserialize_mux (std::ofstream &source, Node &node)
 Recursive function to print a muxing if statement for all node classes derived from the given node class. More...
 
void generate_node_class (std::ofstream &header, std::ofstream &source, Specification &spec, Node &node)
 Generates the class for the given node. More...
 
void generate_visitor_base_class (std::ofstream &header, std::ofstream &source, Nodes &nodes)
 Generate the visitor base class. More...
 
void generate_visitor_class (std::ofstream &header, std::ofstream &source, Nodes &nodes)
 Generate the templated visitor class. More...
 
void generate_recursive_visitor_class (std::ofstream &header, std::ofstream &source, Nodes &nodes)
 Generate the recursive visitor class. More...
 
void generate_dumper_class (std::ofstream &header, std::ofstream &source, Nodes &nodes, std::string &source_location, std::string &support_ns)
 Generate the dumper class. More...
 
void generate (const std::string &header_filename, const std::string &source_filename, Specification &specification)
 Generate the complete C++ code (source and header). More...
 

Function Documentation

◆ format_doc()

void tree_gen::cpp::format_doc ( std::ofstream &  stream,
const std::string &  doc,
const std::string &  indent = "",
const std::string &  annotation = "" 
)

Formats a C++ docstring.

Definition at line 17 of file tree-gen-cpp.cpp.

◆ generate_enum()

void tree_gen::cpp::generate_enum ( std::ofstream &  header,
Nodes nodes 
)

Generates the node type enumeration.

Definition at line 66 of file tree-gen-cpp.cpp.

◆ generate_typecast_function()

void tree_gen::cpp::generate_typecast_function ( std::ofstream &  header,
std::ofstream &  source,
const std::string &  clsname,
Node into,
bool  allowed 
)

Generates an as_<type> function.

Definition at line 96 of file tree-gen-cpp.cpp.

◆ generate_base_class()

void tree_gen::cpp::generate_base_class ( std::ofstream &  header,
std::ofstream &  source,
Nodes nodes,
bool  with_serdes,
const std::string &  support_ns 
)

Generates the base class for the nodes.

Definition at line 136 of file tree-gen-cpp.cpp.

◆ generate_deserialize_mux()

void tree_gen::cpp::generate_deserialize_mux ( std::ofstream &  source,
Node node 
)

Recursive function to print a muxing if statement for all node classes derived from the given node class.

Definition at line 249 of file tree-gen-cpp.cpp.

◆ generate_node_class()

void tree_gen::cpp::generate_node_class ( std::ofstream &  header,
std::ofstream &  source,
Specification spec,
Node node 
)

Generates the class for the given node.

Definition at line 266 of file tree-gen-cpp.cpp.

◆ generate_visitor_base_class()

void tree_gen::cpp::generate_visitor_base_class ( std::ofstream &  header,
std::ofstream &  source,
Nodes nodes 
)

Generate the visitor base class.

Definition at line 671 of file tree-gen-cpp.cpp.

◆ generate_visitor_class()

void tree_gen::cpp::generate_visitor_class ( std::ofstream &  header,
std::ofstream &  source,
Nodes nodes 
)

Generate the templated visitor class.

Definition at line 714 of file tree-gen-cpp.cpp.

◆ generate_recursive_visitor_class()

void tree_gen::cpp::generate_recursive_visitor_class ( std::ofstream &  header,
std::ofstream &  source,
Nodes nodes 
)

Generate the recursive visitor class.

Definition at line 826 of file tree-gen-cpp.cpp.

◆ generate_dumper_class()

void tree_gen::cpp::generate_dumper_class ( std::ofstream &  header,
std::ofstream &  source,
Nodes nodes,
std::string &  source_location,
std::string &  support_ns 
)

Generate the dumper class.

Definition at line 873 of file tree-gen-cpp.cpp.

◆ generate()

void tree_gen::cpp::generate ( const std::string &  header_filename,
const std::string &  source_filename,
Specification specification 
)

Generate the complete C++ code (source and header).

Definition at line 1077 of file tree-gen-cpp.cpp.