-
-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f588fb
commit 6d872df
Showing
4 changed files
with
106 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright 2013-2023 Daniel Parker | ||
// Distributed under the Boost license, Version 1.0. | ||
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
// See https://github.com/danielaparker/jsoncons for latest version | ||
|
||
#ifndef JSONCONS_JSONSCHEMA_SCHEMA_FACTORY_HPP | ||
#define JSONCONS_JSONSCHEMA_SCHEMA_FACTORY_HPP | ||
|
||
#include <jsoncons_ext/jsonschema/draft7/schema_parser_impl.hpp> | ||
|
||
namespace jsoncons { | ||
namespace jsonschema { | ||
|
||
template <class Json> | ||
using schema_draft7 = jsoncons::jsonschema::draft7::schema_draft7<Json>; | ||
|
||
template <class Json> | ||
std::shared_ptr<json_schema<Json>> make_schema(const Json& schema) | ||
{ | ||
jsoncons::jsonschema::draft7::schema_parser_impl<Json> parser{ jsoncons::jsonschema::draft7::default_uri_resolver<Json>()}; | ||
parser.parse(schema); | ||
|
||
return parser.get_schema(); | ||
} | ||
|
||
template <class Json> | ||
std::shared_ptr<json_schema<Json>> make_schema(const Json& schema, const std::string& retrieval_uri) | ||
{ | ||
jsoncons::jsonschema::draft7::schema_parser_impl<Json> parser{ jsoncons::jsonschema::draft7::default_uri_resolver<Json>()}; | ||
parser.parse(schema, retrieval_uri); | ||
|
||
return parser.get_schema(); | ||
} | ||
|
||
template <class Json,class URIResolver> | ||
typename std::enable_if<extension_traits::is_unary_function_object_exact<URIResolver,Json,std::string>::value,std::shared_ptr<json_schema<Json>>>::type | ||
make_schema(const Json& schema, const URIResolver& resolver) | ||
{ | ||
jsoncons::jsonschema::draft7::schema_parser_impl<Json> parser(resolver); | ||
parser.parse(schema); | ||
|
||
return parser.get_schema(); | ||
} | ||
|
||
template <class Json,class URIResolver> | ||
typename std::enable_if<extension_traits::is_unary_function_object_exact<URIResolver,Json,std::string>::value,std::shared_ptr<json_schema<Json>>>::type | ||
make_schema(const Json& schema, const std::string& retrieval_uri, const URIResolver& resolver) | ||
{ | ||
jsoncons::jsonschema::draft7::schema_parser_impl<Json> parser(resolver, retrieval_uri); | ||
parser.parse(schema); | ||
|
||
return parser.get_schema(); | ||
} | ||
|
||
} // namespace jsonschema | ||
} // namespace jsoncons | ||
|
||
#endif // JSONCONS_JSONSCHEMA_SCHEMA_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2013-2023 Daniel Parker | ||
// Distributed under the Boost license, Version 1.0. | ||
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
// See https://github.com/danielaparker/jsoncons for latest version | ||
|
||
#ifndef JSONCONS_JSONSCHEMA_SCHEMA_PARSER_HPP | ||
#define JSONCONS_JSONSCHEMA_SCHEMA_PARSER_HPP | ||
|
||
#include <jsoncons/config/jsoncons_config.hpp> | ||
#include <jsoncons/uri.hpp> | ||
#include <jsoncons/json.hpp> | ||
#include <jsoncons_ext/jsonpointer/jsonpointer.hpp> | ||
#include <jsoncons_ext/jsonschema/jsonschema_error.hpp> | ||
#include <jsoncons_ext/jsonschema/schema_location.hpp> | ||
#include <jsoncons_ext/jsonschema/keyword_validator.hpp> | ||
|
||
namespace jsoncons { | ||
namespace jsonschema { | ||
|
||
template <class Json> | ||
class schema_parser | ||
{ | ||
public: | ||
|
||
virtual void parse(const Json& sch) = 0; | ||
|
||
virtual void parse(const Json& sch, const std::string& retrieval_uri) = 0; | ||
}; | ||
|
||
} // namespace jsonschema | ||
} // namespace jsoncons | ||
|
||
#endif // JSONCONS_JSONSCHEMA_SCHEMA_HPP |