Fawkes API
Fawkes Development Version
|
Generator that transforms input from the InterfaceParser into valid C++ classes. More...
#include <>>
Public Member Functions | |
CppInterfaceGenerator (std::string directory, std::string interface_name, std::string config_basename, std::string author, std::string year, std::string creation_date, std::string data_comment, const unsigned char *hash, size_t hash_size, const std::vector< InterfaceConstant > &constants, const std::vector< InterfaceEnumConstant > &enum_constants, const std::vector< InterfaceField > &data_fields, const std::vector< InterfacePseudoMap > &pseudo_maps, const std::vector< InterfaceMessage > &messages) | |
Constructor. More... | |
~CppInterfaceGenerator () | |
Destructor. More... | |
void | write_h (FILE *f) |
Write h file. More... | |
void | write_cpp (FILE *f) |
Write cpp file. More... | |
void | write_constants_cpp (FILE *f) |
Write constants to cpp file. More... | |
void | write_constants_h (FILE *f) |
Write constants to h file. More... | |
void | write_enum_constants_tostring_cpp (FILE *f) |
Write enum constant tostring methods to cpp file. More... | |
void | write_messages_cpp (FILE *f) |
Write messages to cpp file. More... | |
void | write_messages_h (FILE *f) |
Write messages to h file. More... | |
void | write_ctor_dtor_h (FILE *f, std::string is, std::string classname) |
Write constructor and destructor to h file. More... | |
void | write_ctor_dtor_cpp (FILE *f, std::string classname, std::string super_class, std::string inclusion_prefix, std::vector< InterfaceField > fields, std::vector< InterfaceMessage > messages) |
Write constructor and destructor to cpp file. More... | |
void | write_message_ctor_dtor_h (FILE *f, std::string is, std::string classname, std::vector< InterfaceField > fields) |
Write constructor and destructor for message to h file. More... | |
void | write_message_ctor_dtor_cpp (FILE *f, std::string classname, std::string super_class, std::string inclusion_prefix, std::vector< InterfaceField > fields) |
Write constructor and destructor for message to cpp file. More... | |
void | write_message_clone_method_h (FILE *f, std::string is) |
Write message clone method header. More... | |
void | write_message_clone_method_cpp (FILE *f, std::string classname) |
Write message clone method. More... | |
void | write_methods_h (FILE *f, std::string is, std::vector< InterfaceField > fields) |
Write methods to h file. More... | |
void | write_methods_cpp (FILE *f, std::string interface_classname, std::string classname, std::vector< InterfaceField > fields, std::string inclusion_prefix, bool write_data_changed) |
Write methods to cpp file. More... | |
void | write_create_message_method_cpp (FILE *f) |
Write create_message() method to cpp file. More... | |
void | write_copy_value_method_cpp (FILE *f) |
Write copy_value() method to CPP file. More... | |
void | write_enum_tostring_method_cpp (FILE *f) |
Write enum_tostring() method to CPP file. More... | |
void | write_basemethods_h (FILE *f, std::string is) |
Write base methods header entries. More... | |
void | write_basemethods_cpp (FILE *f) |
Write base methods. More... | |
void | write_methods_h (FILE *f, std::string is, std::vector< InterfaceField > fields, std::vector< InterfacePseudoMap > pseudo_maps) |
Write methods to h file. More... | |
void | write_methods_cpp (FILE *f, std::string interface_classname, std::string classname, std::vector< InterfaceField > fields, std::vector< InterfacePseudoMap > pseudo_maps, std::string inclusion_prefix) |
Write methods to cpp file including pseudo maps. More... | |
void | write_management_funcs_cpp (FILE *f) |
Write management functions. More... | |
void | write_enum_map_population (FILE *f) |
Write enum maps. More... | |
void | write_add_fieldinfo_calls (FILE *f, std::vector< InterfaceField > &fields) |
Write the add_fieldinfo() calls. More... | |
void | write_struct (FILE *f, std::string name, std::string is, std::vector< InterfaceField > fields) |
Write optimized struct. More... | |
void | write_enum_maps_h (FILE *f) |
Write enum maps to header. More... | |
void | write_header (FILE *f, std::string filename) |
Write header to file. More... | |
void | write_deflector (FILE *f) |
Write header deflector. More... | |
void | generate () |
Generator cpp and h files. More... | |
Generator that transforms input from the InterfaceParser into valid C++ classes.
Definition at line 36 of file cpp_generator.h.
CppInterfaceGenerator::CppInterfaceGenerator | ( | std::string | directory, |
std::string | interface_name, | ||
std::string | config_basename, | ||
std::string | author, | ||
std::string | year, | ||
std::string | creation_date, | ||
std::string | data_comment, | ||
const unsigned char * | hash, | ||
size_t | hash_size, | ||
const std::vector< InterfaceConstant > & | constants, | ||
const std::vector< InterfaceEnumConstant > & | enum_constants, | ||
const std::vector< InterfaceField > & | data_fields, | ||
const std::vector< InterfacePseudoMap > & | pseudo_maps, | ||
const std::vector< InterfaceMessage > & | messages | ||
) |
Constructor.
directory | Directory where to create the files |
interface_name | name of the interface, should end with Interface |
config_basename | basename of the config without suffix |
author | author of interface |
year | year of copyright |
creation_date | user-supplied creation date of interface |
data_comment | comment in data block. |
hash | MD5 hash of the config file that was used to generate the interface |
hash_size | size in bytes of hash |
constants | constants |
enum_constants | constants defined as an enum |
data_fields | data fields of the interface |
pseudo_maps | pseudo maps of the interface |
messages | messages defined in the interface |
Definition at line 58 of file cpp_generator.cpp.
References fawkes::StringConversions::to_upper().
CppInterfaceGenerator::~CppInterfaceGenerator | ( | ) |
Destructor.
Definition at line 102 of file cpp_generator.cpp.
void CppInterfaceGenerator::generate | ( | ) |
Generator cpp and h files.
Definition at line 1209 of file cpp_generator.cpp.
void CppInterfaceGenerator::write_add_fieldinfo_calls | ( | FILE * | f, |
std::vector< InterfaceField > & | fields | ||
) |
Write the add_fieldinfo() calls.
f | file to write to |
fields | fields to write field info for |
Definition at line 632 of file cpp_generator.cpp.
void CppInterfaceGenerator::write_basemethods_cpp | ( | FILE * | f | ) |
void CppInterfaceGenerator::write_basemethods_h | ( | FILE * | f, |
std::string | is | ||
) |
Write base methods header entries.
f | file to write to |
is | indentation string |
Definition at line 1152 of file cpp_generator.cpp.
void CppInterfaceGenerator::write_constants_cpp | ( | FILE * | f | ) |
Write constants to cpp file.
f | file to write to |
Definition at line 264 of file cpp_generator.cpp.
void CppInterfaceGenerator::write_constants_h | ( | FILE * | f | ) |
Write constants to h file.
f | file to write to |
Definition at line 318 of file cpp_generator.cpp.
void CppInterfaceGenerator::write_copy_value_method_cpp | ( | FILE * | f | ) |
Write copy_value() method to CPP file.
f | file to write to |
Definition at line 469 of file cpp_generator.cpp.
void CppInterfaceGenerator::write_cpp | ( | FILE * | f | ) |
void CppInterfaceGenerator::write_create_message_method_cpp | ( | FILE * | f | ) |
Write create_message() method to cpp file.
f | file to write to |
Definition at line 433 of file cpp_generator.cpp.
void CppInterfaceGenerator::write_ctor_dtor_cpp | ( | FILE * | f, |
std::string | classname, | ||
std::string | super_class, | ||
std::string | inclusion_prefix, | ||
std::vector< InterfaceField > | fields, | ||
std::vector< InterfaceMessage > | messages | ||
) |
Write constructor and destructor to cpp file.
f | file to write to |
classname | name of class |
super_class | name of base class |
inclusion_prefix | Used if class is included in another class. |
fields | fields |
messages | messages |
Definition at line 696 of file cpp_generator.cpp.
void CppInterfaceGenerator::write_ctor_dtor_h | ( | FILE * | f, |
std::string | is, | ||
std::string | classname | ||
) |
Write constructor and destructor to h file.
f | file to write to |
is | indentation space |
classname | name of class |
Definition at line 530 of file cpp_generator.cpp.
void CppInterfaceGenerator::write_deflector | ( | FILE * | f | ) |
Write header deflector.
f | file to write to |
Definition at line 204 of file cpp_generator.cpp.
void CppInterfaceGenerator::write_enum_constants_tostring_cpp | ( | FILE * | f | ) |
Write enum constant tostring methods to cpp file.
f | file to write to |
Definition at line 287 of file cpp_generator.cpp.
void CppInterfaceGenerator::write_enum_map_population | ( | FILE * | f | ) |
void CppInterfaceGenerator::write_enum_maps_h | ( | FILE * | f | ) |
Write enum maps to header.
f | file to write to |
Definition at line 153 of file cpp_generator.cpp.
void CppInterfaceGenerator::write_enum_tostring_method_cpp | ( | FILE * | f | ) |
Write enum_tostring() method to CPP file.
f | file to write to |
Definition at line 493 of file cpp_generator.cpp.
void CppInterfaceGenerator::write_h | ( | FILE * | f | ) |
void CppInterfaceGenerator::write_header | ( | FILE * | f, |
std::string | filename | ||
) |
Write header to file.
f | file to write to |
filename | name of file |
Definition at line 167 of file cpp_generator.cpp.
void CppInterfaceGenerator::write_management_funcs_cpp | ( | FILE * | f | ) |
Write management functions.
f | file to write to |
Definition at line 250 of file cpp_generator.cpp.
void CppInterfaceGenerator::write_message_clone_method_cpp | ( | FILE * | f, |
std::string | classname | ||
) |
Write message clone method.
f | file to write to |
classname | name of message class |
Definition at line 593 of file cpp_generator.cpp.
void CppInterfaceGenerator::write_message_clone_method_h | ( | FILE * | f, |
std::string | is | ||
) |
Write message clone method header.
f | file to write to |
is | indentation space |
Definition at line 582 of file cpp_generator.cpp.
void CppInterfaceGenerator::write_message_ctor_dtor_cpp | ( | FILE * | f, |
std::string | classname, | ||
std::string | super_class, | ||
std::string | inclusion_prefix, | ||
std::vector< InterfaceField > | fields | ||
) |
Write constructor and destructor for message to cpp file.
f | file to write to |
classname | name of class |
super_class | name of base class |
inclusion_prefix | Used if class is included in another class. |
fields | vector of data fields of message |
Definition at line 751 of file cpp_generator.cpp.
void CppInterfaceGenerator::write_message_ctor_dtor_h | ( | FILE * | f, |
std::string | is, | ||
std::string | classname, | ||
std::vector< InterfaceField > | fields | ||
) |
Write constructor and destructor for message to h file.
f | file to write to |
is | indentation space |
classname | name of class |
fields | vector of data fields of message |
Definition at line 548 of file cpp_generator.cpp.
void CppInterfaceGenerator::write_messages_cpp | ( | FILE * | f | ) |
Write messages to cpp file.
f | file to write to |
Definition at line 388 of file cpp_generator.cpp.
void CppInterfaceGenerator::write_messages_h | ( | FILE * | f | ) |
Write messages to h file.
f | file to write to |
Definition at line 358 of file cpp_generator.cpp.
void CppInterfaceGenerator::write_methods_cpp | ( | FILE * | f, |
std::string | interface_classname, | ||
std::string | classname, | ||
std::vector< InterfaceField > | fields, | ||
std::string | inclusion_prefix, | ||
bool | write_data_changed | ||
) |
Write methods to cpp file.
f | file to write to |
interface_classname | name of the interface class |
classname | name of class (can be interface or message) |
fields | fields |
inclusion_prefix | used if class is included in another class. |
write_data_changed | if true writes code that sets the interface's data_changed flag. Set to true for interface methods, false for message methods. |
Definition at line 874 of file cpp_generator.cpp.
void CppInterfaceGenerator::write_methods_cpp | ( | FILE * | f, |
std::string | interface_classname, | ||
std::string | classname, | ||
std::vector< InterfaceField > | fields, | ||
std::vector< InterfacePseudoMap > | pseudo_maps, | ||
std::string | inclusion_prefix | ||
) |
Write methods to cpp file including pseudo maps.
f | file to write to |
interface_classname | name of the interface class |
classname | name of class (can be interface or message) |
fields | fields |
pseudo_maps | pseudo maps |
inclusion_prefix | used if class is included in another class. |
Definition at line 1012 of file cpp_generator.cpp.
void CppInterfaceGenerator::write_methods_h | ( | FILE * | f, |
std::string | is, | ||
std::vector< InterfaceField > | fields | ||
) |
Write methods to h file.
f | file to write to |
is | indentation space. |
fields | fields to write accessor methods for. |
Definition at line 1089 of file cpp_generator.cpp.
void CppInterfaceGenerator::write_methods_h | ( | FILE * | f, |
std::string | is, | ||
std::vector< InterfaceField > | fields, | ||
std::vector< InterfacePseudoMap > | pseudo_maps | ||
) |
Write methods to h file.
f | file to write to |
is | indentation space. |
fields | fields to write accessor methods for. |
pseudo_maps | pseudo maps |
Definition at line 1129 of file cpp_generator.cpp.
void CppInterfaceGenerator::write_struct | ( | FILE * | f, |
std::string | name, | ||
std::string | is, | ||
std::vector< InterfaceField > | fields | ||
) |
Write optimized struct.
Create struct, try align data well, sort fields:
f | file to write to |
name | name of struct |
is | indentation space |
fields | fields for struct |
Definition at line 125 of file cpp_generator.cpp.