MQTTSuite
Loading...
Searching...
No Matches
anonymous_namespace{json-validator.cpp}::schema_ref Class Reference
Inheritance diagram for anonymous_namespace{json-validator.cpp}::schema_ref:
Collaboration diagram for anonymous_namespace{json-validator.cpp}::schema_ref:

Public Member Functions

 schema_ref (const std::string &id, root_schema *root)
const std::string & id () const
void set_target (const std::shared_ptr< schema > &target, bool strong=false)
 schema_ref (const std::string &id, root_schema *root)
const std::string & id () const
void set_target (const std::shared_ptr< schema > &target, bool strong=false)
Public Member Functions inherited from anonymous_namespace{json-validator.cpp}::schema
virtual ~schema ()=default
 schema (root_schema *root)
void set_default_value (const json &v)
virtual ~schema ()=default
 schema (root_schema *root)
void set_default_value (const json &v)

Protected Member Functions

virtual std::shared_ptr< schemamake_for_default_ (std::shared_ptr<::schema > &sch, root_schema *root, std::vector< nlohmann::json_uri > &uris, nlohmann::json &default_value) const override
virtual std::shared_ptr< schemamake_for_default_ (std::shared_ptr<::schema > &sch, root_schema *root, std::vector< nlohmann::json_uri > &uris, nlohmann::json &default_value) const override

Private Member Functions

void validate (const json::json_pointer &ptr, const json &instance, json_patch &patch, error_handler &e) const final
const jsondefault_value (const json::json_pointer &ptr, const json &instance, error_handler &e) const override final
void validate (const json::json_pointer &ptr, const json &instance, json_patch &patch, error_handler &e) const final
const jsondefault_value (const json::json_pointer &ptr, const json &instance, error_handler &e) const override final

Private Attributes

const std::string id_
std::weak_ptr< schematarget_
std::shared_ptr< schematarget_strong_

Additional Inherited Members

Static Public Member Functions inherited from anonymous_namespace{json-validator.cpp}::schema
static std::shared_ptr< schemamake (json &schema, root_schema *root, const std::vector< std::string > &key, std::vector< nlohmann::json_uri > uris)
static std::shared_ptr< schemamake (json &schema, root_schema *root, const std::vector< std::string > &key, std::vector< nlohmann::json_uri > uris)
Protected Attributes inherited from anonymous_namespace{json-validator.cpp}::schema
root_schemaroot_
json default_value_ = nullptr

Detailed Description

Definition at line 75 of file json-validator.cpp.

Constructor & Destructor Documentation

◆ schema_ref() [1/2]

anonymous_namespace{json-validator.cpp}::schema_ref::schema_ref ( const std::string & id,
root_schema * root )
inline

Definition at line 122 of file json-validator.cpp.

123 : schema(root), id_(id) {}
auto schema
Definition id-ref.cpp:69

References id_, and anonymous_namespace{json-validator.cpp}::schema::schema().

Here is the call graph for this function:

◆ schema_ref() [2/2]

anonymous_namespace{json-validator.cpp}::schema_ref::schema_ref ( const std::string & id,
root_schema * root )
inline

Definition at line 122 of file json-validator.cpp.

123 : schema(root), id_(id) {}

Member Function Documentation

◆ default_value() [1/2]

const json & anonymous_namespace{json-validator.cpp}::schema_ref::default_value ( const json::json_pointer & ptr,
const json & instance,
error_handler & e ) const
inlinefinaloverrideprivatevirtual

Reimplemented from anonymous_namespace{json-validator.cpp}::schema.

Definition at line 92 of file json-validator.cpp.

93 {
94 if (!default_value_.is_null())
95 return default_value_;
96
97 auto target = target_.lock();
98 if (target)
99 return target->default_value(ptr, instance, e);
100
101 e.error(ptr, instance, "unresolved or freed schema-reference " + id_);
102
103 return default_value_;
104 }
virtual void error(const json::json_pointer &, const json &, const std::string &)=0
static const auto instance
Definition issue-93.cpp:14

References anonymous_namespace{json-validator.cpp}::schema::default_value(), anonymous_namespace{json-validator.cpp}::schema::default_value_, nlohmann::json_schema::error_handler::error(), id_, and target_.

Here is the call graph for this function:

◆ default_value() [2/2]

const json & anonymous_namespace{json-validator.cpp}::schema_ref::default_value ( const json::json_pointer & ptr,
const json & instance,
error_handler & e ) const
inlinefinaloverrideprivatevirtual

Reimplemented from anonymous_namespace{json-validator.cpp}::schema.

Definition at line 92 of file json-validator.cpp.

93 {
94 if (!default_value_.is_null())
95 return default_value_;
96
97 auto target = target_.lock();
98 if (target)
99 return target->default_value(ptr, instance, e);
100
101 e.error(ptr, instance, "unresolved or freed schema-reference " + id_);
102
103 return default_value_;
104 }

◆ id() [1/2]

const std::string & anonymous_namespace{json-validator.cpp}::schema_ref::id ( ) const
inline

Definition at line 125 of file json-validator.cpp.

125{ return id_; }

References id_.

◆ id() [2/2]

const std::string & anonymous_namespace{json-validator.cpp}::schema_ref::id ( ) const
inline

Definition at line 125 of file json-validator.cpp.

125{ return id_; }

◆ make_for_default_() [1/2]

virtual std::shared_ptr< schema > anonymous_namespace{json-validator.cpp}::schema_ref::make_for_default_ ( std::shared_ptr<::schema > & sch,
root_schema * root,
std::vector< nlohmann::json_uri > & uris,
nlohmann::json & default_value ) const
inlineoverrideprotectedvirtual

Reimplemented from anonymous_namespace{json-validator.cpp}::schema.

Definition at line 107 of file json-validator.cpp.

112 {
113 // create a new reference schema using the original reference (which will be resolved later)
114 // to store this overloaded default value #209
115 auto result = std::make_shared<schema_ref>(uris[0].to_string(), root);
116 result->set_target(sch, true);
117 result->set_default_value(default_value);
118 return result;
119 };
const json & default_value(const json::json_pointer &ptr, const json &instance, error_handler &e) const override final

References anonymous_namespace{json-validator.cpp}::schema::set_default_value(), set_target(), and nlohmann::json_uri::to_string().

Here is the call graph for this function:

◆ make_for_default_() [2/2]

virtual std::shared_ptr< schema > anonymous_namespace{json-validator.cpp}::schema_ref::make_for_default_ ( std::shared_ptr<::schema > & sch,
root_schema * root,
std::vector< nlohmann::json_uri > & uris,
nlohmann::json & default_value ) const
inlineoverrideprotectedvirtual

Reimplemented from anonymous_namespace{json-validator.cpp}::schema.

Definition at line 107 of file json-validator.cpp.

112 {
113 // create a new reference schema using the original reference (which will be resolved later)
114 // to store this overloaded default value #209
115 auto result = std::make_shared<schema_ref>(uris[0].to_string(), root);
116 result->set_target(sch, true);
117 result->set_default_value(default_value);
118 return result;
119 };

◆ set_target() [1/2]

void anonymous_namespace{json-validator.cpp}::schema_ref::set_target ( const std::shared_ptr< schema > & target,
bool strong = false )
inline

Definition at line 127 of file json-validator.cpp.

128 {
129 target_ = target;
130 if (strong)
131 target_strong_ = target;
132 }

References target_, and target_strong_.

Referenced by nlohmann::json_schema::root_schema::insert(), and make_for_default_().

Here is the caller graph for this function:

◆ set_target() [2/2]

void anonymous_namespace{json-validator.cpp}::schema_ref::set_target ( const std::shared_ptr< schema > & target,
bool strong = false )
inline

Definition at line 127 of file json-validator.cpp.

128 {
129 target_ = target;
130 if (strong)
131 target_strong_ = target;
132 }

◆ validate() [1/2]

void anonymous_namespace{json-validator.cpp}::schema_ref::validate ( const json::json_pointer & ptr,
const json & instance,
json_patch & patch,
error_handler & e ) const
inlinefinalprivatevirtual

Implements anonymous_namespace{json-validator.cpp}::schema.

Definition at line 82 of file json-validator.cpp.

83 {
84 auto target = target_.lock();
85
86 if (target)
87 target->validate(ptr, instance, patch, e);
88 else
89 e.error(ptr, instance, "unresolved or freed schema-reference " + id_);
90 }

References nlohmann::json_schema::error_handler::error(), id_, target_, and anonymous_namespace{json-validator.cpp}::schema::validate().

Here is the call graph for this function:

◆ validate() [2/2]

void anonymous_namespace{json-validator.cpp}::schema_ref::validate ( const json::json_pointer & ptr,
const json & instance,
json_patch & patch,
error_handler & e ) const
inlinefinalprivatevirtual

Implements anonymous_namespace{json-validator.cpp}::schema.

Definition at line 82 of file json-validator.cpp.

83 {
84 auto target = target_.lock();
85
86 if (target)
87 target->validate(ptr, instance, patch, e);
88 else
89 e.error(ptr, instance, "unresolved or freed schema-reference " + id_);
90 }

Member Data Documentation

◆ id_

const std::string anonymous_namespace{json-validator.cpp}::schema_ref::id_
private

Definition at line 77 of file json-validator.cpp.

Referenced by default_value(), id(), schema_ref(), and validate().

◆ target_

std::weak_ptr< schema > anonymous_namespace{json-validator.cpp}::schema_ref::target_
private

Definition at line 78 of file json-validator.cpp.

Referenced by default_value(), set_target(), and validate().

◆ target_strong_

std::shared_ptr< schema > anonymous_namespace{json-validator.cpp}::schema_ref::target_strong_
private

Definition at line 79 of file json-validator.cpp.

Referenced by set_target().


The documentation for this class was generated from the following file: