11 #ifndef RTI_DDS_FLAT_BUILDERHELPER_HPP_
12 #define RTI_DDS_FLAT_BUILDERHELPER_HPP_
14 namespace rti {
namespace flat {
17 class PrimitiveSequenceBuilder;
19 template <
typename ElementBuilder>
20 class MutableSequenceBuilder;
22 template <
typename ElementOffset>
23 class FinalSequenceBuilder;
25 template <
typename ElementBuilder,
unsigned int N>
26 class MutableArrayBuilder;
36 template <
unsigned int PrimitiveSize>
37 struct primitive_lc_code_helper;
40 struct primitive_lc_code_helper<1> {
48 struct primitive_lc_code_helper<2> {
56 struct primitive_lc_code_helper<4> {
64 struct primitive_lc_code_helper<8> {
72 struct primitive_lc_code {
73 enum { value = primitive_lc_code_helper<sizeof(T)>::single };
87 struct lc_code<MutableSequenceBuilder<T> > {
94 struct lc_code<FinalSequenceBuilder<T> > {
100 template <
typename T,
unsigned int N>
101 struct lc_code<MutableArrayBuilder<T, N> > {
108 template <
typename T>
109 struct lc_code<PrimitiveSequenceBuilder<T> > {
110 enum { value = primitive_lc_code_helper<sizeof(T)>::sequence };
114 struct lc_code<StringBuilder> : lc_code<PrimitiveSequenceBuilder<char> > {};
120 template <
typename Offset>
121 struct final_offset_initializer {
123 static bool initialize(Offset& offset)
125 return RTI_XCDR_TRUE == RTIXCdrFlatData_initializeSample(
126 (
char *) offset.get_buffer(),
127 offset.get_buffer_size(),
128 rti::xcdr::type_programs<rti::flat::Sample<Offset> >::get());
134 template <
typename T>
135 struct default_primitive_value {
142 template <
typename T,
unsigned int N>
143 struct final_offset_initializer<rti::flat::PrimitiveArrayOffset<T, N> > {
147 T default_value = default_primitive_value<T>::get();
148 if (default_value == (T) 0) {
159 template <
typename T,
unsigned int N>
160 struct final_offset_initializer<rti::flat::FinalAlignedArrayOffset<T, N> > {
164 for (
unsigned int i = 0; i < N; i++) {
166 if (offset.is_null()) {
170 if (!final_offset_initializer<T>::initialize(offset)) {
182 #endif // RTI_DDS_FLAT_BUILDERHELPER_HPP_