#include <interfaces/generator/cpp_generator.h>
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. | |
~CppInterfaceGenerator () | |
Destructor. | |
void | write_h (FILE *f) |
Write h file. | |
void | write_cpp (FILE *f) |
Write cpp file. | |
void | write_constants_cpp (FILE *f) |
Write constants to cpp file. | |
void | write_constants_h (FILE *f) |
Write constants to h file. | |
void | write_enum_constants_tostring_cpp (FILE *f) |
Write enum constant tostring methods to cpp file. | |
void | write_messages_cpp (FILE *f) |
Write messages to cpp file. | |
void | write_messages_h (FILE *f) |
Write messages to h file. | |
void | write_ctor_dtor_h (FILE *f, std::stringis, std::string classname) |
Write constructor and destructor to h file. | |
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. | |
void | write_message_ctor_dtor_h (FILE *f, std::stringis, std::string classname, std::vector< InterfaceField > fields) |
Write constructor and destructor for message to h file. | |
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. | |
void | write_message_clone_method_h (FILE *f, std::string is) |
Write message clone method header. | |
void | write_message_clone_method_cpp (FILE *f, std::string classname) |
Write message clone method. | |
void | write_methods_h (FILE *f, std::stringis, std::vector< InterfaceField > fields) |
Write methods to h file. | |
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. | |
void | write_create_message_method_cpp (FILE *f) |
Write create_message() method to cpp file. | |
void | write_copy_value_method_cpp (FILE *f) |
Write copy_value() method to CPP file. | |
void | write_enum_tostring_method_cpp (FILE *f) |
Write enum_tostring() method to CPP file. | |
void | write_basemethods_h (FILE *f, std::string is) |
Write base methods header entries. | |
void | write_basemethods_cpp (FILE *f) |
Write base methods. | |
void | write_methods_h (FILE *f, std::stringis, std::vector< InterfaceField > fields, std::vector< InterfacePseudoMap > pseudo_maps) |
Write methods to h file. | |
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. | |
void | write_management_funcs_cpp (FILE *f) |
Write management functions. | |
void | write_add_fieldinfo_calls (FILE *f, std::vector< InterfaceField > &fields) |
Write the add_fieldinfo() calls. | |
void | write_struct (FILE *f, std::string name, std::stringis, std::vector< InterfaceField > fields) |
Write optimized struct. | |
void | write_header (FILE *f, std::string filename) |
Write header to file. | |
void | write_deflector (FILE *f) |
Write header deflector. | |
void | generate () |
Generator cpp and h files. |
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 | ( | ) |
void CppInterfaceGenerator::generate | ( | ) |
Generator cpp and h files.
Definition at line 1153 of file cpp_generator.cpp.
References write_cpp(), and write_h().
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 593 of file cpp_generator.cpp.
Referenced by write_ctor_dtor_cpp(), and write_message_ctor_dtor_cpp().
void CppInterfaceGenerator::write_basemethods_cpp | ( | FILE * | f | ) |
Write base methods.
f | file to write to |
Definition at line 496 of file cpp_generator.cpp.
References write_copy_value_method_cpp(), write_create_message_method_cpp(), and write_enum_tostring_method_cpp().
Referenced by write_cpp().
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 1099 of file cpp_generator.cpp.
Referenced by write_h().
void CppInterfaceGenerator::write_constants_cpp | ( | FILE * | f | ) |
Write constants to cpp file.
f | file to write to |
Definition at line 251 of file cpp_generator.cpp.
Referenced by write_cpp().
void CppInterfaceGenerator::write_constants_h | ( | FILE * | f | ) |
Write constants to h file.
f | file to write to |
Definition at line 305 of file cpp_generator.cpp.
Referenced by write_h().
void CppInterfaceGenerator::write_copy_value_method_cpp | ( | FILE * | f | ) |
Write copy_value() method to CPP file.
f | file to write to |
Definition at line 449 of file cpp_generator.cpp.
Referenced by write_basemethods_cpp().
void CppInterfaceGenerator::write_cpp | ( | FILE * | f | ) |
Write cpp file.
f | file to write to |
Definition at line 204 of file cpp_generator.cpp.
References write_basemethods_cpp(), write_constants_cpp(), write_ctor_dtor_cpp(), write_enum_constants_tostring_cpp(), write_header(), write_management_funcs_cpp(), write_messages_cpp(), and write_methods_cpp().
Referenced by generate().
void CppInterfaceGenerator::write_create_message_method_cpp | ( | FILE * | f | ) |
Write create_message() method to cpp file.
f | file to write to |
Definition at line 413 of file cpp_generator.cpp.
Referenced by write_basemethods_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 652 of file cpp_generator.cpp.
References write_add_fieldinfo_calls().
Referenced by write_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 510 of file cpp_generator.cpp.
Referenced by write_h(), and write_message_ctor_dtor_h().
void CppInterfaceGenerator::write_deflector | ( | FILE * | f | ) |
Write header deflector.
f | file to write to |
Definition at line 193 of file cpp_generator.cpp.
Referenced by write_h().
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 274 of file cpp_generator.cpp.
Referenced by write_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 473 of file cpp_generator.cpp.
Referenced by write_basemethods_cpp().
void CppInterfaceGenerator::write_h | ( | FILE * | f | ) |
Write h file.
f | file to write to |
Definition at line 1112 of file cpp_generator.cpp.
References write_basemethods_h(), write_constants_h(), write_ctor_dtor_h(), write_deflector(), write_header(), write_messages_h(), write_methods_h(), and write_struct().
Referenced by generate().
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 156 of file cpp_generator.cpp.
Referenced by write_cpp(), and write_h().
void CppInterfaceGenerator::write_management_funcs_cpp | ( | FILE * | f | ) |
Write management functions.
f | file to write to |
Definition at line 237 of file cpp_generator.cpp.
Referenced by write_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 573 of file cpp_generator.cpp.
Referenced by write_messages_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 562 of file cpp_generator.cpp.
Referenced by write_messages_h().
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 706 of file cpp_generator.cpp.
References write_add_fieldinfo_calls().
Referenced by write_messages_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 528 of file cpp_generator.cpp.
References write_ctor_dtor_h().
Referenced by write_messages_h().
void CppInterfaceGenerator::write_messages_cpp | ( | FILE * | f | ) |
Write messages to cpp file.
f | file to write to |
Definition at line 368 of file cpp_generator.cpp.
References write_message_clone_method_cpp(), write_message_ctor_dtor_cpp(), and write_methods_cpp().
Referenced by write_cpp().
void CppInterfaceGenerator::write_messages_h | ( | FILE * | f | ) |
Write messages to h file.
f | file to write to |
Definition at line 340 of file cpp_generator.cpp.
References write_message_clone_method_h(), write_message_ctor_dtor_h(), write_methods_h(), and write_struct().
Referenced by write_h().
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 959 of file cpp_generator.cpp.
References write_methods_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 827 of file cpp_generator.cpp.
Referenced by write_cpp(), write_messages_cpp(), and write_methods_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 1076 of file cpp_generator.cpp.
References write_methods_h().
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 1036 of file cpp_generator.cpp.
Referenced by write_h(), write_messages_h(), and write_methods_h().
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: 1. unsigned int 2. int 3. unsigned long int 4. long int 5. float 6. double 7. bool 8. byte 8. string
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.
Referenced by write_h(), and write_messages_h().