|
OpenSDN source code
|
#include <t_generator.h>


Public Member Functions | |
| t_generator (t_program *program) | |
| virtual | ~t_generator () |
| virtual void | generate_program () |
| const t_program * | get_program () const |
| void | generate_docstring_comment (std::ofstream &out, const std::string &comment_start, const std::string &line_prefix, const std::string &contents, const std::string &comment_end) |
| virtual std::string | escape_string (const std::string &in) const |
| std::string | get_escaped_string (t_const_value *constval) |
Static Public Member Functions | |
| static bool | is_valid_namespace (const std::string &sub_namespace) |
| static t_type * | get_true_type (t_type *type) |
Protected Member Functions | |
| virtual void | init_generator () |
| virtual void | close_generator () |
| virtual void | generate_consts (std::vector< t_const * > consts) |
| virtual void | generate_typedef (t_typedef *ttypedef)=0 |
| virtual void | generate_enum (t_enum *tenum)=0 |
| virtual void | generate_const (t_const *tconst) |
| virtual void | generate_struct (t_struct *tstruct)=0 |
| virtual void | generate_service (t_service *tservice)=0 |
| virtual void | generate_xception (t_struct *txception) |
| virtual std::string | get_program_name (t_program *tprogram) |
| virtual std::string | get_service_name (t_service *tservice) |
| virtual std::string | get_out_dir () const |
| std::string | tmp (std::string name) |
| void | indent_up () |
| void | indent_down () |
| std::string | indent () |
| std::ostream & | indent (std::ostream &os) |
| std::string | capitalize (std::string in) |
| std::string | decapitalize (std::string in) |
| std::string | lowercase (std::string in) |
| std::string | uppercase (std::string in) |
| std::string | underscore (std::string in) |
| std::string | camelcase (std::string in) |
Protected Attributes | |
| t_program * | program_ |
| std::string | program_name_ |
| std::string | service_name_ |
| std::string | out_dir_base_ |
| std::map< char, std::string > | escape_ |
Private Attributes | |
| int | indent_ |
| int | tmp_ |
Base class for a thrift code generator. This class defines the basic routines for code generation and contains the top level method that dispatches code generation across various components.
Definition at line 40 of file t_generator.h.
|
inline |
|
inlinevirtual |
Definition at line 54 of file t_generator.h.
|
inlineprotected |
Transforms a string with words separated by underscores to a camel case equivalent e.g. a_multi_word -> aMultiWord some_name -> someName name -> name
Definition at line 247 of file t_generator.h.

|
inlineprotected |
Capitalization helpers
Definition at line 203 of file t_generator.h.
|
inlineprotectedvirtual |
Reimplemented in t_xsd_generator, t_py_generator, t_cpp_generator, and t_c_generator.
Definition at line 101 of file t_generator.h.
|
inlineprotected |
Definition at line 207 of file t_generator.h.
|
virtual |
Escape string to use one in generated sources.
Definition at line 90 of file t_generator.cc.
|
inlineprotectedvirtual |
Reimplemented in t_py_generator, t_html_generator, and t_doc_generator.
Definition at line 111 of file t_generator.h.
|
protectedvirtual |
Reimplemented in t_cpp_generator.
Definition at line 103 of file t_generator.cc.
| void t_generator::generate_docstring_comment | ( | std::ofstream & | out, |
| const std::string & | comment_start, | ||
| const std::string & | line_prefix, | ||
| const std::string & | contents, | ||
| const std::string & | comment_end | ||
| ) |
Definition at line 110 of file t_generator.cc.
|
protectedpure virtual |
Implemented in t_xsd_generator, t_py_generator, t_html_generator, t_doc_generator, t_cpp_generator, and t_c_generator.
|
virtual |
Framework generator method that iterates over all the parts of a program and performs general actions. This is implemented by the base class and should not normally be overwritten in the subclasses.
Top level program generation function. Calls the generator subclass methods for preparing file streams etc. then iterates over all the parts of the program to perform the correct actions.
| program | The thrift program to compile into C++ source |
Reimplemented in t_html_generator, and t_doc_generator.
Definition at line 33 of file t_generator.cc.
|
protectedpure virtual |
Implemented in t_xsd_generator, t_py_generator, t_html_generator, t_doc_generator, t_cpp_generator, and t_c_generator.
|
protectedpure virtual |
Implemented in t_xsd_generator, t_py_generator, t_html_generator, t_doc_generator, t_cpp_generator, and t_c_generator.
|
protectedpure virtual |
Pure virtual methods implemented by the generator subclasses.
Implemented in t_xsd_generator, t_py_generator, t_html_generator, t_doc_generator, t_cpp_generator, and t_c_generator.
|
inlineprotectedvirtual |
Reimplemented in t_py_generator, t_cpp_generator, and t_c_generator.
Definition at line 116 of file t_generator.h.

|
inline |
|
inlineprotectedvirtual |
Get the current output directory
Definition at line 151 of file t_generator.h.

|
inline |
Definition at line 63 of file t_generator.h.
|
inlineprotectedvirtual |
Method to get the program name, may be overridden
Definition at line 128 of file t_generator.h.

|
inlineprotectedvirtual |
Method to get the service name, may be overridden
Definition at line 135 of file t_generator.h.

Get the true type behind a series of typedefs.
Definition at line 271 of file t_generator.h.
|
inlineprotected |
Indentation print function
Definition at line 184 of file t_generator.h.
|
inlineprotected |
Indentation utility wrapper
Definition at line 196 of file t_generator.h.

|
inlineprotected |
Definition at line 177 of file t_generator.h.
|
inlineprotected |
Indentation level modifiers
Definition at line 173 of file t_generator.h.
|
inlineprotectedvirtual |
Optional methods that may be imlemented by subclasses to take necessary steps at the beginning or end of code generation.
Reimplemented in t_xsd_generator, t_py_generator, t_cpp_generator, and t_c_generator.
Definition at line 100 of file t_generator.h.
|
inlinestatic |
check whether sub-namespace declaraction is used by generator. e.g. allow namespace py.twisted bar to specify namespace to use when -gen py:twisted is specified. Will be called with subnamespace, i.e. is_valid_namespace("twisted") will be called for the above example.
Definition at line 79 of file t_generator.h.
|
inlineprotected |
Definition at line 211 of file t_generator.h.
|
inlineprotected |
Creates a unique temporary variable name, which is just "name" with a number appended to it (i.e. name35)
Definition at line 163 of file t_generator.h.
|
inlineprotected |
Transforms a camel case string to an equivalent one separated by underscores e.g. aMultiWord -> a_multi_word someName -> some_name CamelCase -> camel_case name -> name Name -> name
Definition at line 231 of file t_generator.h.
|
inlineprotected |
Definition at line 217 of file t_generator.h.
|
protected |
Map of characters to escape in string literals.
Definition at line 309 of file t_generator.h.
|
private |
Current code indentation level
Definition at line 315 of file t_generator.h.
|
protected |
Output type-specifc directory name ("gen-*")
Definition at line 304 of file t_generator.h.
|
protected |
The program being generated
Definition at line 279 of file t_generator.h.
|
protected |
Quick accessor for formatted program name that is currently being generated.
Definition at line 285 of file t_generator.h.
|
protected |
Quick accessor for formatted service name that is currently being generated.
Definition at line 291 of file t_generator.h.
|
private |
Temporary variable counter, for making unique variable names
Definition at line 320 of file t_generator.h.