MCPcopy Create free account
hub / github.com/OpenDDS/OpenDDS / begin_array

Method begin_array

dds/DCPS/Xcdr2ValueWriter.cpp:309–332  ·  view source on GitHub ↗

Array and sequence can be treated similar to final/appendable struct. If the element type is primitive, it is similar to a final struct with no delimiter. If the element type is not primitive, it is similar to an appendable struct with a delimiter. In both case, elements are serialized back-to-back similarly to final/appendable struct. One difference is that sequence has a length field ahead of th

Source from the content-addressed store, hash-verified

307// In both case, elements are serialized back-to-back similarly to final/appendable struct.
308// One difference is that sequence has a length field ahead of the elements.
309bool Xcdr2ValueWriter::begin_array(XTypes::TypeKind elem_tk)
310{
311 // TODO: Revisit for multi-dimensional array with typedef.
312 // See https://github.com/OpenDDS/OpenDDS/issues/4453 for related issue in opendds_idl.
313 // Potential solution: resolve all the intermediary typedefs to get the actual final
314 // element type and at the same time keep track the dimensions of the array in the
315 // vwrite_array function in DynamicVwrite.cpp.
316
317 Extensibility arr_exten = FINAL;
318 // In case the element type is not primitive, account for the Dheader only when this is
319 // called for the outermost dimension of the array.
320 const bool primitive_elem_kind = XTypes::is_primitive(elem_tk);
321 if (mode_ == SERIALIZATION_SIZE_MODE) {
322 if (size_states_.top().collection_kind != ARRAY_KIND && !primitive_elem_kind) {
323 arr_exten = APPENDABLE;
324 }
325 } else {
326 if (serialize_states_.top().collection_kind != ARRAY_KIND && !primitive_elem_kind) {
327 arr_exten = APPENDABLE;
328 }
329 }
330
331 return begin_complex(arr_exten, ARRAY_KIND);
332}
333
334bool Xcdr2ValueWriter::end_array()
335{

Callers

nothing calls this directly

Calls 1

is_primitiveFunction · 0.85

Tested by

no test coverage detected