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 - 2026 (C). Alex Robenko. All rights reserved.
3//
4// SPDX-License-Identifier: MPL-2.0
5//
6// This Source Code Form is subject to the terms of the Mozilla Public
7// License, v. 2.0. If a copy of the MPL was not distributed with this
8// file, You can obtain one at http://mozilla.org/MPL/2.0/.
9
10#pragma once
11
14
15#include "comms/details/ReadIteratorHelper.h"
16#include "comms/details/WriteIteratorHelper.h"
17
18#include <type_traits>
19#include <utility>
20
21namespace comms
22{
23
28template <typename TMessage, typename TIter>
29auto readIteratorFor(TIter&& iter) -> decltype(details::ReadIteratorHelper<>::template get<TMessage>(std::forward<TIter>(iter)))
30{
31 return details::ReadIteratorHelper<>::template get<TMessage>(std::forward<TIter>(iter));
32}
33
39template <typename TMessage, typename TIter>
40auto readIteratorFor(TMessage&& msg, TIter&& iter) ->
41 decltype(details::ReadIteratorHelper<>::template get<typename std::decay<decltype(msg)>::type>(std::forward<TIter>(iter)))
42{
43 static_cast<void>(msg);
44 return details::ReadIteratorHelper<>::template get<typename std::decay<decltype(msg)>::type>(std::forward<TIter>(iter));
45}
46
51template <typename TMessage, typename TIter>
52auto writeIteratorFor(TIter&& iter) -> decltype(details::WriteIteratorHelper<>::template get<TMessage>(std::forward<TIter>(iter)))
53{
54 return details::WriteIteratorHelper<>::template get<TMessage>(std::forward<TIter>(iter));
55}
56
62template <typename TMessage, typename TIter>
63auto writeIteratorFor(TMessage&& msg, TIter&& iter) ->
64 decltype(details::WriteIteratorHelper<>::template get<typename std::decay<decltype(msg)>::type>(std::forward<TIter>(iter)))
65{
66 static_cast<void>(msg);
67 return details::WriteIteratorHelper<>::template get<typename std::decay<decltype(msg)>::type>(std::forward<TIter>(iter));
68}
69
70} // 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:29
auto writeIteratorFor(TIter &&iter) -> decltype(details::WriteIteratorHelper<>::template get< TMessage >(std::forward< TIter >(iter)))
Create and initialise iterator for message write.
Definition iterator.h:52