@@ -49,20 +49,22 @@ namespace nil {
49
49
struct marshalling_impl : boost::accumulators::accumulator_base {
50
50
protected:
51
51
typedef TypeToProcess field_type;
52
-
52
+
53
53
public:
54
54
typedef field_type result_type;
55
55
56
56
template <typename Args>
57
- marshalling_impl (const Args &args) : processed_field(args[boost::accumulators::sample]){
57
+ marshalling_impl (const Args &args) : processed_field(args[boost::accumulators::sample]) {
58
58
}
59
59
60
60
template <typename ArgumentPack>
61
61
inline void operator ()(const ArgumentPack &args) {
62
- status_type expected_status = args[::nil::marshalling::accumulators::expected_status | status_type::success];
62
+ status_type expected_status
63
+ = args[::nil::marshalling::accumulators::expected_status | status_type::success];
63
64
64
- status_type marshalling_status = resolve_type (args[boost::accumulators::sample],
65
- args[::nil::marshalling::accumulators::buffer_length | std::size_t ()]);
65
+ status_type marshalling_status
66
+ = resolve_type (args[boost::accumulators::sample],
67
+ args[::nil::marshalling::accumulators::buffer_length | std::size_t ()]);
66
68
}
67
69
68
70
inline field_type result (boost::accumulators::dont_care) const {
@@ -74,10 +76,11 @@ namespace nil {
74
76
// because byte iterator can be directly processed
75
77
template <typename InputIterator>
76
78
inline typename std::enable_if<
77
- marshalling::detail::is_iterator<InputIterator>::value &&
78
- marshalling::detail::is_supported_representation_type<typename std::iterator_traits<InputIterator>::value_type>::value,
79
- status_type>::type
80
- resolve_type (InputIterator first, std::size_t buf_len) {
79
+ marshalling::detail::is_iterator<InputIterator>::value
80
+ && marshalling::detail::is_supported_representation_type<
81
+ typename std::iterator_traits<InputIterator>::value_type>::value,
82
+ status_type>::type
83
+ resolve_type (InputIterator first, std::size_t buf_len) {
81
84
82
85
return processed_field.read (first, buf_len);
83
86
}
@@ -92,52 +95,50 @@ namespace nil {
92
95
93
96
template <typename InputIterator>
94
97
inline typename std::enable_if<
95
- marshalling::detail::is_iterator<InputIterator>::value &&
96
- !(marshalling::detail::is_supported_representation_type<typename std::iterator_traits<InputIterator>::value_type>::value) &&
97
- marshalling::detail::is_marshalling_field<typename std::iterator_traits<InputIterator>::value_type>::value,
98
- status_type>::type
99
- resolve_type (const InputIterator other_field_begin, std::size_t buf_len) {
98
+ marshalling::detail::is_iterator<InputIterator>::value
99
+ && !(marshalling::detail::is_supported_representation_type<
100
+ typename std::iterator_traits<InputIterator>::value_type>::value)
101
+ && marshalling::detail::is_marshalling_field<
102
+ typename std::iterator_traits<InputIterator>::value_type>::value,
103
+ status_type>::type
104
+ resolve_type (const InputIterator other_field_begin, std::size_t buf_len) {
100
105
101
106
using type_to_process = typename std::iterator_traits<InputIterator>::value_type;
102
107
status_type final_status = status_type::success;
103
108
104
109
// hardcoded to be little-endian by default. If the user wants to process a container
105
110
// in other order (for example, in reverse or by skipping some first elements), he should
106
- // define type of the container using array_list and process it not by iterator, but by
107
- // processing it as marshaling type (at the moment it is the resolve_type function under
111
+ // define type of the container using array_list and process it not by iterator, but by
112
+ // processing it as marshaling type (at the moment it is the resolve_type function under
108
113
// this one).
109
- using marhsalling_array_type =
110
- types::array_list<
111
- marshalling::field_type<nil::marshalling::option::little_endian>,
112
- type_to_process>;
113
- using nil_marshalling_array_internal_sequential_container_type = typename marhsalling_array_type::value_type;
114
+ using marhsalling_array_type
115
+ = types::array_list<marshalling::field_type<nil::marshalling::option::little_endian>,
116
+ type_to_process>;
117
+
118
+ typename marhsalling_array_type::value_type sequential_container ;
114
119
115
- nil_marshalling_array_internal_sequential_container_type sequentional_container ;
120
+ std::copy (other_field_begin, other_field_begin + buf_len, sequential_container. begin ()) ;
116
121
117
- std::copy (other_field_begin, other_field_begin + buf_len, sequentional_container.begin ());
118
-
119
- marhsalling_array_type input_data (sequentional_container);
122
+ marhsalling_array_type input_data (sequential_container);
120
123
121
124
return resolve_type (input_data, 1 );
122
125
}
123
126
124
127
// Probably there is a way to directly convert between marshalling fields
125
128
template <typename OtherFieldType>
126
- inline typename std::enable_if<
127
- !marshalling::detail::is_iterator<OtherFieldType>::value &&
128
- marshalling::detail::is_marshalling_field<OtherFieldType>::value,
129
- status_type>::type
130
- resolve_type (const OtherFieldType other_field, ...) {
129
+ inline
130
+ typename std::enable_if< !marshalling::detail::is_iterator<OtherFieldType>::value
131
+ && marshalling::detail::is_marshalling_field<OtherFieldType>::value,
132
+ status_type>::type
133
+ resolve_type (const OtherFieldType other_field, ...) {
131
134
132
- std::vector<std::uint8_t > buffer (other_field.length ());
135
+ std::vector<std::uint8_t > buffer (other_field.length ());
133
136
typename std::vector<std::uint8_t >::iterator buffer_begin = buffer.begin ();
134
- status_type write_status =
135
- other_field.write (buffer_begin, buffer.size ());
137
+ status_type write_status = other_field.write (buffer_begin, buffer.size ());
136
138
137
139
buffer_begin = buffer.begin ();
138
140
139
- status_type read_status =
140
- processed_field.read (buffer_begin, buffer.size ());
141
+ status_type read_status = processed_field.read (buffer_begin, buffer.size ());
141
142
142
143
return read_status | write_status;
143
144
}
0 commit comments