26 #include "../concepts.h"
29 #ifdef EMLABCPP_USE_NLOHMANN_JSON
30 #include <nlohmann/json.hpp>
38 template < std::
size_t N >
65 template <
size_type M >
69 static_assert( M <=
N );
72 template <
size_type M >
73 constexpr
explicit message( std::array< value_type, M >
const& inpt ) noexcept
76 static_assert( M <=
N );
79 template < std::convertible_to< u
int8_t >... Ts >
81 : data_{ static_cast<
value_type >( inpt )... }
82 , used_( sizeof...( Ts ) )
86 template <
size_type M >
121 return data_[used_ - 1];
126 return data_[used_ - 1];
141 return &data_[0] + used_;
146 return &data_[0] + used_;
166 return view_n( lh.begin(), lh.used_ ) ==
view_n( rh.begin(), rh.used_ );
174 template < std::convertible_to< u
int8_t >... Ts >
181 template < std::
size_t N >
187 template < std::
size_t M >
191 static_assert( M <=
N );
195 template < std::convertible_to< u
int8_t >... Ts >
200 template < std::
size_t N >
208 template <
typename T >
211 #ifdef EMLABCPP_USE_NLOHMANN_JSON
213 template < std::
size_t N >
214 void to_json( nlohmann::json& j, message< N >
const& msg )
216 j = nlohmann::json::array();
221 template < std::
size_t N >
222 void from_json( nlohmann::json
const& j, message< N >& msg )
225 throw std::exception{};
227 std::vector< std::byte > tmp;
231 msg = message< N >{ view< std::byte const* >( tmp ) };
The bounded class represents a wrapper over type T constrained between MinVal and MaxVal as compile-t...
Definition: bounded.h:44
Protocol library has custom type that represents message, however this is just simple overaly over st...
Definition: message.h:40
std::byte const * const_pointer
Definition: message.h:45
constexpr reference back() noexcept
Definition: message.h:124
constexpr message(size_type const n) noexcept
Definition: message.h:54
constexpr iterator begin() noexcept
Definition: message.h:134
constexpr const_iterator begin() const noexcept
Definition: message.h:129
value_type operator[](size_type const i) const noexcept
Definition: message.h:149
constexpr message & operator=(message< M > const &other) noexcept
Definition: message.h:87
constexpr const_pointer data() const noexcept
Definition: message.h:94
std::byte & reference
Definition: message.h:43
constexpr message(Ts... inpt)
Definition: message.h:80
static constexpr size_type capacity
Definition: message.h:50
constexpr pointer data() noexcept
Definition: message.h:99
std::byte * pointer
Definition: message.h:44
reference operator[](size_type const i) noexcept
Definition: message.h:154
constexpr size_type size() const noexcept
Definition: message.h:104
friend auto operator==(message const &lh, message const &rh) noexcept
Definition: message.h:164
constexpr message(view< const_iterator > const &v) noexcept
Definition: message.h:59
void resize(size_type const n) noexcept
Definition: message.h:159
std::byte * iterator
Definition: message.h:46
std::size_t size_type
Definition: message.h:48
constexpr value_type back() const noexcept
Definition: message.h:119
std::byte value_type
Definition: message.h:42
constexpr iterator end() noexcept
Definition: message.h:144
constexpr message(std::array< value_type, M > const &inpt) noexcept
Definition: message.h:73
constexpr const_iterator end() const noexcept
Definition: message.h:139
std::byte const * const_iterator
Definition: message.h:47
constexpr value_type front() const noexcept
Definition: message.h:109
constexpr message()=default
constexpr message(message< M > const &other) noexcept
Definition: message.h:66
constexpr reference front() noexcept
Definition: message.h:114
Sizeless message is class that behaves in a same way as normal message, however it is serialized diff...
Definition: message.h:183
sizeless_message(message< M > const &other)
Definition: message.h:188
Generic class to represent view of some container.
Definition: view.h:41
constexpr bool message_derived_test(message< N > const &)
Definition: message.h:201
MIT License.
Definition: multiplexer.h:33
sizeless_message(Ts... inpt) -> sizeless_message< sizeof...(Ts) >
requires(std::is_enum_v< T >) struct serializer< T
concept message_derived
concept matches any type that is message or derives from it.
Definition: message.h:209
message(Ts... inpt) -> message< sizeof...(Ts) >
constexpr pointer data() noexcept
Returns pointer to first item of the storage.
Definition: static_storage.h:108
void copy(Container &&cont, Iterator iter)
Definition: algorithm.h:455
constexpr view< Iter > view_n(Iter begin, std::size_t const n)
Creates view over 'n' items of dataset starting at 'begin' This does not check validity of the range!
Definition: view.h:198
N
Definition: static_storage.h:97
physical_quantity< 0, 0, 0, 0, 0, 0, 0, 0, 1 > byte
Definition: physical_quantity.h:118