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 - 2025 (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
16#include <utility>
17
18namespace comms
19{
20
25template <typename TMessage, typename TIter>
26auto readIteratorFor(TIter&& iter) -> decltype(details::ReadIteratorHelper<>::template get<TMessage>(std::forward<TIter>(iter)))
27{
28 return details::ReadIteratorHelper<>::template get<TMessage>(std::forward<TIter>(iter));
29}
30
36template <typename TMessage, typename TIter>
37auto readIteratorFor(TMessage&& msg, TIter&& iter) ->
38 decltype(details::ReadIteratorHelper<>::template get<typename std::decay<decltype(msg)>::type>(std::forward<TIter>(iter)))
39{
40 static_cast<void>(msg);
41 return details::ReadIteratorHelper<>::template get<typename std::decay<decltype(msg)>::type>(std::forward<TIter>(iter));
42}
43
48template <typename TMessage, typename TIter>
49auto writeIteratorFor(TIter&& iter) -> decltype(details::WriteIteratorHelper<>::template get<TMessage>(std::forward<TIter>(iter)))
50{
51 return details::WriteIteratorHelper<>::template get<TMessage>(std::forward<TIter>(iter));
52}
53
59template <typename TMessage, typename TIter>
60auto writeIteratorFor(TMessage&& msg, TIter&& iter) ->
61 decltype(details::WriteIteratorHelper<>::template get<typename std::decay<decltype(msg)>::type>(std::forward<TIter>(iter)))
62{
63 static_cast<void>(msg);
64 return details::WriteIteratorHelper<>::template get<typename std::decay<decltype(msg)>::type>(std::forward<TIter>(iter));
65}
66
67} // 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:26
auto writeIteratorFor(TIter &&iter) -> decltype(details::WriteIteratorHelper<>::template get< TMessage >(std::forward< TIter >(iter)))
Create and initialise iterator for message write.
Definition iterator.h:49