How do I copy from a sequence to an array?
Note: Applies to RTI Connext 4.x and above, C and C++ APIs
Statically allocated arrays
- For C, use
FooSeq_to_array
. - For C++, use
FooSeq::to_array
.
Dinamically allocated arrays
There is an easy way to copy from sequence into an array. RTI Connext will always create a contiguous internal buffer for a sequence, if you don't loan it anything. So, you can do the following to copy the sequence to an application buffer:
- Ensure that the application buffer is at least as big as the current size of the sequence.
- Get the address of the first element, e.g. using
FooSeq_get_reference(&foo_seq,0)
- Use that address in a call to memcpy.
Note: See Example attached.
Comments
rip
Sat, 09/07/2013 - 12:35
Permalink
Usage, pointing at online documentation
FooSeq_to_array usage
FooSeq::to_array usage