Merge 90865ccd20 into c4d74856bb
This commit is contained in:
commit
0ff6d629c1
@ -414,7 +414,7 @@ int json::get() const
|
|||||||
switch (type_)
|
switch (type_)
|
||||||
{
|
{
|
||||||
case (value_t::number):
|
case (value_t::number):
|
||||||
return value_.number;
|
return static_cast<int>(value_.number);
|
||||||
case (value_t::number_float):
|
case (value_t::number_float):
|
||||||
return static_cast<int>(value_.number_float);
|
return static_cast<int>(value_.number_float);
|
||||||
default:
|
default:
|
||||||
@ -2371,7 +2371,7 @@ std::string json::parser::codePointToUTF8(unsigned int codePoint) const
|
|||||||
{
|
{
|
||||||
// Can't be tested without direct access to this private method.
|
// Can't be tested without direct access to this private method.
|
||||||
std::string errorMessage = "Invalid codePoint: ";
|
std::string errorMessage = "Invalid codePoint: ";
|
||||||
errorMessage += codePoint;
|
errorMessage += static_cast<char>(codePoint);
|
||||||
error(errorMessage);
|
error(errorMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2584,6 +2584,8 @@ void json::parser::expect(const char c)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if !_MSC_VER
|
||||||
/*!
|
/*!
|
||||||
This operator implements a user-defined string literal for JSON objects. It can
|
This operator implements a user-defined string literal for JSON objects. It can
|
||||||
be used by adding \p "_json" to a string literal and returns a JSON object if
|
be used by adding \p "_json" to a string literal and returns a JSON object if
|
||||||
@ -2596,3 +2598,4 @@ nlohmann::json operator "" _json(const char* s, std::size_t)
|
|||||||
{
|
{
|
||||||
return nlohmann::json::parse(s);
|
return nlohmann::json::parse(s);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|||||||
35
src/json.h
35
src/json.h
@ -20,6 +20,20 @@
|
|||||||
#include <limits> // std::numeric_limits
|
#include <limits> // std::numeric_limits
|
||||||
#include <functional> // std::hash
|
#include <functional> // std::hash
|
||||||
|
|
||||||
|
#if _MSC_VER
|
||||||
|
|
||||||
|
#ifndef _MSC_EXTENSIONS
|
||||||
|
#define _MSC_EXTENSIONS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <iso646.h>
|
||||||
|
|
||||||
|
#ifdef _NOEXCEPT
|
||||||
|
#define noexcept _NOEXCEPT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace nlohmann
|
namespace nlohmann
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -515,7 +529,13 @@ class json
|
|||||||
/// read the next character, stripping whitespace
|
/// read the next character, stripping whitespace
|
||||||
bool next();
|
bool next();
|
||||||
/// raise an exception with an error message
|
/// raise an exception with an error message
|
||||||
|
|
||||||
|
#if _MSC_VER
|
||||||
|
__declspec(noreturn) inline void error(const std::string&) const;
|
||||||
|
#else
|
||||||
[[noreturn]] inline void error(const std::string&) const;
|
[[noreturn]] inline void error(const std::string&) const;
|
||||||
|
#endif
|
||||||
|
|
||||||
/// parse a quoted string
|
/// parse a quoted string
|
||||||
inline std::string parseString();
|
inline std::string parseString();
|
||||||
/// transforms a unicode codepoint to it's UTF-8 presentation
|
/// transforms a unicode codepoint to it's UTF-8 presentation
|
||||||
@ -545,12 +565,17 @@ class json
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if !_MSC_VER
|
||||||
/// user-defined literal operator to create JSON objects from strings
|
/// user-defined literal operator to create JSON objects from strings
|
||||||
nlohmann::json operator "" _json(const char*, std::size_t);
|
nlohmann::json operator "" _json(const char*, std::size_t);
|
||||||
|
#endif
|
||||||
|
|
||||||
// specialization of std::swap, and std::hash
|
// specialization of std::swap, and std::hash
|
||||||
namespace std
|
namespace std
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#if !_MSC_VER
|
||||||
template <>
|
template <>
|
||||||
/// swaps the values of two JSON objects
|
/// swaps the values of two JSON objects
|
||||||
inline void swap(nlohmann::json& j1,
|
inline void swap(nlohmann::json& j1,
|
||||||
@ -561,6 +586,16 @@ inline void swap(nlohmann::json& j1,
|
|||||||
{
|
{
|
||||||
j1.swap(j2);
|
j1.swap(j2);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
template <>
|
||||||
|
/// swaps the values of two JSON objects
|
||||||
|
inline void swap(nlohmann::json& j1,
|
||||||
|
nlohmann::json& j2)
|
||||||
|
{
|
||||||
|
j1.swap(j2);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
/// hash value for JSON objects
|
/// hash value for JSON objects
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user