Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit f6db79c

Browse files
committed
Reformatting done. Minor includes fixes #3
1 parent 4bdb2bd commit f6db79c

File tree

82 files changed

+525
-509
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+525
-509
lines changed

include/nil/marshalling/accumulators/marshalling.hpp

+36-35
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,22 @@ namespace nil {
4949
struct marshalling_impl : boost::accumulators::accumulator_base {
5050
protected:
5151
typedef TypeToProcess field_type;
52-
52+
5353
public:
5454
typedef field_type result_type;
5555

5656
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]) {
5858
}
5959

6060
template<typename ArgumentPack>
6161
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];
6364

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()]);
6668
}
6769

6870
inline field_type result(boost::accumulators::dont_care) const {
@@ -74,10 +76,11 @@ namespace nil {
7476
// because byte iterator can be directly processed
7577
template<typename InputIterator>
7678
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) {
8184

8285
return processed_field.read(first, buf_len);
8386
}
@@ -92,52 +95,50 @@ namespace nil {
9295

9396
template<typename InputIterator>
9497
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) {
100105

101106
using type_to_process = typename std::iterator_traits<InputIterator>::value_type;
102107
status_type final_status = status_type::success;
103108

104109
// hardcoded to be little-endian by default. If the user wants to process a container
105110
// 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
108113
// 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;
114119

115-
nil_marshalling_array_internal_sequential_container_type sequentional_container;
120+
std::copy(other_field_begin, other_field_begin + buf_len, sequential_container.begin());
116121

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);
120123

121124
return resolve_type(input_data, 1);
122125
}
123126

124127
// Probably there is a way to directly convert between marshalling fields
125128
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, ...) {
131134

132-
std::vector<std::uint8_t> buffer (other_field.length());
135+
std::vector<std::uint8_t> buffer(other_field.length());
133136
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());
136138

137139
buffer_begin = buffer.begin();
138140

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());
141142

142143
return read_status | write_status;
143144
}

0 commit comments

Comments
 (0)