#include <keys_generator.h>
Public Member Functions | |
bool | gen_struct (AST_Structure *node, 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 *) |
Definition at line 13 of file keys_generator.h.
bool keys_generator::gen_struct | ( | AST_Structure * | node, | |
UTL_ScopedName * | name, | |||
const std::vector< AST_Field * > & | fields, | |||
AST_Type::SIZE_TYPE | size, | |||
const char * | repoid | |||
) | [virtual] |
Implements dds_generator.
Definition at line 16 of file keys_generator.cpp.
References ACE_TEXT_ALWAYS_CHAR, be_global, scoped(), dds_generator::scoped_helper(), and str.
00018 { 00019 string cxx = scoped(name), under = scoped_helper(name, "_"); 00020 IDL_GlobalData::DCPS_Data_Type_Info* info = idl_global->is_dcps_type(name); 00021 if (!info) { 00022 return true; 00023 } 00024 00025 const bool empty = info->key_list_.is_empty(); 00026 00027 be_global->header_ << be_global->versioning_begin() << "\n"; 00028 00029 { 00030 struct Namespaces { 00031 size_t n_; 00032 Namespaces(UTL_ScopedName* name) 00033 : n_(0) 00034 { 00035 for (UTL_ScopedName* sn = name; sn && sn->tail(); 00036 sn = static_cast<UTL_ScopedName*>(sn->tail())) { 00037 string str = sn->head()->get_string(); 00038 if (str.size()) { 00039 be_global->header_ << "namespace " << str << " {\n"; 00040 ++n_; 00041 } 00042 } 00043 } 00044 ~Namespaces() 00045 { 00046 for (size_t i = 0; i < n_; ++i) be_global->header_ << "}\n"; 00047 } 00048 } ns(name); 00049 00050 be_global->header_ << 00051 "// This structure supports use of std::map with a key\n" 00052 "// defined by one or more #pragma DCPS_DATA_KEY lines.\n" 00053 "struct " << be_global->export_macro() << ' ' << 00054 name->last_component()->get_string() << "_OpenDDS_KeyLessThan {\n"; 00055 00056 if (empty) 00057 { 00058 be_global->header_ << 00059 " bool operator()(const " << cxx << "&, const " << cxx 00060 << "&) const\n" 00061 " {\n" 00062 " // Eith no DCPS_DATA_KEYs, return false\n" 00063 " // to allow use of map with just one entry\n"; 00064 } 00065 else 00066 { 00067 be_global->header_ << 00068 " bool operator()(const " << cxx << "& v1, const " << cxx 00069 << "& v2) const\n" 00070 " {\n" 00071 " using ::operator<; // TAO::String_Manager's operator< is " 00072 "in global NS\n"; 00073 00074 IDL_GlobalData::DCPS_Data_Type_Info_Iter iter(info->key_list_); 00075 00076 for (ACE_TString* kp = 0; iter.next(kp) != 0; iter.advance()) { 00077 string fname = ACE_TEXT_ALWAYS_CHAR(kp->c_str()); 00078 be_global->header_ << 00079 " if (v1." << fname << " < v2." << fname << ") return true;\n" 00080 " if (v2." << fname << " < v1." << fname << ") return false;\n"; 00081 } 00082 } 00083 be_global->header_ << 00084 " return false;\n" 00085 " }\n};\n"; 00086 } 00087 be_global->header_ << be_global->versioning_end() << "\n"; 00088 return true; 00089 }
bool keys_generator::gen_typedef | ( | AST_Typedef * | , | |
UTL_ScopedName * | , | |||
AST_Type * | , | |||
const char * | ||||
) | [inline, virtual] |
bool keys_generator::gen_union | ( | AST_Union * | , | |
UTL_ScopedName * | , | |||
const std::vector< AST_UnionBranch * > & | , | |||
AST_Type * | , | |||
const char * | ||||
) | [inline, virtual] |