8 #ifndef MESSAGE_BYTE_ORDER_DETAIL_H_INCLUDED
9 #define MESSAGE_BYTE_ORDER_DETAIL_H_INCLUDED
21 template<
typename FromMsgT,
24 struct ByteOrderConversionFunctor;
28 template<
typename MsgT,
34 template<
typename MsgT,
59 convert_byte_order( T& from,
63 T::format_type format_type;
67 detail::ByteOrderConversionFunctor
93 struct ConvertEndianess
95 void operator()(
const T &input,
108 template<
typename T,
111 struct ConvertEndianess<T, StorageT, nested_trait>
113 template <
typename NestedValueT>
114 void operator()(
const NestedValueT &input,
115 NestedValueT &output)
128 from_type from(input);
132 output = convert_byte_order<from_type,
133 to_order>(from, to).values();
142 template<
typename T,
145 struct ConvertEndianess<T, StorageT, array_trait>
147 template <
typename ArrayValueT>
148 void operator()(
const ArrayValueT &input,
153 ArrayValueT::value_type value_type;
156 DeduceTypeTrait<value_type>::type type_trait;
160 ConvertEndianess< value_type,
165 for (
size_t index = 0; index < input.size(); ++index)
167 swap_order(input[index], output[index]);
177 template<
typename T,
180 struct ConvertEndianess<T, StorageT, vector_trait>
182 template <
typename VectorValueT>
183 void operator()(
const VectorValueT &input,
184 VectorValueT &output)
188 VectorValueT::value_type value_type;
191 DeduceTypeTrait<value_type>::type type_trait;
195 ConvertEndianess< value_type,
200 output.resize(input.size());
203 for (
size_t index = 0; index < input.size(); ++index)
205 swap_order(input[index], output[index]);
218 template<
typename FromMsgT,
221 struct ByteOrderConversionFunctor
224 typedef FromMsgT from_message_type;
225 typedef ToMsgT to_message_type;
227 from_message_type::message_type message_type;
229 message_type::format_type format_type;
231 from_message_type::storage_type storage_type;
234 from_message_type& input;
235 to_message_type& output;
243 ByteOrderConversionFunctor(from_message_type& from,
261 template <
size_t Idx,
263 void operator()(
const value_t*)
270 proxy_type::value_type value_type;
276 from_message_type &mutable_input =
const_cast<from_message_type &
>(input);
278 value_type& from_value = mutable_input.template FieldAt<Idx>().
get();
282 ConvertEndianess< value_type,
284 typename DeduceTypeTrait<value_type>::type
287 swap_order( from_value,
288 output.template FieldAt<Idx>().get());
302 template<
typename T >
303 struct ByteOrderConversionFunctor <T, T>
306 typedef T from_message_type;
307 typedef T to_message_type;
310 const from_message_type &input;
311 to_message_type& output;
319 ByteOrderConversionFunctor(
const from_message_type& from,
337 template <
size_t Idx,
339 void operator()(
const value_t*)
345 from_message_type &mutable_input =
const_cast<from_message_type &
>(input);
347 output.template FieldAt<Idx>().
set(
348 mutable_input.template FieldAt<Idx>().get()