COMMS
Template library intended to help with implementation of communication protocols.
Loading...
Searching...
No Matches
MissingOnReadFail.h
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
10#include <utility>
11
12#include "comms/cast.h"
13
14namespace comms
15{
16
17namespace field
18{
19
20namespace adapter
21{
22
23
24template <typename TBase>
25class MissingOnReadFail : public TBase
26{
27 using BaseImpl = TBase;
28public:
29
30 template <typename TIter>
31 comms::ErrorStatus read(TIter& iter, std::size_t len)
32 {
33 BaseImpl tmp;
34 auto iterTmp = iter;
35 auto es = tmp.read(iterTmp, len);
37 BaseImpl::setMode(comms::field::OptionalMode::Missing);
39 }
40
41 static_cast<BaseImpl&>(*this) = std::move(tmp);
42 iter = iterTmp;
43 return es;
44 }
45
46 static constexpr bool hasReadNoStatus()
47 {
48 return false;
49 }
50
51 template <typename TIter>
52 void readNoStatus(TIter& iter) = delete;
53};
54
55} // namespace adapter
56
57} // namespace field
58
59} // namespace comms
60
61
62
63
Contains definition of various casts.
@ Missing
Field doesn't exist.
Main namespace for all classes / functions of COMMS library.
ErrorStatus
Error statuses reported by the Communication module.
Definition ErrorStatus.h:17
@ Success
Used to indicate successful outcome of the operation.