COMMS
Template library intended to help with implementation of communication protocols.
Loading...
Searching...
No Matches
iterator.h
Go to the documentation of this file.
1//
2// Copyright 2019 - 2024 (C). Alex Robenko. All rights reserved.
3//
4// This Source Code Form is subject to the terms of the Mozilla Public
5// License, v. 2.0. If a copy of the MPL was not distributed with this
6// file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
8#pragma once
9
12
13#include "comms/details/ReadIteratorHelper.h"
14#include "comms/details/WriteIteratorHelper.h"
15
16namespace comms
17{
18
23template <typename TMessage, typename TIter>
24auto readIteratorFor(TIter&& iter) -> decltype(details::ReadIteratorHelper<>::template get<TMessage>(std::forward<TIter>(iter)))
25{
26 return details::ReadIteratorHelper<>::template get<TMessage>(std::forward<TIter>(iter));
27}
28
34template <typename TMessage, typename TIter>
35auto readIteratorFor(TMessage&& msg, TIter&& iter) ->
36 decltype(details::ReadIteratorHelper<>::template get<typename std::decay<decltype(msg)>::type>(std::forward<TIter>(iter)))
37{
38 static_cast<void>(msg);
39 return details::ReadIteratorHelper<>::template get<typename std::decay<decltype(msg)>::type>(std::forward<TIter>(iter));
40}
41
46template <typename TMessage, typename TIter>
47auto writeIteratorFor(TIter&& iter) -> decltype(details::WriteIteratorHelper<>::template get<TMessage>(std::forward<TIter>(iter)))
48{
49 return details::WriteIteratorHelper<>::template get<TMessage>(std::forward<TIter>(iter));
50}
51
57template <typename TMessage, typename TIter>
58auto writeIteratorFor(TMessage&& msg, TIter&& iter) ->
59 decltype(details::WriteIteratorHelper<>::template get<typename std::decay<decltype(msg)>::type>(std::forward<TIter>(iter)))
60{
61 static_cast<void>(msg);
62 return details::WriteIteratorHelper<>::template get<typename std::decay<decltype(msg)>::type>(std::forward<TIter>(iter));
63}
64
65} // namespace comms
Main namespace for all classes / functions of COMMS library.
auto readIteratorFor(TIter &&iter) -> decltype(details::ReadIteratorHelper<>::template get< TMessage >(std::forward< TIter >(iter)))
Create and initialise iterator for message read.
Definition iterator.h:24
auto writeIteratorFor(TIter &&iter) -> decltype(details::WriteIteratorHelper<>::template get< TMessage >(std::forward< TIter >(iter)))
Create and initialise iterator for message write.
Definition iterator.h:47