How to set struct member value to null?

2 posts / 0 new
Last post
Offline
Last seen: 5 years 1 month ago
Joined: 03/16/2016
Posts: 1
How to set struct member value to null?

I use DynamicData to build a TypeCode for a topic called "Track", and one of its member "Location" is a struct.When the Track topic is created, the Location field and its members are populated with default values. Is there a way to set this Location struct to null? 

Something like this:

 dynamicData.set_complex_member("Location", "1", null);

But this doesn't work, it throws an exception. 

Thank you!!

Gary

Gerardo Pardo's picture
Offline
Last seen: 1 week 1 day ago
Joined: 06/02/2010
Posts: 598

Hi Gary,

Did you declare the "Location" member as //@Optional in the IDL file? I think is required to indicate that the member may be NULL.

See the Optional Members section in the Connext DDS 5.0 Extensible Types Addendum for details. 

Alternatively if you are using the TypeCode to dynamically define the data-type then you would need to set the StructMember is_optional attribute to TRUE when you are defining the Location member.

Gerardo