COMMS
Template library intended to help with implementation of communication protocols.
Loading...
Searching...
No Matches
CustomValidator.h
1//
2// Copyright 2015 - 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
12namespace comms
13{
14
15namespace field
16{
17
18namespace adapter
19{
20
21template <typename TValidator, typename TBase>
22class CustomValidator : public TBase
23{
24 using BaseImpl = TBase;
25 using Validator = TValidator;
26
27public:
28
29 using ValueType = typename BaseImpl::ValueType;
30
31 CustomValidator() = default;
32
33 explicit CustomValidator(const ValueType& val)
34 : BaseImpl(val)
35 {
36 }
37
38 explicit CustomValidator(ValueType&& val)
39 : BaseImpl(std::move(val))
40 {
41 }
42
43 CustomValidator(const CustomValidator&) = default;
44 CustomValidator(CustomValidator&&) = default;
45 CustomValidator& operator=(const CustomValidator&) = default;
46 CustomValidator& operator=(CustomValidator&&) = default;
47
48 bool valid() const
49 {
50 return BaseImpl::valid() && (Validator()(*this));
51 }
52};
53
54} // namespace adapter
55
56} // namespace field
57
58} // namespace comms
59
Main namespace for all classes / functions of COMMS library.
STL namespace.