We totally forgot to implement the comparison operators other than ==
and != for scalar types. Consequently, comparing a JSON value with a
scalar type led to compile errors.
The solution with a std::runtime_error member is more elegant. It
allows to have std::exception as base class again. However, I still
have no idea why GCC thinks the copy constructor may throw...
To have nothrow-copy-constructible exceptions, we inherit from
std::runtime_error which can cope with arbitrary-length error messages.
Intermediate strings are built with static functions and then passed to
the actual constructor.
- Removed unused headers.
- Added override where needed.
- Added description for parse_error.113 exception.
- Fixed some conversion warnings.
- Integrated cbor_expect_string function for CBOR maps.
- Added documentation on the supported CBOR/MessagePack features.
- Added test to check all initial bytes for CBOR input.
When <Windows.h> is included with MSVC, a macro NOMINMAX is defined
that yields compilation errors when max/min calls are encountered. This
can be fixed by un-defining NOMINMAX, or by placing parentheses around
all min/max calls. We chose the latter.
Since #329, NaN and inf numbers do not yield an exception, but are
stored internally and are dumped as “null”. This commit adjusts the
fuzz testers to deal with this special case.
- If an overflow occurs during parsing a number from a JSON text, an
exception (std::out_of_range for the moment, to be replaced by a
user-defined exception #244) is thrown so that the overflow is detected
early and roundtripping is guaranteed.
- NaN and INF floating-point values can be stored in a JSON value and
are not replaced by null. That is, the basic_json class behaves like
double in this regard (no exception occurs). However, NaN and INF are
serialized to “null”.
- Adjusted test cases appropriately.
To avoid the error described in #497, I added a function
msgpack_expect_string that is executed every time a string is expected
during the parsing of a map. In case the current byte does not belong
to a MsgPack string, an exception is thrown.
Added a test to check if the input stream is good() before executing
getline on it. Also added two test cases that set the failbit and
badbit before calling file_line_buffer.
I used __EXCEPTIONS to detect whether exceptions are supported.
Apparently, this is a macro that is only used by libstdc++
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64276). It’s much cleaner
to use __cpp_exceptions as it is in the standard since C++98.
Note that compiling the unit-tests with “-fno-exceptions” still does
not work, because Catch uses throw internally. However, the library’s
exceptions can be switched off by defining JSON_NOEXCEPTION.