Skip to content

Commit 107d756

Browse files
committed
fable: Provide fable/fable_fwd.hpp header for forward declarations
This follows the pattern set by other libraries, such as Boost and nlohmann/json.
1 parent ac46bfa commit 107d756

File tree

3 files changed

+55
-3
lines changed

3 files changed

+55
-3
lines changed

fable/include/fable/fable.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#pragma once
2727

28+
#include <fable/fable_fwd.hpp>
2829
#include <fable/conf.hpp>
2930
#include <fable/confable.hpp>
3031
#include <fable/enum.hpp>

fable/include/fable/fable_fwd.hpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright 2023 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+
*/
18+
/**
19+
* \file fable/fable_fwd.hpp
20+
*/
21+
22+
#include <string>
23+
24+
#include <nlohmann/detail/value_t.hpp>
25+
#include <nlohmann/json_fwd.hpp>
26+
27+
namespace fable {
28+
29+
// from json.hpp
30+
using Json = nlohmann::json;
31+
using JsonPointer = nlohmann::json_pointer<std::string>;
32+
using JsonType = nlohmann::detail::value_t;
33+
34+
// from conf.hpp
35+
class Conf;
36+
37+
// from error.hpp
38+
class Error;
39+
class ConfError;
40+
class SchemaError;
41+
42+
// from schema.hpp
43+
class Schema;
44+
45+
// from confable.hpp
46+
class Confable;
47+
48+
// from environment.hpp
49+
class Environment;
50+
51+
} // namespace fable

fable/include/fable/json.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ using Json = nlohmann::json;
6565
* This makes it easier to talk/write about operations that deal with
6666
* JSON pointers.
6767
*/
68-
using JsonPointer = Json::json_pointer;
68+
using JsonPointer = nlohmann::json_pointer<std::string>;
6969

7070
/**
7171
* The JsonType type maps to nlohmann::json::value_t.
7272
*
7373
* This makes it easier to talk/write about operations that deal on the
7474
* underlying type that is stored in a Json value.
7575
*/
76-
using JsonType = Json::value_t;
76+
using JsonType = nlohmann::detail::value_t;
7777

7878
/**
7979
* Return a string representation of a JSON type.
@@ -100,7 +100,7 @@ std::string to_string(JsonType);
100100
* See the documentation on each of these global variables for more details.
101101
*/
102102
template <typename InputType>
103-
inline Json parse_json(InputType&& input) {
103+
Json parse_json(InputType&& input) {
104104
return Json::parse(std::forward<InputType>(input), nullptr, NLOHMANN_JSON_USE_EXCEPTIONS,
105105
NLOHMANN_JSON_ALLOW_COMMENTS);
106106
}

0 commit comments

Comments
 (0)