Blaze 0.0.1
The ultra high-performance JSON Schema evaluator
Loading...
Searching...
No Matches
alterschema.h
1#ifndef SOURCEMETA_BLAZE_ALTERSCHEMA_H_
2#define SOURCEMETA_BLAZE_ALTERSCHEMA_H_
3
12
13#ifndef SOURCEMETA_BLAZE_ALTERSCHEMA_EXPORT
14#include <sourcemeta/blaze/alterschema_export.h>
15#endif
16
17#include <sourcemeta/blaze/alterschema_error.h>
18#include <sourcemeta/blaze/alterschema_transformer.h>
19
20#include <sourcemeta/blaze/compiler.h>
21#include <sourcemeta/core/jsonschema.h>
22
23#include <cstdint> // std::uint8_t
24#include <optional> // std::optional, std::nullopt
25#include <string_view> // std::string_view
26#include <type_traits> // std::false_type
27
28namespace sourcemeta::blaze {
29
30// Exporting symbols that depends on the standard C++ library is considered
31// safe.
32// https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-2-c4275?view=msvc-170&redirectedfrom=MSDN
33#if defined(_MSC_VER)
34#pragma warning(disable : 4251 4275)
35#endif
36
39enum class AlterSchemaMode : std::uint8_t {
43};
44
78SOURCEMETA_BLAZE_ALTERSCHEMA_EXPORT
79auto add(SchemaTransformer &bundle, const AlterSchemaMode mode) -> void;
80
91class SOURCEMETA_BLAZE_ALTERSCHEMA_EXPORT SchemaRule final
92 : public SchemaTransformRule {
93public:
95 enum class Scope : std::uint8_t {
97 All,
98
100 TopLevel
101 };
102
103 using mutates = std::false_type;
104 using reframe_after_transform = std::false_type;
105 SchemaRule(const sourcemeta::core::JSON &schema,
106 const sourcemeta::core::SchemaWalker &walker,
107 const sourcemeta::core::SchemaResolver &resolver,
108 const Compiler &compiler,
109 const std::string_view default_dialect = "",
110 const std::optional<Tweaks> &tweaks = std::nullopt,
111 const Scope scope = Scope::All);
112 [[nodiscard]] auto condition(const sourcemeta::core::JSON &,
113 const sourcemeta::core::JSON &,
114 const sourcemeta::core::SchemaVocabularies &,
115 const sourcemeta::core::SchemaFrame &,
116 const sourcemeta::core::SchemaFrame::Location &,
117 const sourcemeta::core::SchemaWalker &,
118 const sourcemeta::core::SchemaResolver &) const
119 -> SchemaTransformRule::Result override;
120
121private:
122 Template template_;
123 Scope scope_;
124};
125
126#if defined(_MSC_VER)
127#pragma warning(default : 4251 4275)
128#endif
129
167SOURCEMETA_BLAZE_ALTERSCHEMA_EXPORT
168auto wrap(const sourcemeta::core::JSON &schema,
169 const sourcemeta::core::SchemaFrame &frame,
170 const sourcemeta::core::SchemaFrame::Location &location,
171 const sourcemeta::core::SchemaWalker &walker,
172 const sourcemeta::core::SchemaResolver &resolver,
173 sourcemeta::core::WeakPointer &base) -> sourcemeta::core::JSON;
174
175} // namespace sourcemeta::blaze
176
177#endif
Scope
The locations of the schema that the rule applies to.
Definition alterschema.h:95
Definition alterschema.h:92
Definition alterschema_transformer.h:142
SOURCEMETA_BLAZE_ALTERSCHEMA_EXPORT auto wrap(const sourcemeta::core::JSON &schema, const sourcemeta::core::SchemaFrame &frame, const sourcemeta::core::SchemaFrame::Location &location, const sourcemeta::core::SchemaWalker &walker, const sourcemeta::core::SchemaResolver &resolver, sourcemeta::core::WeakPointer &base) -> sourcemeta::core::JSON
SOURCEMETA_BLAZE_ALTERSCHEMA_EXPORT auto add(SchemaTransformer &bundle, const AlterSchemaMode mode) -> void
AlterSchemaMode
Definition alterschema.h:39
@ Linter
Definition alterschema.h:42
std::function< Instructions(const KeywordContext &, const Instructions &)> Compiler
Definition compiler.h:105
Definition evaluator.h:38
The result of evaluating a rule.
Definition alterschema_transformer.h:56