OpenDDS  Snapshot(2023/04/07-19:43)
Public Member Functions | List of all members
keys_generator Class Reference

#include <keys_generator.h>

Inheritance diagram for keys_generator:
Inheritance graph
[legend]
Collaboration diagram for keys_generator:
Collaboration graph
[legend]

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 *node, UTL_ScopedName *name, const std::vector< AST_UnionBranch *> &, AST_Type *, const char *)
 
- Public Member Functions inherited from dds_generator
virtual ~dds_generator ()=0
 
virtual bool do_included_files () const
 
virtual void gen_prologue ()
 
virtual void gen_epilogue ()
 
virtual bool gen_const (UTL_ScopedName *, bool, AST_Constant *)
 
virtual bool gen_enum (AST_Enum *, UTL_ScopedName *, const std::vector< AST_EnumVal *> &, const char *)
 
virtual bool gen_struct_fwd (UTL_ScopedName *, AST_Type::SIZE_TYPE)
 
virtual bool gen_interf (AST_Interface *, UTL_ScopedName *, bool, const std::vector< AST_Interface *> &, const std::vector< AST_Interface *> &, const std::vector< AST_Attribute *> &, const std::vector< AST_Operation *> &, const char *)
 
virtual bool gen_interf_fwd (UTL_ScopedName *)
 
virtual bool gen_native (AST_Native *, UTL_ScopedName *, const char *)
 
virtual bool gen_union_fwd (AST_UnionFwd *, UTL_ScopedName *, AST_Type::SIZE_TYPE)
 

Additional Inherited Members

- Static Public Member Functions inherited from dds_generator
static std::string get_tag_name (const std::string &base_name, bool nested_key_only=false)
 
static std::string get_xtag_name (UTL_ScopedName *name)
 
static bool cxx_escaped (const std::string &s)
 
static std::string valid_var_name (const std::string &str)
 
static std::string to_string (Identifier *id, EscapeContext ec=EscapeContext_Normal)
 
static std::string scoped_helper (UTL_ScopedName *sn, const char *sep, EscapeContext cxt=EscapeContext_Normal)
 
static std::string module_scope_helper (UTL_ScopedName *sn, const char *sep, EscapeContext cxt=EscapeContext_Normal)
 

Detailed Description

Definition at line 13 of file keys_generator.h.

Member Function Documentation

◆ gen_struct()

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 82 of file keys_generator.cpp.

References ACE_TEXT_ALWAYS_CHAR, be_global, TopicKeys::begin(), TopicKeys::count(), TopicKeys::end(), KeyLessThanWrapper::has_keys_signature(), KeyLessThanWrapper::has_no_keys_signature(), insert_cxx11_accessor_parens(), KeyLessThanWrapper::key_compare(), OpenDDS::XTypes::key_count(), TopicKeys::Iterator::path(), and TopicKeys::UnionType.

84 {
85  TopicKeys keys(node);
86  size_t key_count = 0;
87  const bool is_topic_type = be_global->is_topic_type(node);
88  IDL_GlobalData::DCPS_Data_Type_Info* info = idl_global->is_dcps_type(name);
89  if (is_topic_type) {
90  key_count = keys.count();
91  } else if (info) {
92  key_count = info->key_list_.size();
93  } else {
94  return true;
95  }
96 
97  {
98  KeyLessThanWrapper wrapper(name);
99 
100  if (key_count) {
101  const bool use_cxx11 = be_global->language_mapping() == BE_GlobalData::LANGMAP_CXX11;
102 
103  wrapper.has_keys_signature();
104  if (!use_cxx11) {
105  be_global->header_ <<
106  " using ::operator<; // TAO::String_Manager's operator< is "
107  "in global NS\n";
108  }
109 
110  if (is_topic_type) {
111  TopicKeys::Iterator finished = keys.end();
112  for (TopicKeys::Iterator i = keys.begin(); i != finished; ++i) {
113  string fname = i.path();
114  if (i.root_type() == TopicKeys::UnionType) {
115  fname += "._d()";
116  } else if (use_cxx11) {
117  fname = insert_cxx11_accessor_parens(fname, false);
118  }
119  wrapper.key_compare(fname);
120  }
121  } else if (info) {
122  IDL_GlobalData::DCPS_Data_Type_Info_Iter iter(info->key_list_);
123  for (ACE_TString* kp = 0; iter.next(kp) != 0; iter.advance()) {
124  string fname = ACE_TEXT_ALWAYS_CHAR(kp->c_str());
125  if (use_cxx11) {
126  fname = insert_cxx11_accessor_parens(fname, false);
127  }
128  wrapper.key_compare(fname);
129  }
130  }
131  } else {
132  wrapper.has_no_keys_signature();
133  }
134  }
135 
136  return true;
137 }
DDS::ReturnCode_t key_count(DDS::DynamicType_ptr type, size_t &count)
#define ACE_TEXT_ALWAYS_CHAR(STRING)
std::string insert_cxx11_accessor_parens(const std::string &full_var_name_, bool is_union_member=false)
const char *const name
Definition: debug.cpp:60
BE_GlobalData * be_global
Definition: be_global.cpp:43
std::string path()
Definition: topic_keys.cpp:335

◆ gen_typedef()

bool keys_generator::gen_typedef ( AST_Typedef *  ,
UTL_ScopedName *  ,
AST_Type *  ,
const char *   
)
inlinevirtual

Implements dds_generator.

Definition at line 19 of file keys_generator.h.

References gen_union().

20  { return true; }

◆ gen_union()

bool keys_generator::gen_union ( AST_Union *  node,
UTL_ScopedName *  name,
const std::vector< AST_UnionBranch *> &  ,
AST_Type *  ,
const char *   
)
virtual

Implements dds_generator.

Definition at line 139 of file keys_generator.cpp.

References be_global, KeyLessThanWrapper::has_keys_signature(), KeyLessThanWrapper::has_no_keys_signature(), and KeyLessThanWrapper::key_compare().

Referenced by gen_typedef().

142 {
143  if (be_global->is_topic_type(node)) {
144  KeyLessThanWrapper wrapper(name);
145  if (be_global->union_discriminator_is_key(node)) {
146  wrapper.has_keys_signature();
147  wrapper.key_compare("_d()");
148  } else {
149  wrapper.has_no_keys_signature();
150  }
151  }
152  return true;
153 }
const char *const name
Definition: debug.cpp:60
BE_GlobalData * be_global
Definition: be_global.cpp:43

The documentation for this class was generated from the following files: