21#ifndef COMMON_WEB_SCHEMAPARSECONTEXT_H_
22#define COMMON_WEB_SCHEMAPARSECONTEXT_H_
32#include "common/web/PointerTracker.h"
33#include "common/web/SchemaErrorLogger.h"
34#include "common/web/SchemaKeywords.h"
37#include "ola/web/OptionalItem.h"
42class ArrayOfSchemaContext;
43class ArrayOfStringsContext;
44class DefinitionsParseContext;
45class DependencyParseContext;
46class JsonValueContext;
47class PropertiesParseContext;
48class SchemaParseContext;
86 m_keyword.Set(keyword);
93 std::string TakeKeyword() {
94 std::string keyword = m_keyword.Value();
102 const std::string& Keyword()
const {
return m_keyword.Value(); }
105 OptionalItem<std::string> m_keyword;
155 m_schema_defs(definitions) {
163 std::auto_ptr<SchemaParseContext> m_current_schema;
180 : m_schema_defs(definitions),
224 std::auto_ptr<JsonNumber> m_maximum;
225 std::auto_ptr<JsonNumber> m_minimum;
226 std::auto_ptr<JsonNumber> m_multiple_of;
237 std::auto_ptr<SchemaParseContext> m_additional_items_context;
240 std::auto_ptr<SchemaParseContext> m_items_single_context;
241 std::auto_ptr<ArrayOfSchemaContext> m_items_context_array;
250 std::auto_ptr<ArrayOfStringsContext> m_required_items;
251 std::auto_ptr<DependencyParseContext> m_dependency_context;
255 std::auto_ptr<class ArrayOfJsonValuesContext> m_enum_context;
256 std::auto_ptr<class ArrayOfSchemaContext> m_allof_context;
257 std::auto_ptr<class ArrayOfSchemaContext> m_anyof_context;
258 std::auto_ptr<class ArrayOfSchemaContext> m_oneof_context;
259 std::auto_ptr<class SchemaParseContext> m_not_context;
264 std::auto_ptr<const JsonValue> m_default_value;
265 std::auto_ptr<JsonValueContext> m_default_value_context;
272 std::auto_ptr<DefinitionsParseContext> m_definitions_context;
273 std::auto_ptr<PropertiesParseContext> m_properties_context;
275 std::auto_ptr<SchemaParseContext> m_additional_properties_context;
279 template <
typename T>
314 m_schema_defs(definitions) {
324 typedef std::map<std::string, SchemaParseContext*> SchemaMap;
327 SchemaMap m_property_contexts;
340 : m_schema_defs(definitions) {
357 typedef std::vector<SchemaParseContext*> ItemSchemas;
360 ItemSchemas m_item_schemas;
374 typedef std::set<std::string> StringSet;
452 bool Empty()
const {
return m_enums.empty(); }
455 std::vector<const JsonValue*> m_enums;
456 std::auto_ptr<JsonValueContext> m_value_context;
476 : m_schema_defs(definitions) {}
487 typedef std::set<std::string> StringSet;
488 typedef std::map<std::string, ValidatorInterface*> SchemaDependencies;
489 typedef std::map<std::string, StringSet> PropertyDependencies;
493 std::auto_ptr<ArrayOfStringsContext> m_property_context;
494 std::auto_ptr<SchemaParseContext> m_schema_context;
496 PropertyDependencies m_property_dependencies;
497 SchemaDependencies m_schema_dependencies;
A JsonParserInterface implementation that builds a parse tree.
A Json Schema, see www.json-schema.org.
The context for an array of JsonValues.
Definition SchemaParseContext.h:431
Parse the array of objects in an 'items' property.
Definition SchemaParseContext.h:337
void GetValidators(SchemaErrorLogger *logger, ValidatorInterface::ValidatorList *validators)
Populate a vector with validators for the elements in 'items'.
Definition SchemaParseContext.cpp:827
The context for an array of strings.
Definition SchemaParseContext.h:372
void GetStringSet(StringSet *stringd)
Return the strings in the string array.
Definition SchemaParseContext.cpp:844
The base class for Json BaseValidators. All Visit methods return false.
Definition JsonSchema.h:121
The context for schema definitions.
Definition SchemaParseContext.h:144
DefinitionsParseContext(SchemaDefinitions *definitions)
Create a new DefinitionsParseContext.
Definition SchemaParseContext.h:153
The context for a dependency object.
Definition SchemaParseContext.h:473
The validator for Json integers.
Definition JsonSchema.h:476
A JsonParserInterface implementation that builds a tree of JsonValues.
Definition JsonParser.h:57
The context for a default value.
Definition SchemaParseContext.h:399
The base class for JSON values.
Definition Json.h:119
A SchemaParseContext that keeps track of the last keyword / property seen.
Definition SchemaParseContext.h:78
void ObjectKey(SchemaErrorLogger *, const std::string &keyword)
Called when we encounter a property.
Definition SchemaParseContext.h:85
The validator for JsonObject.
Definition JsonSchema.h:531
Definition OptionalItem.h:31
Definition SchemaParseContext.h:310
Definition JsonSchema.h:960
The SchemaErrorLogger captures errors while parsing the schema.
Definition SchemaErrorLogger.h:41
Definition SchemaParseContext.h:172
SchemaParseContext(SchemaDefinitions *definitions)
Create a new SchemaParseContext.
Definition SchemaParseContext.h:179
ValidatorInterface * GetValidator(SchemaErrorLogger *logger)
Return the ValidatorInterface for this context.
Definition SchemaParseContext.cpp:149
The interface all SchemaParseContext classes inherit from.
Definition SchemaParseContext.h:53
A SchemaParseContext that reports errors for all types.
Definition SchemaParseContext.h:114
The interface Json Schema Validators.
Definition JsonSchema.h:56
std::vector< ValidatorInterface * > ValidatorList
a list of Validators.
Definition JsonSchema.h:61
JsonType
The type of JSON data element.
Definition JsonTypes.h:44
@ JSON_UNDEFINED
Definition JsonTypes.h:52
SchemaKeyword
The list of valid JSon Schema keywords.
Definition SchemaKeywords.h:32
@ SCHEMA_UNKNOWN
Definition SchemaKeywords.h:33
The namespace containing all OLA symbols.
Definition Credentials.cpp:44