COMMS
Template library intended to help with implementation of communication protocols.
Loading...
Searching...
No Matches
EmptySerialization.h
1//
2// Copyright 2017 - 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 EmptySerialization : public TBase
24{
25 using BaseImpl = TBase;
26public:
27
28 using ValueType = typename BaseImpl::ValueType;
29
30 EmptySerialization() = default;
31
32 explicit EmptySerialization(const ValueType& val)
33 : BaseImpl(val)
34 {
35 }
36
37 explicit EmptySerialization(ValueType&& val)
38 : BaseImpl(std::move(val))
39 {
40 }
41
42 EmptySerialization(const EmptySerialization&) = default;
43 EmptySerialization(EmptySerialization&&) = default;
44 EmptySerialization& operator=(const EmptySerialization&) = default;
45 EmptySerialization& operator=(EmptySerialization&&) = default;
46
47 static constexpr std::size_t length()
48 {
49 return 0U;
50 }
51
52 static constexpr std::size_t minLength()
53 {
54 return length();
55 }
56
57 static constexpr std::size_t maxLength()
58 {
59 return length();
60 }
61
62 template <typename TIter>
63 static comms::ErrorStatus read(TIter&, std::size_t)
64 {
66 }
67
68 template <typename TIter>
69 static void readNoStatus(TIter&)
70 {
71 }
72
73 static constexpr bool canWrite()
74 {
75 return true;
76 }
77
78 template <typename TIter>
79 static comms::ErrorStatus write(TIter&, std::size_t)
80 {
82 }
83
84 template <typename TIter>
85 static void writeNoStatus(TIter&)
86 {
87 }
88};
89
90} // namespace adapter
91
92} // namespace field
93
94} // namespace comms
95
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:1766
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.