Given next field in a topic.
<member name="exerciseNickname" type="string" arrayDimensions="4" stringMaxLength="20"/>
With the usual dynamicdata you have set some array types to set as double, byte, float, etc but there's no set_string_array.
Notice in my case i don't use idl file i use a file .qos to describe every topic instead.
How can i set the array of string?
Hello,
You need to use the DynamicData::bind_complex_member operation to first bind your member. I will elaborate below.
A structure can contain members of different types (longs, strings, arrays, sequences, other structures). If a member is of a simple type, e.g. a primitive like a long, float, or even sequences of primitive types, then you can use the "set_xxx" operations directly on the structure to set the member. However more complex members, like members that themselves have a structured type or arrays/sequences of non primitive types require the use of the DynamicData::bind_complex_member() to bind another DynamicData object to the inner member. This can be done recursively until you get to a member of a type where you can use the aforementioned "set_xxx" operations.
Assuming the data-type described by this XML:
You can use the following C++ code to set the elements of array of strings inside:
I also uploaded an example that uses this API to the File Exchange it can be found at this link dyndata_string_seq.zip
Gerardo
Thanks!!
That works fine!!