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