$darkmode
ignore.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_IGNORE_HPP_
26 #define FABLE_SCHEMA_IGNORE_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 
46 class Ignore : public Base<Ignore> {
47  public: // Constructors
48  Ignore() : Base(JsonType::object, "ignored") {}
49  explicit Ignore(std::string&& desc, JsonType t = JsonType::object) : Base(t, std::move(desc)) {}
50 
51  public: // Overrides
52  Json json_schema() const override {
53  Json j = Json::object({});
54  this->augment_schema(j);
55  return j;
56  }
57 
58  void validate(const Conf&) const override {}
59  using Interface::to_json;
60  void to_json(Json& j) const override { j = nullptr; }
61  void from_conf(const Conf&) override {}
62  void reset_ptr() override {}
63 };
64 
65 inline Ignore make_schema(std::string&& desc, JsonType t = JsonType::object) {
66  return Ignore(std::move(desc), t);
67 }
68 
69 } // namespace schema
70 } // namespace fable
71 
72 #endif // FABLE_SCHEMA_IGNORE_HPP_
Definition: conf.hpp:74
void to_json(Json &j) const override
Definition: ignore.hpp:60
Definition: ignore.hpp:46
nlohmann::json Json
Definition: json.hpp:62
void reset_ptr() override
Definition: ignore.hpp:62
Json::value_t JsonType
Definition: json.hpp:78
Definition: conf.hpp:70
virtual Json to_json() const
Definition: interface.hpp:220
void validate(const Conf &) const override
Definition: ignore.hpp:58
Definition: interface.hpp:354
void from_conf(const Conf &) override
Definition: ignore.hpp:61
Json json_schema() const override
Definition: ignore.hpp:52