COMMS
Template library intended to help with implementation of communication protocols.
Loading...
Searching...
No Matches
EmptySerialization.h
1//
2// Copyright 2017 - 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/Assert.h"
13#include "comms/ErrorStatus.h"
14
15#include <cstddef>
16#include <utility>
17
18namespace comms
19{
20
21namespace field
22{
23
24namespace adapter
25{
26
27template <typename TBase>
28class EmptySerialization : public TBase
29{
30 using BaseImpl = TBase;
31public:
32
33 using ValueType = typename BaseImpl::ValueType;
34
35 EmptySerialization() = default;
36
37 explicit EmptySerialization(const ValueType& val)
38 : BaseImpl(val)
39 {
40 }
41
42 explicit EmptySerialization(ValueType&& val)
43 : BaseImpl(std::move(val))
44 {
45 }
46
47 EmptySerialization(const EmptySerialization&) = default;
48 EmptySerialization(EmptySerialization&&) = default;
49 EmptySerialization& operator=(const EmptySerialization&) = default;
50 EmptySerialization& operator=(EmptySerialization&&) = default;
51
52 static constexpr std::size_t length()
53 {
54 return 0U;
55 }
56
57 static constexpr std::size_t minLength()
58 {
59 return length();
60 }
61
62 static constexpr std::size_t maxLength()
63 {
64 return length();
65 }
66
67 template <typename TIter>
68 static comms::ErrorStatus read(TIter&, std::size_t)
69 {
71 }
72
73 template <typename TIter>
74 static void readNoStatus(TIter&)
75 {
76 }
77
78 static constexpr bool canWrite()
79 {
80 return true;
81 }
82
83 template <typename TIter>
84 static comms::ErrorStatus write(TIter&, std::size_t)
85 {
87 }
88
89 template <typename TIter>
90 static void writeNoStatus(TIter&)
91 {
92 }
93};
94
95} // namespace adapter
96
97} // namespace field
98
99} // namespace comms
100
This file contains classes required for generic custom assertion functionality.
This file contain definition of error statuses used by comms module.
comms::option::def::EmptySerialization EmptySerialization
Same as comms::option::def::EmptySerialization.
Definition options.h:1891
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.
STL namespace.