#include <wireshark_generator.h>
Inheritance diagram for wireshark_generator:
Public Member Functions | |
wireshark_generator () | |
bool | gen_enum (AST_Enum *, UTL_ScopedName *name, const std::vector< AST_EnumVal * > &contents, const char *repoid) |
bool | gen_struct (AST_Structure *, UTL_ScopedName *name, const std::vector< AST_Field * > &fields, AST_Type::SIZE_TYPE size, const char *repoid) |
bool | gen_typedef (AST_Typedef *, UTL_ScopedName *, AST_Type *, const char *) |
bool | gen_union (AST_Union *, UTL_ScopedName *, const std::vector< AST_UnionBranch * > &, AST_Type *, const char *) |
Private Member Functions | |
void | write_common (UTL_ScopedName *name, const char *kind, const char *repoid) |
void | gen_array (UTL_ScopedName *tdname, AST_Array *arr) |
Definition at line 14 of file wireshark_generator.h.
wireshark_generator::wireshark_generator | ( | ) | [inline] |
void wireshark_generator::gen_array | ( | UTL_ScopedName * | tdname, | |
AST_Array * | arr | |||
) | [private] |
Definition at line 45 of file wireshark_generator.cpp.
References be_global, scoped(), and BE_GlobalData::ws_config_.
Referenced by gen_typedef().
00046 { 00047 std::string elem = scoped(arr->base_type()->name()); 00048 const char *ident = name->last_component()->get_string(); 00049 00050 be_global->ws_config_ << ident << ".element = \"" << elem << "\"\n"; 00051 ACE_CDR::ULong dims = arr->n_dims(); 00052 if (dims > 1) 00053 { 00054 be_global->ws_config_ << ident << ".dimensions = " << dims << "\n"; 00055 be_global->ws_config_ << ident << ".sizes = \""; 00056 } 00057 else 00058 { 00059 be_global->ws_config_ << ident << ".size = "; 00060 } 00061 00062 for (size_t i = 0; i < dims; ++i) { 00063 be_global->ws_config_ << arr->dims()[i]->ev()->u.ulval; 00064 if ((i+1) < dims) 00065 be_global->ws_config_ << " "; 00066 } 00067 00068 if (dims > 1) 00069 { 00070 be_global->ws_config_ << "\""; 00071 } 00072 be_global->ws_config_ << "\n"; 00073 00074 }
bool wireshark_generator::gen_enum | ( | AST_Enum * | , | |
UTL_ScopedName * | name, | |||
const std::vector< AST_EnumVal * > & | contents, | |||
const char * | repoid | |||
) | [virtual] |
Reimplemented from dds_generator.
Definition at line 26 of file wireshark_generator.cpp.
References be_global, BE_GlobalData::generate_wireshark(), write_common(), and BE_GlobalData::ws_config_.
00028 { 00029 if (!be_global->generate_wireshark()) 00030 return true; 00031 00032 write_common (name, "enum", repoid); 00033 be_global->ws_config_ << name->last_component()->get_string() 00034 << ".order = \""; 00035 00036 for (size_t i = 0; i < contents.size(); ++i) { 00037 be_global->ws_config_ << contents[i]->local_name()->get_string(); 00038 if ((i+1) < contents.size()) 00039 be_global->ws_config_<< " "; 00040 } 00041 be_global->ws_config_ << "\"\n"; 00042 return true; 00043 }
bool wireshark_generator::gen_struct | ( | AST_Structure * | , | |
UTL_ScopedName * | name, | |||
const std::vector< AST_Field * > & | fields, | |||
AST_Type::SIZE_TYPE | size, | |||
const char * | repoid | |||
) | [virtual] |
Implements dds_generator.
Definition at line 148 of file wireshark_generator.cpp.
References be_global, BE_GlobalData::generate_wireshark(), orderstrm, write_common(), write_field(), and BE_GlobalData::ws_config_.
00151 { 00152 if (!be_global->generate_wireshark()) 00153 return true; 00154 00155 write_common (name, "struct", repoid); 00156 00157 std::for_each (fields.begin(), fields.end(), write_field); 00158 00159 be_global->ws_config_ << name->last_component()->get_string() 00160 << ".order = \"" 00161 << orderstrm.str() << "\"\n"; 00162 orderstrm.str(""); 00163 orderstrm.clear(); 00164 00165 return true; 00166 }
bool wireshark_generator::gen_typedef | ( | AST_Typedef * | , | |
UTL_ScopedName * | , | |||
AST_Type * | , | |||
const char * | ||||
) | [virtual] |
Implements dds_generator.
Definition at line 77 of file wireshark_generator.cpp.
References be_global, gen_array(), BE_GlobalData::generate_wireshark(), scoped(), write_common(), and BE_GlobalData::ws_config_.
00079 { 00080 if (!be_global->generate_wireshark()) 00081 return true; 00082 switch (base->node_type()) { 00083 case AST_Decl::NT_sequence: 00084 { 00085 AST_Sequence *seq = AST_Sequence::narrow_from_decl(base); 00086 write_common (name, "sequence", repoid); 00087 be_global->ws_config_ << name->last_component()->get_string() 00088 << ".element = \"" 00089 << scoped(seq->base_type()->name()) 00090 << "\"\n"; 00091 break; 00092 } 00093 case AST_Decl::NT_array: 00094 { 00095 write_common (name, "array", repoid); 00096 gen_array(name, AST_Array::narrow_from_decl(base)); 00097 break; 00098 } 00099 default: 00100 { 00101 write_common (name, "alias", repoid); 00102 be_global->ws_config_ << name->last_component()->get_string() 00103 << ".base = \"" 00104 << scoped(base->name()) 00105 << "\"\n"; 00106 00107 return true; 00108 } 00109 } 00110 return true; 00111 }
bool wireshark_generator::gen_union | ( | AST_Union * | , | |
UTL_ScopedName * | , | |||
const std::vector< AST_UnionBranch * > & | , | |||
AST_Type * | , | |||
const char * | ||||
) | [virtual] |
Implements dds_generator.
Definition at line 169 of file wireshark_generator.cpp.
References be_global, BE_GlobalData::generate_wireshark(), orderstrm, scoped(), write_branch(), write_common(), and BE_GlobalData::ws_config_.
00173 { 00174 if (!be_global->generate_wireshark()) 00175 return true; 00176 00177 write_common (name, "union", repoid); 00178 const char *ident = name->last_component()->get_string(); 00179 00180 be_global->ws_config_ << ident << ".discriminator = \"" 00181 << scoped(_d->name()) << "\"\n"; 00182 00183 std::for_each (cases.begin(), cases.end(), write_branch); 00184 00185 be_global->ws_config_ << ident << ".order = \"" 00186 << orderstrm.str() << "\"\n"; 00187 orderstrm.str(""); 00188 orderstrm.clear(); 00189 00190 return true; 00191 }
void wireshark_generator::write_common | ( | UTL_ScopedName * | name, | |
const char * | kind, | |||
const char * | repoid | |||
) | [private] |
Definition at line 16 of file wireshark_generator.cpp.
References be_global, dds_generator::scoped_helper(), and BE_GlobalData::ws_config_.
Referenced by gen_enum(), gen_struct(), gen_typedef(), and gen_union().
00019 { 00020 const char *ident = name->last_component()->get_string(); 00021 be_global->ws_config_ << "\n[" << scoped_helper(name, "/") << "]\n"; 00022 be_global->ws_config_ << ident << ".kind = \"" << kind << "\"\n"; 00023 be_global->ws_config_ << ident << ".repoid = \"" << repoid << "\"\n"; 00024 }