24 #include "../algorithm.h"
55 if ( p == target.
end() )
64 return p != target.
end();
70 return { target.
begin(), p };
83 inline std::tuple< bool, view< std::byte* > >
90 return {
true, std::move( e ).commit() };
95 [[nodiscard]] std::optional< std::byte >
get(
std::byte inpt )
const
115 offset =
static_cast< uint8_t
>( inpt );
123 std::optional< std::byte >
const b =
get( inpt );
135 ,
offset( static_cast< uint8_t >( b ) )
143 inline std::tuple< bool, view< std::byte* > >
152 std::optional< std::byte > val = dec.
iter( b );
154 if ( !val.has_value() )
156 *target_current = *val;
159 if ( target_current == target.
end() )
160 return {
false, target };
162 return {
true, { target.
begin(), target_current } };
165 template <
typename Iter >
166 class decode_cobs_iter;
170 template <
typename Iter >
171 struct std::iterator_traits<
emlabcpp::decode_cobs_iter< Iter > >
184 template <
typename Iter >
197 return *dec_.
get( *iter_ );
220 return iter_ == other.iter_;
228 template <
typename Iter >
TODO: make this no inline.
Definition: cobs.h:35
cobs_encoder(view< std::byte * > target)
Definition: cobs.h:37
bool insert(std::byte b)
Definition: cobs.h:42
view< std::byte * > commit() &&
Definition: cobs.h:67
decode_cobs_iter & operator++()
Definition: cobs.h:200
bool operator==(decode_cobs_iter const &other) const
Definition: cobs.h:218
decode_cobs_iter operator++(int)
Definition: cobs.h:211
std::byte operator*() const
Definition: cobs.h:193
decode_cobs_iter(Iter iter)
Definition: cobs.h:188
constexpr EndIterator end() const
Past the end iterator.
Definition: view.h:110
constexpr Iterator begin() const
Start of the dataset iterator.
Definition: view.h:104
constexpr value_type const & front() const
Returns first value of the range.
Definition: view.h:147
hdr_state next(hdr_state cs) noexcept
Definition: page.h:43
MIT License.
Definition: impl.h:31
view< decode_cobs_iter< Iter >, decode_cobs_iter< Iter > > cobs_decode_view(view< Iter > data)
Definition: cobs.h:229
constexpr pointer data() noexcept
Returns pointer to first item of the storage.
Definition: static_storage.h:108
constexpr view< Iterator > tail(Container &&cont, int const step=1)
Returns range over Container, which skips first item of container.
Definition: algorithm.h:94
std::tuple< bool, view< std::byte * > > encode_cobs(view< std::byte const * > source, view< std::byte * > target)
Encodes data from source range into target buffer with Consistent Overhead Byte Stuffing (COBS) encod...
Definition: cobs.h:84
std::tuple< bool, view< std::byte * > > decode_cobs(view< std::byte const * > source, view< std::byte * > target)
Decodes data from source range into target buffer with Consistent Overhead Byte Stuffing (COBS) encod...
Definition: cobs.h:144
T res
Definition: algorithm.h:505
constexpr auto find(Container &&cont, T const &item)
Finds first item in container 'cont' that is equal to 'item', returns iterator for container,...
Definition: algorithm.h:140
physical_quantity< 0, 0, 0, 0, 0, 0, 0, 0, 1 > byte
Definition: physical_quantity.h:118
generic_iterator simplifies custom iterator implementation using CRTP.
Definition: iterator.h:62
void advance(std::byte inpt)
Definition: cobs.h:111
std::optional< std::byte > get(std::byte inpt) const
Definition: cobs.h:95
std::optional< std::byte > iter(std::byte inpt)
Definition: cobs.h:121
cobs_decoder(std::byte b)
Definition: cobs.h:133
uint8_t offset
Definition: cobs.h:129
bool nonzero
Definition: cobs.h:128
bool non_value_byte()
Definition: cobs.h:106
physical_quantity represents all physical units defined using the International System of Units and m...
Definition: physical_quantity.h:56
std::input_iterator_tag iterator_category
Definition: cobs.h:178
value_type & reference
Definition: cobs.h:177
value_type const * const_pointer
Definition: cobs.h:176
std::byte value_type
Definition: cobs.h:173
value_type * pointer
Definition: cobs.h:175
std::ptrdiff_t difference_type
Definition: cobs.h:174