$darkmode
boolean.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2020 Robert Bosch GmbH
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * SPDX-License-Identifier: Apache-2.0
17  */
24 #pragma once
25 #ifndef FABLE_SCHEMA_BOOLEAN_HPP_
26 #define FABLE_SCHEMA_BOOLEAN_HPP_
27 
28 #include <string> // for string
29 #include <utility> // for move
30 
31 #include <fable/schema/interface.hpp> // for Base<>
32 
33 namespace fable {
34 namespace schema {
35 
36 class Boolean : public Base<Boolean> {
37  public: // Types and Constructors
38  using Type = bool;
39 
40  Boolean(Type* ptr, std::string&& desc);
41 
42  public: // Overrides
43  Json json_schema() const override;
44  void validate(const Conf& c) const override;
45  using Interface::to_json;
46  void to_json(Json& j) const override;
47  void from_conf(const Conf& c) override;
48  Json serialize(const Type& x) const;
49  Type deserialize(const Conf& c) const;
50  void reset_ptr() override;
51 
52  private:
53  Type* ptr_{nullptr};
54 };
55 
56 inline Boolean make_schema(bool* ptr, std::string&& desc) { return Boolean(ptr, std::move(desc)); }
57 
58 } // namespace schema
59 } // namespace fable
60 
61 #endif // FABLE_SCHEMA_BOOLEAN_HPP_
Definition: conf.hpp:74
void validate(const Conf &c) const override
Definition: boolean.cpp:42
Json json_schema() const override
Definition: boolean.cpp:34
void reset_ptr() override
Definition: boolean.cpp:58
nlohmann::json Json
Definition: json.hpp:62
Definition: conf.hpp:70
virtual Json to_json() const
Definition: interface.hpp:220
Definition: boolean.hpp:36
void from_conf(const Conf &c) override
Definition: boolean.cpp:49
Definition: interface.hpp:354