COMMS
Template library intended to help with implementation of communication protocols.
Loading...
Searching...
No Matches
IgnoreInvalid.h
1//
2// Copyright 2015 - 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 "comms/Assert.h"
11#include "comms/ErrorStatus.h"
12
13namespace comms
14{
15
16namespace field
17{
18
19namespace adapter
20{
21
22template <typename TBase>
23class IgnoreInvalid : public TBase
24{
25 using BaseImpl = TBase;
26public:
27
28 using ValueType = typename BaseImpl::ValueType;
29
30 IgnoreInvalid() = default;
31
32 explicit IgnoreInvalid(const ValueType& val)
33 : BaseImpl(val)
34 {
35 }
36
37 explicit IgnoreInvalid(ValueType&& val)
38 : BaseImpl(std::move(val))
39 {
40 }
41
42 IgnoreInvalid(const IgnoreInvalid&) = default;
43 IgnoreInvalid(IgnoreInvalid&&) = default;
44 IgnoreInvalid& operator=(const IgnoreInvalid&) = default;
45 IgnoreInvalid& operator=(IgnoreInvalid&&) = default;
46
47 template <typename TIter>
48 comms::ErrorStatus read(TIter& iter, std::size_t len)
49 {
50 BaseImpl tmp;
51 auto es = tmp.read(iter, len);
53 return es;
54 }
55
56 if (tmp.valid()) {
57 static_cast<BaseImpl&>(*this) = std::move(tmp);
58 }
59
61 }
62
63 template <typename TIter>
64 void readNoStatus(TIter& iter)
65 {
66 BaseImpl tmp;
67 tmp.readNoStatus(iter);
68
69 if (tmp.valid()) {
70 static_cast<BaseImpl&>(*this) = std::move(tmp);
71 }
72 }
73};
74
75} // namespace adapter
76
77} // namespace field
78
79} // namespace comms
80
This file contains classes required for generic custom assertion functionality.
This file contain definition of error statuses used by comms module.
comms::option::def::IgnoreInvalid IgnoreInvalid
Same as comms::option::def::IgnoreInvalid.
Definition options.h:1555
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.
STL namespace.