Ran clang format.
This commit is contained in:
parent
b2090c5d4b
commit
d501b774a3
@ -35,7 +35,7 @@ void json_uri::update(const std::string &uri)
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string hex = pointer.substr(pos + 1, 2);
|
std::string hex = pointer.substr(pos + 1, 2);
|
||||||
char ascii = static_cast<char>( std::strtoul(hex.c_str(), nullptr, 16));
|
char ascii = static_cast<char>(std::strtoul(hex.c_str(), nullptr, 16));
|
||||||
pointer.replace(pos, 3, 1, ascii);
|
pointer.replace(pos, 3, 1, ascii);
|
||||||
|
|
||||||
pos--;
|
pos--;
|
||||||
|
|||||||
@ -10,10 +10,10 @@
|
|||||||
|
|
||||||
#include "json-patch.hpp"
|
#include "json-patch.hpp"
|
||||||
|
|
||||||
|
#include <deque>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <deque>
|
|
||||||
|
|
||||||
using nlohmann::json;
|
using nlohmann::json;
|
||||||
using nlohmann::json_patch;
|
using nlohmann::json_patch;
|
||||||
@ -192,7 +192,7 @@ public:
|
|||||||
for (auto &rt : ref_tokens) {
|
for (auto &rt : ref_tokens) {
|
||||||
auto existing_object = unk_kw->find(rt);
|
auto existing_object = unk_kw->find(rt);
|
||||||
if (existing_object == unk_kw->end())
|
if (existing_object == unk_kw->end())
|
||||||
(*unk_kw)[rt] = json::object();
|
(*unk_kw)[rt] = json::object();
|
||||||
unk_kw = &(*unk_kw)[rt];
|
unk_kw = &(*unk_kw)[rt];
|
||||||
}
|
}
|
||||||
(*unk_kw)[key] = value;
|
(*unk_kw)[key] = value;
|
||||||
@ -500,7 +500,7 @@ public:
|
|||||||
type_schema(json &sch,
|
type_schema(json &sch,
|
||||||
root_schema *root,
|
root_schema *root,
|
||||||
const std::vector<nlohmann::json_uri> &uris)
|
const std::vector<nlohmann::json_uri> &uris)
|
||||||
: schema(root), type_(static_cast<uint8_t>(json::value_t::discarded) + 1)
|
: schema(root), type_(static_cast<uint8_t>(json::value_t::discarded) + 1)
|
||||||
{
|
{
|
||||||
// association between JSON-schema-type and NLohmann-types
|
// association between JSON-schema-type and NLohmann-types
|
||||||
static const std::vector<std::pair<std::string, json::value_t>> schema_types = {
|
static const std::vector<std::pair<std::string, json::value_t>> schema_types = {
|
||||||
@ -518,7 +518,7 @@ public:
|
|||||||
auto attr = sch.find("type");
|
auto attr = sch.find("type");
|
||||||
if (attr == sch.end()) // no type field means all sub-types possible
|
if (attr == sch.end()) // no type field means all sub-types possible
|
||||||
for (auto &t : schema_types)
|
for (auto &t : schema_types)
|
||||||
type_[static_cast<uint8_t> (t.second)] = type_schema::make(sch, t.second, root, uris, known_keywords);
|
type_[static_cast<uint8_t>(t.second)] = type_schema::make(sch, t.second, root, uris, known_keywords);
|
||||||
else {
|
else {
|
||||||
switch (attr.value().type()) { // "type": "type"
|
switch (attr.value().type()) { // "type": "type"
|
||||||
|
|
||||||
@ -526,14 +526,14 @@ public:
|
|||||||
auto schema_type = attr.value().get<std::string>();
|
auto schema_type = attr.value().get<std::string>();
|
||||||
for (auto &t : schema_types)
|
for (auto &t : schema_types)
|
||||||
if (t.first == schema_type)
|
if (t.first == schema_type)
|
||||||
type_[static_cast<uint8_t> (t.second)] = type_schema::make(sch, t.second, root, uris, known_keywords);
|
type_[static_cast<uint8_t>(t.second)] = type_schema::make(sch, t.second, root, uris, known_keywords);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case json::value_t::array: // "type": ["type1", "type2"]
|
case json::value_t::array: // "type": ["type1", "type2"]
|
||||||
for (auto &schema_type : attr.value())
|
for (auto &schema_type : attr.value())
|
||||||
for (auto &t : schema_types)
|
for (auto &t : schema_types)
|
||||||
if (t.first == schema_type)
|
if (t.first == schema_type)
|
||||||
type_[static_cast<uint8_t> (t.second)] = type_schema::make(sch, t.second, root, uris, known_keywords);
|
type_[static_cast<uint8_t>(t.second)] = type_schema::make(sch, t.second, root, uris, known_keywords);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -553,16 +553,16 @@ public:
|
|||||||
|
|
||||||
// with nlohmann::json float instance (but number in schema-definition) can be seen as unsigned or integer -
|
// with nlohmann::json float instance (but number in schema-definition) can be seen as unsigned or integer -
|
||||||
// reuse the number-validator for integer values as well, if they have not been specified explicitly
|
// reuse the number-validator for integer values as well, if they have not been specified explicitly
|
||||||
if (type_[static_cast<uint8_t> (json::value_t::number_float)] && !type_[static_cast<uint8_t> (json::value_t::number_integer)])
|
if (type_[static_cast<uint8_t>(json::value_t::number_float)] && !type_[static_cast<uint8_t>(json::value_t::number_integer)])
|
||||||
type_[static_cast<uint8_t> (json::value_t::number_integer)] = type_[static_cast<uint8_t> (json::value_t::number_float)];
|
type_[static_cast<uint8_t>(json::value_t::number_integer)] = type_[static_cast<uint8_t>(json::value_t::number_float)];
|
||||||
|
|
||||||
// #54: JSON-schema does not differentiate between unsigned and signed integer - nlohmann::json does
|
// #54: JSON-schema does not differentiate between unsigned and signed integer - nlohmann::json does
|
||||||
// we stick with JSON-schema: use the integer-validator if instance-value is unsigned
|
// we stick with JSON-schema: use the integer-validator if instance-value is unsigned
|
||||||
type_[static_cast<uint8_t> (json::value_t::number_unsigned)] = type_[static_cast<uint8_t> (json::value_t::number_integer)];
|
type_[static_cast<uint8_t>(json::value_t::number_unsigned)] = type_[static_cast<uint8_t>(json::value_t::number_integer)];
|
||||||
|
|
||||||
// special for binary types
|
// special for binary types
|
||||||
if (type_[static_cast<uint8_t> (json::value_t::string)]) {
|
if (type_[static_cast<uint8_t>(json::value_t::string)]) {
|
||||||
type_[static_cast<uint8_t> (json::value_t::binary)] = type_[static_cast<uint8_t> (json::value_t::string)];
|
type_[static_cast<uint8_t>(json::value_t::binary)] = type_[static_cast<uint8_t>(json::value_t::string)];
|
||||||
}
|
}
|
||||||
|
|
||||||
attr = sch.find("enum");
|
attr = sch.find("enum");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user