run make pretty
This commit is contained in:
parent
fbac056c38
commit
3e15b551e0
6 changed files with 6274 additions and 5716 deletions
896
src/json.hpp
896
src/json.hpp
File diff suppressed because it is too large
Load diff
|
@ -500,14 +500,22 @@ void get_arithmetic_value(const Json &j, ArithmeticType &val)
|
||||||
{
|
{
|
||||||
// unsigned must be checked first, since is_number_integer() == true for unsigned
|
// unsigned must be checked first, since is_number_integer() == true for unsigned
|
||||||
if (j.is_number_unsigned())
|
if (j.is_number_unsigned())
|
||||||
|
{
|
||||||
val = static_cast<ArithmeticType>(*j.template get_ptr<const typename Json::number_unsigned_t*>());
|
val = static_cast<ArithmeticType>(*j.template get_ptr<const typename Json::number_unsigned_t*>());
|
||||||
|
}
|
||||||
else if (j.is_number_integer())
|
else if (j.is_number_integer())
|
||||||
|
{
|
||||||
val = static_cast<ArithmeticType>(*j.template get_ptr<const typename Json::number_integer_t*>());
|
val = static_cast<ArithmeticType>(*j.template get_ptr<const typename Json::number_integer_t*>());
|
||||||
|
}
|
||||||
else if (j.is_number_float())
|
else if (j.is_number_float())
|
||||||
|
{
|
||||||
val = static_cast<ArithmeticType>(*j.template get_ptr<const typename Json::number_float_t*>());
|
val = static_cast<ArithmeticType>(*j.template get_ptr<const typename Json::number_float_t*>());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
throw std::domain_error("type must be number, but is " + type_name(j));
|
throw std::domain_error("type must be number, but is " + type_name(j));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template <typename Json>
|
template <typename Json>
|
||||||
void to_json(Json& j, typename Json::boolean_t b) noexcept
|
void to_json(Json& j, typename Json::boolean_t b) noexcept
|
||||||
|
@ -583,7 +591,9 @@ template <typename Json>
|
||||||
void from_json(const Json& j, typename Json::boolean_t& b)
|
void from_json(const Json& j, typename Json::boolean_t& b)
|
||||||
{
|
{
|
||||||
if (!j.is_boolean())
|
if (!j.is_boolean())
|
||||||
|
{
|
||||||
throw std::domain_error("type must be boolean, but is " + type_name(j));
|
throw std::domain_error("type must be boolean, but is " + type_name(j));
|
||||||
|
}
|
||||||
b = *j.template get_ptr<const typename Json::boolean_t*>();
|
b = *j.template get_ptr<const typename Json::boolean_t*>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -591,7 +601,9 @@ template <typename Json>
|
||||||
void from_json(const Json& j, typename Json::string_t& s)
|
void from_json(const Json& j, typename Json::string_t& s)
|
||||||
{
|
{
|
||||||
if (!j.is_string())
|
if (!j.is_string())
|
||||||
|
{
|
||||||
throw std::domain_error("type must be string, but is " + type_name(j));
|
throw std::domain_error("type must be string, but is " + type_name(j));
|
||||||
|
}
|
||||||
s = *j.template get_ptr<const typename Json::string_t*>();
|
s = *j.template get_ptr<const typename Json::string_t*>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -626,7 +638,9 @@ template <typename Json>
|
||||||
void from_json(const Json& j, typename Json::array_t& arr)
|
void from_json(const Json& j, typename Json::array_t& arr)
|
||||||
{
|
{
|
||||||
if (!j.is_array())
|
if (!j.is_array())
|
||||||
|
{
|
||||||
throw std::domain_error("type must be array, but is " + type_name(j));
|
throw std::domain_error("type must be array, but is " + type_name(j));
|
||||||
|
}
|
||||||
arr = *j.template get_ptr<const typename Json::array_t*>();
|
arr = *j.template get_ptr<const typename Json::array_t*>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -637,15 +651,21 @@ void from_json(const Json &j, std::forward_list<T, Allocator>& l)
|
||||||
// do not perform the check when user wants to retrieve jsons
|
// do not perform the check when user wants to retrieve jsons
|
||||||
// (except when it's null.. ?)
|
// (except when it's null.. ?)
|
||||||
if (j.is_null())
|
if (j.is_null())
|
||||||
|
{
|
||||||
throw std::domain_error("type must be array, but is " + type_name(j));
|
throw std::domain_error("type must be array, but is " + type_name(j));
|
||||||
|
}
|
||||||
if (not std::is_same<T, Json>::value)
|
if (not std::is_same<T, Json>::value)
|
||||||
{
|
{
|
||||||
if (!j.is_array())
|
if (!j.is_array())
|
||||||
|
{
|
||||||
throw std::domain_error("type must be array, but is " + type_name(j));
|
throw std::domain_error("type must be array, but is " + type_name(j));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for (auto it = j.rbegin(), end = j.rend(); it != end; ++it)
|
for (auto it = j.rbegin(), end = j.rend(); it != end; ++it)
|
||||||
|
{
|
||||||
l.push_front(it->template get<T>());
|
l.push_front(it->template get<T>());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template <typename Json, typename CompatibleArrayType>
|
template <typename Json, typename CompatibleArrayType>
|
||||||
void from_json_array_impl(const Json& j, CompatibleArrayType& arr, priority_tag<0>)
|
void from_json_array_impl(const Json& j, CompatibleArrayType& arr, priority_tag<0>)
|
||||||
|
@ -690,13 +710,17 @@ template <
|
||||||
void from_json(const Json& j, CompatibleArrayType& arr)
|
void from_json(const Json& j, CompatibleArrayType& arr)
|
||||||
{
|
{
|
||||||
if (j.is_null())
|
if (j.is_null())
|
||||||
|
{
|
||||||
throw std::domain_error("type must be array, but is " + type_name(j));
|
throw std::domain_error("type must be array, but is " + type_name(j));
|
||||||
|
}
|
||||||
// when T == Json, do not check if value_t is correct
|
// when T == Json, do not check if value_t is correct
|
||||||
if (not std::is_same<typename CompatibleArrayType::value_type, Json>::value)
|
if (not std::is_same<typename CompatibleArrayType::value_type, Json>::value)
|
||||||
{
|
{
|
||||||
if (!j.is_array())
|
if (!j.is_array())
|
||||||
|
{
|
||||||
throw std::domain_error("type must be array, but is " + type_name(j));
|
throw std::domain_error("type must be array, but is " + type_name(j));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
from_json_array_impl(j, arr, priority_tag<1> {});
|
from_json_array_impl(j, arr, priority_tag<1> {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -708,7 +732,9 @@ template <
|
||||||
void from_json(const Json& j, CompatibleObjectType& obj)
|
void from_json(const Json& j, CompatibleObjectType& obj)
|
||||||
{
|
{
|
||||||
if (!j.is_object())
|
if (!j.is_object())
|
||||||
|
{
|
||||||
throw std::domain_error("type must be object, but is " + type_name(j));
|
throw std::domain_error("type must be object, but is " + type_name(j));
|
||||||
|
}
|
||||||
|
|
||||||
auto inner_object = j.template get_ptr<const typename Json::object_t*>();
|
auto inner_object = j.template get_ptr<const typename Json::object_t*>();
|
||||||
using std::begin;
|
using std::begin;
|
||||||
|
@ -734,16 +760,26 @@ template <
|
||||||
void from_json(const Json& j, ArithmeticType& val)
|
void from_json(const Json& j, ArithmeticType& val)
|
||||||
{
|
{
|
||||||
if (j.is_number_unsigned())
|
if (j.is_number_unsigned())
|
||||||
|
{
|
||||||
val = static_cast<ArithmeticType>(*j.template get_ptr<const typename Json::number_unsigned_t*>());
|
val = static_cast<ArithmeticType>(*j.template get_ptr<const typename Json::number_unsigned_t*>());
|
||||||
|
}
|
||||||
else if (j.is_number_integer())
|
else if (j.is_number_integer())
|
||||||
|
{
|
||||||
val = static_cast<ArithmeticType>(*j.template get_ptr<const typename Json::number_integer_t*>());
|
val = static_cast<ArithmeticType>(*j.template get_ptr<const typename Json::number_integer_t*>());
|
||||||
|
}
|
||||||
else if (j.is_number_float())
|
else if (j.is_number_float())
|
||||||
|
{
|
||||||
val = static_cast<ArithmeticType>(*j.template get_ptr<const typename Json::number_float_t*>());
|
val = static_cast<ArithmeticType>(*j.template get_ptr<const typename Json::number_float_t*>());
|
||||||
|
}
|
||||||
else if (j.is_boolean())
|
else if (j.is_boolean())
|
||||||
|
{
|
||||||
val = static_cast<ArithmeticType>(*j.template get_ptr<const typename Json::boolean_t*>());
|
val = static_cast<ArithmeticType>(*j.template get_ptr<const typename Json::boolean_t*>());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
throw std::domain_error("type must be number, but is " + type_name(j));
|
throw std::domain_error("type must be number, but is " + type_name(j));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct to_json_fn
|
struct to_json_fn
|
||||||
{
|
{
|
||||||
|
@ -7871,7 +7907,10 @@ class basic_json
|
||||||
|
|
||||||
@since version 1.0.0
|
@since version 1.0.0
|
||||||
*/
|
*/
|
||||||
std::string type_name() const { return detail::type_name(*this); }
|
std::string type_name() const
|
||||||
|
{
|
||||||
|
return detail::type_name(*this);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/*!
|
/*!
|
||||||
|
@ -11536,7 +11575,8 @@ inline bool operator<(const value_t lhs, const value_t rhs) noexcept
|
||||||
2, // integer
|
2, // integer
|
||||||
2, // unsigned
|
2, // unsigned
|
||||||
2, // float
|
2, // float
|
||||||
}};
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// discarded values are not comparable
|
// discarded values are not comparable
|
||||||
if (lhs == value_t::discarded or rhs == value_t::discarded)
|
if (lhs == value_t::discarded or rhs == value_t::discarded)
|
||||||
|
|
Loading…
Reference in a new issue