OpenDDS  Snapshot(2023/04/07-19:43)
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
FieldInfo Struct Reference

#include <field_info.h>

Collaboration diagram for FieldInfo:
Collaboration graph
[legend]

Classes

struct  EleLen
 

Public Types

typedef std::set< EleLenEleLenSet
 

Public Member Functions

 FieldInfo (AST_Field &field)
 
bool is_new (EleLenSet &el_set) const
 
bool anonymous () const
 

Static Public Member Functions

static bool cxx11 ()
 
static std::string at_pfx ()
 
static std::string scoped_type (AST_Type &field_type, const std::string &field_name)
 
static std::string underscore (const std::string &scoped)
 
static std::string ref (const std::string &scoped, const std::string &const_s="const ")
 

Public Attributes

AST_Type * type_
 
const std::string name_
 
const std::string scoped_type_
 
const std::string underscored_
 
const std::string struct_name_
 
const std::string type_name_
 
AST_Type * act_
 
const AstTypeClassification::Classification cls_
 
AST_Array * arr_
 
AST_Sequence * seq_
 
AST_Type * as_base_
 
AST_Type * as_act_
 
const AstTypeClassification::Classification as_cls_
 
const std::string scoped_elem_
 
const std::string underscored_elem_
 
const std::string elem_ref_
 
const std::string elem_const_ref_
 
std::size_t n_elems_
 
std::string length_
 
std::string unwrap_
 
std::string const_unwrap_
 
std::string arg_
 
std::string ref_
 
std::string const_ref_
 
std::string ptr_
 

Static Public Attributes

static const std::string scope_op = "::"
 

Detailed Description

Definition at line 20 of file field_info.h.

Member Typedef Documentation

◆ EleLenSet

typedef std::set<EleLen> FieldInfo::EleLenSet

Definition at line 31 of file field_info.h.

Constructor & Destructor Documentation

◆ FieldInfo()

FieldInfo::FieldInfo ( AST_Field &  field)
explicit

Definition at line 87 of file field_info.cpp.

References arg_, arr_, const_ref_, const_unwrap_, cxx11(), length_, n_elems_, ptr_, ref(), ref_, scoped_type_, seq_, and unwrap_.

88  : type_(field.field_type())
89  , name_(field.local_name()->get_string())
92  , struct_name_(scoped_type_.substr(0, scoped_type_.rfind(scope_op)))
93  , type_name_(scoped_type_.substr(scoped_type_.rfind(scope_op) + 2))
95  , cls_(classify(act_))
96  , arr_(dynamic_cast<AST_Array*>(type_))
97  , seq_(dynamic_cast<AST_Sequence*>(type_))
101  , scoped_elem_(as_base_ ? scoped(as_base_->name()) : "")
103  , elem_ref_(as_base_ ? ref(scoped_elem_, "") : "")
106 {
107  if (arr_) {
108  std::ostringstream os;
109  os << n_elems_;
110  length_ = os.str();
111  arg_ = "arr";
112  } else if (seq_) {
113  length_ = "length";
114  arg_ = "seq";
115  }
116 
117  if (cxx11()) {
118  unwrap_ = scoped_type_ + "& " + arg_ + " = wrap;\n ACE_UNUSED_ARG(" + arg_ + ");\n";
119  const_unwrap_ = " const " + unwrap_;
120  unwrap_ = " " + unwrap_;
121  arg_ = "wrap";
122  ref_ = ref(scoped_type_, "");
124  ptr_ = ref_ + '*';
125  } else {
126  ref_ = scoped_type_ + (arr_ ? "_forany&" : "&");
127  const_ref_ = "const " + ref_;
128  ptr_ = scoped_type_ + (arr_ ? "_forany*" : "*");
129  }
130 }
const std::string elem_ref_
Definition: field_info.h:55
std::string ptr_
Definition: field_info.h:66
const std::string name_
Definition: field_info.h:41
const Classification CL_UNKNOWN
AST_Array * arr_
Definition: field_info.h:48
const std::string struct_name_
Definition: field_info.h:44
AST_Type * act_
Definition: field_info.h:46
AST_Type * resolveActualType(AST_Type *element)
const std::string scoped_type_
Definition: field_info.h:42
std::string const_ref_
Definition: field_info.h:65
std::size_t n_elems_
Definition: field_info.h:58
Classification classify(AST_Type *type)
ACE_CDR::ULong container_element_limit(AST_Type *type)
const std::string scoped_elem_
Definition: field_info.h:53
std::string unwrap_
Definition: field_info.h:61
const std::string underscored_
Definition: field_info.h:43
std::string scoped(UTL_ScopedName *sn, EscapeContext ec=EscapeContext_Normal)
AST_Type * as_base_
Definition: field_info.h:50
AST_Type * as_act_
Definition: field_info.h:51
static bool cxx11()
Definition: field_info.cpp:50
const AstTypeClassification::Classification as_cls_
Definition: field_info.h:52
static std::string scoped_type(AST_Type &field_type, const std::string &field_name)
Definition: field_info.cpp:60
const AstTypeClassification::Classification cls_
Definition: field_info.h:47
AST_Type * container_base_type(AST_Type *type)
std::string ref_
Definition: field_info.h:64
static std::string underscore(const std::string &scoped)
Definition: field_info.cpp:70
AST_Sequence * seq_
Definition: field_info.h:49
std::string length_
Definition: field_info.h:59
const std::string elem_const_ref_
Definition: field_info.h:56
const std::string underscored_elem_
Definition: field_info.h:54
AST_Type * type_
Definition: field_info.h:40
const std::string type_name_
Definition: field_info.h:45
static const std::string scope_op
Definition: field_info.h:33
std::string const_unwrap_
Definition: field_info.h:62
std::string arg_
Definition: field_info.h:63
static std::string ref(const std::string &scoped, const std::string &const_s="const ")
Definition: field_info.cpp:82

Member Function Documentation

◆ anonymous()

bool FieldInfo::anonymous ( ) const

Definition at line 137 of file field_info.cpp.

References as_base_, AstTypeClassification::CL_ARRAY, AstTypeClassification::CL_SEQUENCE, cls_, and type_.

Referenced by marshal_generator::gen_typedef().

138 {
139  return type_->anonymous() && as_base_ && (cls_ & (CL_ARRAY | CL_SEQUENCE));
140 }
const Classification CL_ARRAY
const Classification CL_SEQUENCE
AST_Type * as_base_
Definition: field_info.h:50
const AstTypeClassification::Classification cls_
Definition: field_info.h:47
AST_Type * type_
Definition: field_info.h:40

◆ at_pfx()

std::string FieldInfo::at_pfx ( )
static

Definition at line 55 of file field_info.cpp.

References cxx11().

Referenced by scoped_type().

56 {
57  return cxx11() ? "AnonymousType_" : "_";
58 }
static bool cxx11()
Definition: field_info.cpp:50

◆ cxx11()

bool FieldInfo::cxx11 ( )
static

Definition at line 50 of file field_info.cpp.

References be_global.

Referenced by at_pfx(), FieldInfo(), and is_new().

51 {
52  return be_global->language_mapping() == BE_GlobalData::LANGMAP_CXX11;
53 }
BE_GlobalData * be_global
Definition: be_global.cpp:43

◆ is_new()

bool FieldInfo::is_new ( EleLenSet el_set) const

Definition at line 132 of file field_info.cpp.

References cxx11(), and type_.

Referenced by marshal_generator::gen_struct(), and metaclass_generator::gen_struct().

133 {
134  return cxx11() || el_set.insert(EleLen(type_)).second;
135 }
static bool cxx11()
Definition: field_info.cpp:50
AST_Type * type_
Definition: field_info.h:40

◆ ref()

std::string FieldInfo::ref ( const std::string &  scoped,
const std::string &  const_s = "const " 
)
static

Definition at line 82 of file field_info.cpp.

References dds_generator::get_tag_name().

Referenced by FieldInfo().

83 {
84  return "IDL::DistinctType<" + const_s + scoped + ", " + dds_generator::get_tag_name(scoped) + ">";
85 }
static std::string get_tag_name(const std::string &base_name, bool nested_key_only=false)
std::string scoped(UTL_ScopedName *sn, EscapeContext ec=EscapeContext_Normal)

◆ scoped_type()

std::string FieldInfo::scoped_type ( AST_Type &  field_type,
const std::string &  field_name 
)
static

Definition at line 60 of file field_info.cpp.

References at_pfx(), scope_op, and scoped().

61 {
62  std::string n = scoped(field_type.name());
63  if (!field_type.anonymous()) {
64  return n;
65  }
66  n = n.substr(0, n.rfind(scope_op) + 2) + at_pfx() + field_name;
67  return (field_type.node_type() == AST_Decl::NT_sequence) ? (n + "_seq") : n;
68 }
static std::string at_pfx()
Definition: field_info.cpp:55
std::string scoped(UTL_ScopedName *sn, EscapeContext ec=EscapeContext_Normal)
static const std::string scope_op
Definition: field_info.h:33

◆ underscore()

std::string FieldInfo::underscore ( const std::string &  scoped)
static

Definition at line 70 of file field_info.cpp.

References scope_op, and scoped().

71 {
72  std::string s = scoped;
73  if (s.find(scope_op) == 1) {
74  s = s.substr(3);
75  }
76  for (std::size_t i = s.find(scope_op); i != s.npos; i = s.find(scope_op, i + 2)) {
77  s.replace(i, 2, "_");
78  }
79  return s;
80 }
std::string scoped(UTL_ScopedName *sn, EscapeContext ec=EscapeContext_Normal)
static const std::string scope_op
Definition: field_info.h:33

Member Data Documentation

◆ act_

AST_Type* FieldInfo::act_

Definition at line 46 of file field_info.h.

Referenced by Cxx11Generator::gen_struct_members().

◆ arg_

std::string FieldInfo::arg_

Definition at line 63 of file field_info.h.

Referenced by FieldInfo().

◆ arr_

AST_Array* FieldInfo::arr_

◆ as_act_

AST_Type* FieldInfo::as_act_

Definition at line 51 of file field_info.h.

Referenced by metaclass_generator::gen_struct().

◆ as_base_

AST_Type* FieldInfo::as_base_

◆ as_cls_

const AstTypeClassification::Classification FieldInfo::as_cls_

Definition at line 52 of file field_info.h.

◆ cls_

Definition at line 47 of file field_info.h.

Referenced by anonymous(), and Cxx11Generator::gen_struct_members().

◆ const_ref_

std::string FieldInfo::const_ref_

Definition at line 65 of file field_info.h.

Referenced by FieldInfo().

◆ const_unwrap_

std::string FieldInfo::const_unwrap_

Definition at line 62 of file field_info.h.

Referenced by FieldInfo().

◆ elem_const_ref_

const std::string FieldInfo::elem_const_ref_

Definition at line 56 of file field_info.h.

◆ elem_ref_

const std::string FieldInfo::elem_ref_

Definition at line 55 of file field_info.h.

◆ length_

std::string FieldInfo::length_

Definition at line 59 of file field_info.h.

Referenced by FieldInfo(), and metaclass_generator::gen_struct().

◆ n_elems_

std::size_t FieldInfo::n_elems_

Definition at line 58 of file field_info.h.

Referenced by FieldInfo().

◆ name_

const std::string FieldInfo::name_

◆ ptr_

std::string FieldInfo::ptr_

◆ ref_

std::string FieldInfo::ref_

Definition at line 64 of file field_info.h.

Referenced by FieldInfo().

◆ scope_op

const std::string FieldInfo::scope_op = "::"
static

Definition at line 33 of file field_info.h.

Referenced by FieldInfo::EleLen::operator<(), scoped_type(), and underscore().

◆ scoped_elem_

const std::string FieldInfo::scoped_elem_

Definition at line 53 of file field_info.h.

◆ scoped_type_

const std::string FieldInfo::scoped_type_

Definition at line 42 of file field_info.h.

Referenced by FieldInfo(), and marshal_generator::gen_typedef().

◆ seq_

AST_Sequence* FieldInfo::seq_

◆ struct_name_

const std::string FieldInfo::struct_name_

Definition at line 44 of file field_info.h.

◆ type_

AST_Type* FieldInfo::type_

◆ type_name_

const std::string FieldInfo::type_name_

Definition at line 45 of file field_info.h.

Referenced by Cxx11Generator::gen_struct_members(), and GeneratorBase::map_type().

◆ underscored_

const std::string FieldInfo::underscored_

Definition at line 43 of file field_info.h.

◆ underscored_elem_

const std::string FieldInfo::underscored_elem_

Definition at line 54 of file field_info.h.

◆ unwrap_

std::string FieldInfo::unwrap_

Definition at line 61 of file field_info.h.

Referenced by FieldInfo().


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