compiler-warnings: use size_t as explicit type for comparisons with size_t
This commit is contained in:
parent
e666f9f7ba
commit
d957c9f667
@ -135,8 +135,7 @@ void validate_type(const json &schema, const std::string &expected_type, const s
|
|||||||
if (type_instance.type() == json::value_t::array) {
|
if (type_instance.type() == json::value_t::array) {
|
||||||
if ((std::find(type_instance.begin(),
|
if ((std::find(type_instance.begin(),
|
||||||
type_instance.end(),
|
type_instance.end(),
|
||||||
expected_type) != type_instance.end())
|
expected_type) != type_instance.end()) ||
|
||||||
||
|
|
||||||
(expected_type == "integer" &&
|
(expected_type == "integer" &&
|
||||||
std::find(type_instance.begin(),
|
std::find(type_instance.begin(),
|
||||||
type_instance.end(),
|
type_instance.end(),
|
||||||
@ -445,13 +444,13 @@ void json_validator::validate_array(const json &instance, const json &schema, co
|
|||||||
// maxItems
|
// maxItems
|
||||||
const auto &maxItems = schema.find("maxItems");
|
const auto &maxItems = schema.find("maxItems");
|
||||||
if (maxItems != schema.end())
|
if (maxItems != schema.end())
|
||||||
if (instance.size() > maxItems.value().get<int>())
|
if (instance.size() > maxItems.value().get<size_t>())
|
||||||
throw std::out_of_range(name + " has too many items.");
|
throw std::out_of_range(name + " has too many items.");
|
||||||
|
|
||||||
// minItems
|
// minItems
|
||||||
const auto &minItems = schema.find("minItems");
|
const auto &minItems = schema.find("minItems");
|
||||||
if (minItems != schema.end())
|
if (minItems != schema.end())
|
||||||
if (instance.size() < minItems.value().get<int>())
|
if (instance.size() < minItems.value().get<size_t>())
|
||||||
throw std::out_of_range(name + " has too many items.");
|
throw std::out_of_range(name + " has too many items.");
|
||||||
|
|
||||||
// uniqueItems
|
// uniqueItems
|
||||||
@ -554,13 +553,13 @@ void json_validator::validate_object(const json &instance, const json &schema, c
|
|||||||
// maxProperties
|
// maxProperties
|
||||||
const auto &maxProperties = schema.find("maxProperties");
|
const auto &maxProperties = schema.find("maxProperties");
|
||||||
if (maxProperties != schema.end())
|
if (maxProperties != schema.end())
|
||||||
if (instance.size() > maxProperties.value().get<int>())
|
if (instance.size() > maxProperties.value().get<size_t>())
|
||||||
throw std::out_of_range(name + " has too many properties.");
|
throw std::out_of_range(name + " has too many properties.");
|
||||||
|
|
||||||
// minProperties
|
// minProperties
|
||||||
const auto &minProperties = schema.find("minProperties");
|
const auto &minProperties = schema.find("minProperties");
|
||||||
if (minProperties != schema.end())
|
if (minProperties != schema.end())
|
||||||
if (instance.size() < minProperties.value().get<int>())
|
if (instance.size() < minProperties.value().get<size_t>())
|
||||||
throw std::out_of_range(name + " has too few properties.");
|
throw std::out_of_range(name + " has too few properties.");
|
||||||
|
|
||||||
// additionalProperties
|
// additionalProperties
|
||||||
@ -681,7 +680,7 @@ void json_validator::validate_string(const json &instance, const json &schema, c
|
|||||||
// minLength
|
// minLength
|
||||||
auto attr = schema.find("minLength");
|
auto attr = schema.find("minLength");
|
||||||
if (attr != schema.end())
|
if (attr != schema.end())
|
||||||
if (utf8_length( instance ) < attr.value().get<int>()) {
|
if (utf8_length(instance) < attr.value().get<size_t>()) {
|
||||||
std::ostringstream s;
|
std::ostringstream s;
|
||||||
s << "'" << name << "' of value '" << instance << "' is too short as per minLength ("
|
s << "'" << name << "' of value '" << instance << "' is too short as per minLength ("
|
||||||
<< attr.value() << ")";
|
<< attr.value() << ")";
|
||||||
@ -691,7 +690,7 @@ void json_validator::validate_string(const json &instance, const json &schema, c
|
|||||||
// maxLength
|
// maxLength
|
||||||
attr = schema.find("maxLength");
|
attr = schema.find("maxLength");
|
||||||
if (attr != schema.end())
|
if (attr != schema.end())
|
||||||
if (utf8_length(instance) > attr.value().get<int>()) {
|
if (utf8_length(instance) > attr.value().get<size_t>()) {
|
||||||
std::ostringstream s;
|
std::ostringstream s;
|
||||||
s << "'" << name << "' of value '" << instance << "' is too long as per maxLength ("
|
s << "'" << name << "' of value '" << instance << "' is too long as per maxLength ("
|
||||||
<< attr.value() << ")";
|
<< attr.value() << ")";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user