OpenDDS  Snapshot(2023/04/28-20:55)
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ts_generator Class Reference

#include <ts_generator.h>

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

Public Member Functions

 ts_generator ()
 
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)
 

Private Member Functions

bool generate_ts (AST_Decl *node, UTL_ScopedName *name)
 

Private Attributes

std::string idl_template_
 

Additional Inherited Members

- Static Public Member Functions inherited from dds_generator
static std::string get_tag_name (const std::string &base_name, const std::string &qualifier="")
 
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 23 of file ts_generator.h.

Constructor & Destructor Documentation

◆ ts_generator()

ts_generator::ts_generator ( )

Definition at line 63 of file ts_generator.cpp.

References ACE_TEXT_ALWAYS_CHAR, be_global, TopicKeys::begin(), and TopicKeys::end().

64  : idl_template_(read_template("IDL"))
65 {
66 }
std::string idl_template_
Definition: ts_generator.h:40

Member Function Documentation

◆ gen_struct()

bool ts_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 493 of file ts_generator.cpp.

References generate_ts().

495 {
496  return generate_ts(node, name);
497 }
const char *const name
Definition: debug.cpp:60
bool generate_ts(AST_Decl *node, UTL_ScopedName *name)

◆ gen_typedef()

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

Implements dds_generator.

Definition at line 31 of file ts_generator.h.

32  { return true; }

◆ gen_union()

bool ts_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 499 of file ts_generator.cpp.

References generate_ts().

501 {
502  return generate_ts(node, name);
503 }
const char *const name
Definition: debug.cpp:60
bool generate_ts(AST_Decl *node, UTL_ScopedName *name)

◆ generate_ts()

bool ts_generator::generate_ts ( AST_Decl *  node,
UTL_ScopedName *  name 
)
private

Definition at line 94 of file ts_generator.cpp.

References be_global, ACE_String_Base< char >::c_str(), TopicKeys::count(), EscapeContext_ForGenIdl, EscapeContext_FromGenIdl, EscapeContext_StripEscapes, face_ts_generator::generate(), dds_generator::get_xtag_name(), idl_template_, OpenDDS::XTypes::key_count(), ACE_String_Base< char >::length(), scoped(), dds_generator::scoped_helper(), and dds_generator::to_string().

Referenced by gen_struct(), and gen_union().

95 {
96  if (idl_template_.empty()) {
97  // error reported in read_template
98  return false;
99  }
100  if (!node || !name) {
101  return false;
102  }
103 
104  AST_Structure* struct_node = 0;
105  AST_Union* union_node = 0;
106  AST_Type::SIZE_TYPE size_type;
107  if (node->node_type() == AST_Decl::NT_struct) {
108  struct_node = dynamic_cast<AST_Structure*>(node);
109  size_type = struct_node->size_type();
110  } else if (node->node_type() == AST_Decl::NT_union) {
111  union_node = dynamic_cast<AST_Union*>(node);
112  size_type = union_node->size_type();
113  } else {
114  idl_global->err()->misc_error(
115  "Could not cast AST Nodes to valid types", node);
116  return false;
117  }
118 
119  size_t key_count = 0;
120  IDL_GlobalData::DCPS_Data_Type_Info* info = 0;
121  TopicKeys keys;
122  if (struct_node) {
123  info = idl_global->is_dcps_type(name);
124  if (be_global->is_topic_type(struct_node)) {
125  keys = TopicKeys(struct_node);
126  key_count = keys.count();
127  } else if (info) {
128  key_count = info->key_list_.size();
129  } else {
130  return true;
131  }
132  } else if (be_global->is_topic_type(union_node)) {
133  key_count = be_global->union_discriminator_is_key(union_node) ? 1 : 0;
134  } else {
135  return true;
136  }
137 
138  const std::string cxx_name = scoped(name);
139  const std::string short_name = name->last_component()->get_string();
140  const std::string ts_name = scoped(name, EscapeContext_FromGenIdl);
141  const std::string ts_short_name = to_string(
142  name->last_component(), EscapeContext_FromGenIdl);
143  const std::string unescaped_name =
145  const std::string name_underscores = dds_generator::scoped_helper(name, "_");
146  static const std::string ns("OpenDDS::DCPS::");
147  const std::string xtag = ns + get_xtag_name(name);
148 
149  static const char* idl_includes[] = {
150  "dds/DdsDcpsInfrastructure.idl", "dds/DdsDcpsTopic.idl",
151  "dds/DdsDcpsPublication.idl", "dds/DdsDcpsSubscriptionExt.idl",
152  "dds/DdsDcpsTypeSupportExt.idl"
153  };
154  add_includes(idl_includes, BE_GlobalData::STREAM_IDL);
155 
156  std::string dc = be_global->header_name_.c_str();
157  dc.replace(dc.end() - 6, dc.end() - 2, "C"); // s/Impl.h$/C.h/
158  be_global->add_include(dc.c_str());
159 
160  static const char* h_includes[] = {
161  "dds/DCPS/TypeSupportImpl.h", "dds/DCPS/ValueDispatcher.h"
162  };
163  add_includes(h_includes, BE_GlobalData::STREAM_H);
164 
165  static const char* cpp_includes[] = {
166  "dds/DCPS/debug.h", "dds/DCPS/Registered_Data_Types.h",
167  "dds/DdsDcpsDomainC.h", "dds/DCPS/Service_Participant.h",
168  "dds/DCPS/Qos_Helper.h", "dds/DCPS/PublicationInstance.h",
169  "dds/DCPS/PublisherImpl.h", "dds/DCPS/SubscriberImpl.h",
170  "dds/DCPS/ReceivedDataElementList.h", "dds/DCPS/RakeResults_T.h",
171  "dds/DCPS/BuiltInTopicUtils.h", "dds/DCPS/Util.h",
172  "dds/DCPS/ContentFilteredTopicImpl.h", "dds/DCPS/RakeData.h",
173  "dds/DCPS/MultiTopicDataReader_T.h", "dds/DCPS/DataWriterImpl_T.h",
174  "dds/DCPS/DataReaderImpl_T.h", "dds/DCPS/XTypes/TypeObject.h"
175  };
176  add_includes(cpp_includes, BE_GlobalData::STREAM_CPP);
177 
178  std::map<std::string, std::string> replacements;
179  replacements["SCOPED"] = scoped(name, EscapeContext_ForGenIdl);
180  // SCOPED_NOT_GLOBAL is EscapeContext_FromGenIdl, because
181  // DCPS_DATA_SEQUENCE_TYPE is strange.
182  replacements["SCOPED_NOT_GLOBAL"] =
184  replacements["TYPE"] = to_string(name->last_component(), EscapeContext_ForGenIdl);
185  replacements["EXPORT"] = be_global->export_macro().c_str();
186  replacements["SEQ"] = be_global->sequence_suffix().c_str();
187 
188  ScopedNamespaceGuard idlGuard(name, be_global->idl_, "module");
189  std::string idl = idl_template_;
190  replaceAll(idl, replacements);
191  be_global->idl_ << idl;
192 
193  be_global->header_ << be_global->versioning_begin() << "\n";
194  {
195  ScopedNamespaceGuard hGuard(name, be_global->header_);
196 
197  be_global->header_ <<
198  "class " << ts_short_name << "TypeSupportImpl;\n";
199  }
200  be_global->header_ << be_global->versioning_end() << "\n";
201 
202  be_global->header_ <<
203  "OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL\n"
204  "namespace OpenDDS {\n"
205  "namespace DCPS {\n"
206  "template <>\n"
207  "struct DDSTraits<" << cxx_name << "> {\n"
208  " typedef " << cxx_name << " MessageType;\n"
209  " typedef " << ts_name << be_global->sequence_suffix() << " MessageSequenceType;\n"
210  " typedef " << ts_name << be_global->sequence_suffix() << "::PrivateMemberAccess MessageSequenceAdapterType;\n"
211  " typedef " << ts_name << "TypeSupport TypeSupportType;\n"
212  " typedef " << ts_name << "TypeSupportImpl TypeSupportImplType;\n"
213  " typedef " << ts_name << "DataWriter DataWriterType;\n"
214  " typedef " << ts_name << "DataReader DataReaderType;\n"
215  " typedef " << cxx_name << "_OpenDDS_KeyLessThan LessThanType;\n"
216  " typedef OpenDDS::DCPS::KeyOnly<const " << cxx_name << "> KeyOnlyType;\n"
217  " typedef " << xtag << " XtagType;\n"
218  "\n"
219  " static const char* type_name() { return \"" << unescaped_name << "\"; }\n"
220  " static size_t key_count() { return " << key_count << "; }\n"
221  " static bool is_key(const char*);\n"
222  "};\n"
223  "} // namespace DCPS\n"
224  "} // namespace OpenDDS\n"
225  "OPENDDS_END_VERSIONED_NAMESPACE_DECL\n\n";
226 
227  be_global->impl_ <<
228  "OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL\n"
229  "namespace OpenDDS {\n"
230  "namespace DCPS {\n"
231  "bool DDSTraits<" << cxx_name << ">::is_key(const char* field)\n"
232  "{\n"
233  " ACE_UNUSED_ARG(field);\n";
234  if (struct_node && key_count) {
235  if (info) {
236  gen_isDcpsKey(info);
237  } else {
238  gen_isDcpsKey(keys);
239  }
240  }
241  be_global->impl_ <<
242  " return false;\n"
243  "}\n"
244  "} // namespace DCPS\n"
245  "} // namespace OpenDDS\n"
246  "OPENDDS_END_VERSIONED_NAMESPACE_DECL\n\n";
247 
248  be_global->header_ << be_global->versioning_begin() << "\n";
249  {
250  ScopedNamespaceGuard hGuard(name, be_global->header_);
251 
252  be_global->header_ <<
253  "class " << be_global->export_macro() << " " << ts_short_name << "TypeSupportImpl\n"
254  " : public virtual OpenDDS::DCPS::LocalObject<" << ts_short_name << "TypeSupport>\n"
255  " , public virtual OpenDDS::DCPS::TypeSupportImpl_T<" << short_name << ">\n"
256  " , public virtual OpenDDS::DCPS::ValueDispatcher_T<" << short_name << ">\n"
257  "{\n"
258  "public:\n"
259  " typedef " << ts_short_name << "TypeSupport TypeSupportType;\n"
260  " typedef " << ts_short_name << "TypeSupport::_var_type _var_type;\n"
261  " typedef " << ts_short_name << "TypeSupport::_ptr_type _ptr_type;\n"
262  "\n"
263  " " << ts_short_name << "TypeSupportImpl() {}\n"
264  " virtual ~" << ts_short_name << "TypeSupportImpl() {}\n"
265  "\n"
266  " virtual " << be_global->versioning_name() << "::DDS::DataWriter_ptr create_datawriter();\n"
267  " virtual " << be_global->versioning_name() << "::DDS::DataReader_ptr create_datareader();\n"
268  "#ifndef OPENDDS_NO_MULTI_TOPIC\n"
269  " virtual " << be_global->versioning_name() << "::DDS::DataReader_ptr create_multitopic_datareader();\n"
270  "#endif /* !OPENDDS_NO_MULTI_TOPIC */\n"
271  "#ifndef OPENDDS_NO_CONTENT_SUBSCRIPTION_PROFILE\n"
272  " virtual const OpenDDS::DCPS::MetaStruct& getMetaStructForType() const;\n"
273  "#endif /* !OPENDDS_NO_CONTENT_SUBSCRIPTION_PROFILE */\n"
274  "\n"
275  " virtual const OpenDDS::XTypes::TypeIdentifier& getMinimalTypeIdentifier() const;\n"
276  " virtual const OpenDDS::XTypes::TypeMap& getMinimalTypeMap() const;\n"
277  "\n"
278  " virtual const OpenDDS::XTypes::TypeIdentifier& getCompleteTypeIdentifier() const;\n"
279  " virtual const OpenDDS::XTypes::TypeMap& getCompleteTypeMap() const;\n"
280  "\n"
281  " ::DDS::ReturnCode_t encode_to_string(const " << short_name << "& in, CORBA::String_out out, OpenDDS::DCPS::RepresentationFormat* format);\n"
282  " ::DDS::ReturnCode_t encode_to_bytes(const " << short_name << "& in, ::DDS::OctetSeq_out out, OpenDDS::DCPS::RepresentationFormat* format);\n"
283  " ::DDS::ReturnCode_t decode_from_string(const char* in, " << short_name << "_out out, OpenDDS::DCPS::RepresentationFormat* format);\n"
284  " ::DDS::ReturnCode_t decode_from_bytes(const ::DDS::OctetSeq& in, " << short_name << "_out out, OpenDDS::DCPS::RepresentationFormat* format);\n"
285  "\n"
286  " static " << ts_short_name << "TypeSupport::_ptr_type _narrow(CORBA::Object_ptr obj);\n"
287  "};\n\n";
288  }
289  be_global->header_ << be_global->versioning_end() << "\n";
290 
291  be_global->impl_ << be_global->versioning_begin() << "\n";
292  {
293  ScopedNamespaceGuard cppGuard(name, be_global->impl_);
294  be_global->impl_ <<
295  "::DDS::DataWriter_ptr " << ts_short_name << "TypeSupportImpl::create_datawriter()\n"
296  "{\n"
297  " typedef OpenDDS::DCPS::DataWriterImpl_T<" << short_name << "> DataWriterImplType;\n"
298  " ::DDS::DataWriter_ptr writer_impl = ::DDS::DataWriter::_nil();\n"
299  " ACE_NEW_NORETURN(writer_impl,\n"
300  " DataWriterImplType());\n"
301  " return writer_impl;\n"
302  "}\n\n"
303  "::DDS::DataReader_ptr " << ts_short_name << "TypeSupportImpl::create_datareader()\n"
304  "{\n"
305  " typedef OpenDDS::DCPS::DataReaderImpl_T<" << short_name << "> DataReaderImplType;\n"
306  " ::DDS::DataReader_ptr reader_impl = ::DDS::DataReader::_nil();\n"
307  " ACE_NEW_NORETURN(reader_impl,\n"
308  " DataReaderImplType());\n"
309  " return reader_impl;\n"
310  "}\n\n"
311  "#ifndef OPENDDS_NO_MULTI_TOPIC\n"
312  "::DDS::DataReader_ptr " << ts_short_name << "TypeSupportImpl::create_multitopic_datareader()\n"
313  "{\n"
314  " typedef OpenDDS::DCPS::DataReaderImpl_T<" << short_name << "> DataReaderImplType;\n"
315  " typedef OpenDDS::DCPS::MultiTopicDataReader_T<" << short_name << ", DataReaderImplType> MultiTopicDataReaderImplType;\n"
316  " ::DDS::DataReader_ptr multitopic_reader_impl = ::DDS::DataReader::_nil();\n"
317  " ACE_NEW_NORETURN(multitopic_reader_impl,\n"
318  " MultiTopicDataReaderImplType());\n"
319  " return multitopic_reader_impl;\n"
320  "}\n"
321  "#endif /* !OPENDDS_NO_MULTI_TOPIC */\n\n"
322  "#ifndef OPENDDS_NO_CONTENT_SUBSCRIPTION_PROFILE\n"
323  "const OpenDDS::DCPS::MetaStruct& " << ts_short_name << "TypeSupportImpl::getMetaStructForType() const\n"
324  "{\n"
325  " return OpenDDS::DCPS::getMetaStruct<" << short_name << ">();\n"
326  "}\n"
327  "#endif /* !OPENDDS_NO_CONTENT_SUBSCRIPTION_PROFILE */\n\n"
328  "namespace {\n"
329  " OpenDDS::DCPS::TypeSupportInitializer<" << ts_short_name << "TypeSupportImpl> ts_init_" << name_underscores << ";\n"
330  "}\n"
331  "\n"
332  "const OpenDDS::XTypes::TypeIdentifier& " << ts_short_name << "TypeSupportImpl::getMinimalTypeIdentifier() const\n"
333  "{\n";
334 
335  const bool java_ts_only = be_global->java_arg().length() > 0;
336  const bool generate_xtypes = !be_global->suppress_xtypes() && !java_ts_only;
337  if (generate_xtypes) {
338  be_global->impl_ <<
339  " return OpenDDS::DCPS::getMinimalTypeIdentifier<" << xtag << ">();\n";
340  } else {
341  be_global->impl_ <<
342  " static OpenDDS::XTypes::TypeIdentifier ti;\n"
343  " return ti;\n";
344  }
345  be_global->impl_ <<
346  "}\n\n"
347  "const OpenDDS::XTypes::TypeMap& " << ts_short_name << "TypeSupportImpl::getMinimalTypeMap() const\n"
348  "{\n";
349 
350  if (generate_xtypes) {
351  be_global->impl_ <<
352  " return OpenDDS::DCPS::getMinimalTypeMap<" << xtag << ">();\n";
353  } else {
354  be_global->impl_ <<
355  " static OpenDDS::XTypes::TypeMap tm;\n"
356  " return tm;\n";
357  }
358  be_global->impl_ <<
359  "}\n\n"
360  "const OpenDDS::XTypes::TypeIdentifier& " << ts_short_name << "TypeSupportImpl::getCompleteTypeIdentifier() const\n"
361  "{\n";
362 
363  const bool generate_xtypes_complete = generate_xtypes && be_global->xtypes_complete();
364  if (generate_xtypes_complete) {
365  be_global->impl_ <<
366  " return OpenDDS::DCPS::getCompleteTypeIdentifier<" << xtag << ">();\n";
367  } else {
368  be_global->impl_ <<
369  " static OpenDDS::XTypes::TypeIdentifier ti;\n"
370  " return ti;\n";
371  }
372  be_global->impl_ <<
373  "}\n\n"
374  "const OpenDDS::XTypes::TypeMap& " << ts_short_name << "TypeSupportImpl::getCompleteTypeMap() const\n"
375  "{\n";
376 
377  if (generate_xtypes_complete) {
378  be_global->impl_ <<
379  " return OpenDDS::DCPS::getCompleteTypeMap<" << xtag << ">();\n";
380  } else {
381  be_global->impl_ <<
382  " static OpenDDS::XTypes::TypeMap tm;\n"
383  " return tm;\n";
384  }
385  be_global->add_cpp_include("dds/DCPS/JsonValueReader.h");
386  be_global->add_cpp_include("dds/DCPS/JsonValueWriter.h");
387  const bool alloc_out = be_global->language_mapping() != BE_GlobalData::LANGMAP_CXX11 && size_type == AST_Type::VARIABLE;
388  be_global->impl_ <<
389  "}\n\n"
390  "::DDS::ReturnCode_t " << ts_short_name << "TypeSupportImpl::encode_to_string(const " << short_name << "& in, CORBA::String_out out, OpenDDS::DCPS::RepresentationFormat* format)\n"
391  "{\n"
392  "#if OPENDDS_HAS_JSON_VALUE_WRITER\n"
393  " OpenDDS::DCPS::JsonRepresentationFormat_var jrf = OpenDDS::DCPS::JsonRepresentationFormat::_narrow(format);\n"
394  " if (jrf) {\n"
395  " rapidjson::StringBuffer buffer;\n"
396  " rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);\n"
397  " OpenDDS::DCPS::JsonValueWriter<rapidjson::Writer<rapidjson::StringBuffer> > jvw(writer);\n"
398  " vwrite(jvw, in);\n"
399  " out = buffer.GetString();\n"
400  " return ::DDS::RETCODE_OK;\n"
401  " }\n"
402  "#else\n"
403  " ACE_UNUSED_ARG(in);\n"
404  " ACE_UNUSED_ARG(format);\n"
405  "#endif\n"
406  " out = \"\";\n"
407  " return ::DDS::RETCODE_UNSUPPORTED;\n"
408  "}\n\n"
409  "::DDS::ReturnCode_t " << ts_short_name << "TypeSupportImpl::encode_to_bytes(const " << short_name << "& in, ::DDS::OctetSeq_out out, OpenDDS::DCPS::RepresentationFormat* format)\n"
410  "{\n"
411  "#if OPENDDS_HAS_JSON_VALUE_WRITER\n"
412  " OpenDDS::DCPS::JsonRepresentationFormat_var jrf = OpenDDS::DCPS::JsonRepresentationFormat::_narrow(format);\n"
413  " if (jrf) {\n"
414  " CORBA::String_var buffer;\n"
415  " const ::DDS::ReturnCode_t ret = encode_to_string(in, buffer, format);\n"
416  " if (ret == ::DDS::RETCODE_OK) {\n"
417  " const ::DDS::UInt32 len = static_cast< ::DDS::UInt32>(std::strlen(buffer));\n"
418  " out = new ::DDS::OctetSeq(len);\n"
419  " out->length(len);\n"
420  " std::memcpy(out->get_buffer(), buffer, len);\n"
421  " return ::DDS::RETCODE_OK;\n"
422  " } else {\n"
423  " out = new ::DDS::OctetSeq();\n"
424  " return ret;\n"
425  " }\n"
426  " }\n"
427  "#else\n"
428  " ACE_UNUSED_ARG(in);\n"
429  " ACE_UNUSED_ARG(format);\n"
430  "#endif\n"
431  " out = new ::DDS::OctetSeq();\n"
432  " return ::DDS::RETCODE_UNSUPPORTED;\n"
433  "}\n\n"
434  "::DDS::ReturnCode_t " << ts_short_name << "TypeSupportImpl::decode_from_string(const char* in, " << short_name << "_out " <<
435  (alloc_out ? "out" : "param") << ", OpenDDS::DCPS::RepresentationFormat* format)\n"
436  "{\n";
437 
438  if (alloc_out) {
439  be_global->impl_ << " out = new " << short_name << ";\n";
440  } else {
441  be_global->impl_ << " " << short_name << "* out = &param;\n";
442  }
443 
444  be_global->impl_ <<
445  " OpenDDS::DCPS::set_default(*out);\n"
446  "#if OPENDDS_HAS_JSON_VALUE_READER\n"
447  " OpenDDS::DCPS::JsonRepresentationFormat_var jrf = OpenDDS::DCPS::JsonRepresentationFormat::_narrow(format);\n"
448  " if (jrf) {\n"
449  " rapidjson::StringStream buffer(in);\n"
450  " OpenDDS::DCPS::JsonValueReader<> jvr(buffer);\n" <<
451  " return vread(jvr, *out) ? ::DDS::RETCODE_OK : ::DDS::RETCODE_ERROR;\n"
452  " }\n"
453  "#else\n"
454  " ACE_UNUSED_ARG(in);\n"
455  " ACE_UNUSED_ARG(format);\n"
456  "#endif\n"
457  " return ::DDS::RETCODE_UNSUPPORTED;\n"
458  "}\n\n"
459  "::DDS::ReturnCode_t " << ts_short_name << "TypeSupportImpl::decode_from_bytes(const ::DDS::OctetSeq& in, " << short_name << "_out out, OpenDDS::DCPS::RepresentationFormat* format)\n"
460  "{\n"
461  "#if OPENDDS_HAS_JSON_VALUE_READER\n"
462  " OpenDDS::DCPS::JsonRepresentationFormat_var jrf = OpenDDS::DCPS::JsonRepresentationFormat::_narrow(format);\n"
463  " if (jrf) {\n"
464  " return decode_from_string(reinterpret_cast<const char*>(in.get_buffer()), out, format);\n"
465  " }\n"
466  "#else\n"
467  " ACE_UNUSED_ARG(in);\n"
468  " ACE_UNUSED_ARG(format);\n"
469  "#endif\n"
470  " out = " << (alloc_out ? "new " : "") << short_name << "();\n"
471  " return ::DDS::RETCODE_UNSUPPORTED;\n"
472  "}\n\n"
473  << ts_short_name << "TypeSupport::_ptr_type " << ts_short_name << "TypeSupportImpl::_narrow(CORBA::Object_ptr obj)\n"
474  "{\n"
475  " return TypeSupportType::_narrow(obj);\n"
476  "}\n";
477  }
478  be_global->impl_ << be_global->versioning_end() << "\n";
479 
480  if (be_global->face_ts()) {
481  if (node->node_type() == AST_Decl::NT_struct) {
483  } else {
484  idl_global->err()->misc_error(
485  "Generating FACE type support for Union topic types is not supported", node);
486  return false;
487  }
488  }
489 
490  return true;
491 }
static std::string scoped_helper(UTL_ScopedName *sn, const char *sep, EscapeContext cxt=EscapeContext_Normal)
const char * c_str(void) const
static std::string get_xtag_name(UTL_ScopedName *name)
void generate(UTL_ScopedName *name)
std::string idl_template_
Definition: ts_generator.h:40
Strip any escapes.
Definition: dds_generator.h:43
size_t count()
Definition: topic_keys.cpp:515
static std::string to_string(Identifier *id, EscapeContext ec=EscapeContext_Normal)
This is for generated IDL. (Like *TypeSupport.idl)
Definition: dds_generator.h:39
This is for a name coming from generated IDL. (Like *TypeSupportC.h)
Definition: dds_generator.h:41
const char *const name
Definition: debug.cpp:60
std::string scoped(UTL_ScopedName *sn, EscapeContext ec=EscapeContext_Normal)
BE_GlobalData * be_global
Definition: be_global.cpp:44
size_type length(void) const
DDS::ReturnCode_t key_count(DDS::DynamicType_ptr type, size_t &count)

Member Data Documentation

◆ idl_template_

std::string ts_generator::idl_template_
private

Definition at line 40 of file ts_generator.h.

Referenced by generate_ts().


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