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 37 of file t_generator.h.
|
inline |
|
inlinevirtual |
Definition at line 51 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 244 of file t_generator.h.
|
inlineprotected |
Capitalization helpers
Definition at line 200 of file t_generator.h.
|
inlineprotectedvirtual |
Reimplemented in t_py_generator, t_c_generator, t_cpp_generator, and t_xsd_generator.
Definition at line 98 of file t_generator.h.
|
inlineprotected |
Definition at line 204 of file t_generator.h.
|
virtual |
Escape string to use one in generated sources.
Definition at line 87 of file t_generator.cc.
|
inlineprotectedvirtual |
Reimplemented in t_doc_generator, t_py_generator, and t_html_generator.
Definition at line 108 of file t_generator.h.
|
protectedvirtual |
Reimplemented in t_cpp_generator.
Definition at line 100 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 107 of file t_generator.cc.
|
protectedpure virtual |
Implemented in t_doc_generator, t_py_generator, t_c_generator, t_cpp_generator, t_html_generator, and t_xsd_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_doc_generator, and t_html_generator.
Definition at line 30 of file t_generator.cc.
|
protectedpure virtual |
Implemented in t_cpp_generator, t_doc_generator, t_py_generator, t_c_generator, t_html_generator, and t_xsd_generator.
|
protectedpure virtual |
Implemented in t_doc_generator, t_py_generator, t_c_generator, t_cpp_generator, t_xsd_generator, and t_html_generator.
|
protectedpure virtual |
Pure virtual methods implemented by the generator subclasses.
Implemented in t_doc_generator, t_py_generator, t_c_generator, t_cpp_generator, t_html_generator, and t_xsd_generator.
|
inlineprotectedvirtual |
Reimplemented in t_py_generator, t_c_generator, and t_cpp_generator.
Definition at line 113 of file t_generator.h.
|
inline |
|
inlineprotectedvirtual |
Get the current output directory
Definition at line 148 of file t_generator.h.
|
inline |
Definition at line 60 of file t_generator.h.
|
inlineprotectedvirtual |
Method to get the program name, may be overridden
Definition at line 125 of file t_generator.h.
|
inlineprotectedvirtual |
Method to get the service name, may be overridden
Definition at line 132 of file t_generator.h.
Get the true type behind a series of typedefs.
Definition at line 268 of file t_generator.h.
|
inlineprotected |
Indentation print function
Definition at line 181 of file t_generator.h.
|
inlineprotected |
Indentation utility wrapper
Definition at line 193 of file t_generator.h.
|
inlineprotected |
Definition at line 174 of file t_generator.h.
|
inlineprotected |
Indentation level modifiers
Definition at line 170 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_py_generator, t_c_generator, t_cpp_generator, and t_xsd_generator.
Definition at line 97 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 76 of file t_generator.h.
|
inlineprotected |
Definition at line 208 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 160 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 228 of file t_generator.h.
|
inlineprotected |
Definition at line 214 of file t_generator.h.
|
protected |
Map of characters to escape in string literals.
Definition at line 306 of file t_generator.h.
|
private |
Current code indentation level
Definition at line 312 of file t_generator.h.
|
protected |
Output type-specifc directory name ("gen-*")
Definition at line 301 of file t_generator.h.
|
protected |
The program being generated
Definition at line 276 of file t_generator.h.
|
protected |
Quick accessor for formatted program name that is currently being generated.
Definition at line 282 of file t_generator.h.
|
protected |
Quick accessor for formatted service name that is currently being generated.
Definition at line 288 of file t_generator.h.
|
private |
Temporary variable counter, for making unique variable names
Definition at line 317 of file t_generator.h.