Merge branch 'develop' into issues/1457
This commit is contained in:
		
						commit
						a4266bbb7d
					
				
					 1178 changed files with 6590 additions and 6298894 deletions
				
			
		|  | @ -990,11 +990,11 @@ inline char* format_buffer(char* buf, int len, int decimal_exponent, | |||
|         // digits[000]
 | ||||
|         // len <= max_exp + 2
 | ||||
| 
 | ||||
|         std::memset(buf + k, '0', static_cast<size_t>(n - k)); | ||||
|         std::memset(buf + k, '0', static_cast<size_t>(n) - static_cast<size_t>(k)); | ||||
|         // Make it look like a floating-point number (#362, #378)
 | ||||
|         buf[n + 0] = '.'; | ||||
|         buf[n + 1] = '0'; | ||||
|         return buf + (n + 2); | ||||
|         return buf + (static_cast<size_t>(n) + 2); | ||||
|     } | ||||
| 
 | ||||
|     if (0 < n and n <= max_exp) | ||||
|  | @ -1004,9 +1004,9 @@ inline char* format_buffer(char* buf, int len, int decimal_exponent, | |||
| 
 | ||||
|         assert(k > n); | ||||
| 
 | ||||
|         std::memmove(buf + (n + 1), buf + n, static_cast<size_t>(k - n)); | ||||
|         std::memmove(buf + (static_cast<size_t>(n) + 1), buf + n, static_cast<size_t>(k) - static_cast<size_t>(n)); | ||||
|         buf[n] = '.'; | ||||
|         return buf + (k + 1); | ||||
|         return buf + (static_cast<size_t>(k) + 1U); | ||||
|     } | ||||
| 
 | ||||
|     if (min_exp < n and n <= 0) | ||||
|  | @ -1014,11 +1014,11 @@ inline char* format_buffer(char* buf, int len, int decimal_exponent, | |||
|         // 0.[000]digits
 | ||||
|         // len <= 2 + (-min_exp - 1) + max_digits10
 | ||||
| 
 | ||||
|         std::memmove(buf + (2 + -n), buf, static_cast<size_t>(k)); | ||||
|         std::memmove(buf + (2 + static_cast<size_t>(-n)), buf, static_cast<size_t>(k)); | ||||
|         buf[0] = '0'; | ||||
|         buf[1] = '.'; | ||||
|         std::memset(buf + 2, '0', static_cast<size_t>(-n)); | ||||
|         return buf + (2 + (-n) + k); | ||||
|         return buf + (2U + static_cast<size_t>(-n) + static_cast<size_t>(k)); | ||||
|     } | ||||
| 
 | ||||
|     if (k == 1) | ||||
|  | @ -1033,9 +1033,9 @@ inline char* format_buffer(char* buf, int len, int decimal_exponent, | |||
|         // d.igitsE+123
 | ||||
|         // len <= max_digits10 + 1 + 5
 | ||||
| 
 | ||||
|         std::memmove(buf + 2, buf + 1, static_cast<size_t>(k - 1)); | ||||
|         std::memmove(buf + 2, buf + 1, static_cast<size_t>(k) - 1); | ||||
|         buf[1] = '.'; | ||||
|         buf += 1 + k; | ||||
|         buf += 1 + static_cast<size_t>(k); | ||||
|     } | ||||
| 
 | ||||
|     *buf++ = 'e'; | ||||
|  |  | |||
|  | @ -67,6 +67,28 @@ struct external_constructor<value_t::string> | |||
|     } | ||||
| }; | ||||
| 
 | ||||
| template<> | ||||
| struct external_constructor<value_t::binary> | ||||
| { | ||||
|     template<typename BasicJsonType> | ||||
|     static void construct(BasicJsonType& j, const typename BasicJsonType::binary_t& b) | ||||
|     { | ||||
|         j.m_type = value_t::binary; | ||||
|         typename BasicJsonType::internal_binary_t value{b}; | ||||
|         j.m_value = value; | ||||
|         j.assert_invariant(); | ||||
|     } | ||||
| 
 | ||||
|     template<typename BasicJsonType> | ||||
|     static void construct(BasicJsonType& j, typename BasicJsonType::binary_t&& b) | ||||
|     { | ||||
|         j.m_type = value_t::binary; | ||||
|         typename BasicJsonType::internal_binary_t value{std::move(b)}; | ||||
|         j.m_value = value; | ||||
|         j.assert_invariant(); | ||||
|     } | ||||
| }; | ||||
| 
 | ||||
| template<> | ||||
| struct external_constructor<value_t::number_float> | ||||
| { | ||||
|  |  | |||
|  | @ -52,6 +52,7 @@ class binary_reader | |||
|     using number_unsigned_t = typename BasicJsonType::number_unsigned_t; | ||||
|     using number_float_t = typename BasicJsonType::number_float_t; | ||||
|     using string_t = typename BasicJsonType::string_t; | ||||
|     using internal_binary_t = typename BasicJsonType::internal_binary_t; | ||||
|     using json_sax_t = SAX; | ||||
| 
 | ||||
|   public: | ||||
|  | @ -208,6 +209,30 @@ class binary_reader | |||
|         return get_string(input_format_t::bson, len - static_cast<NumberType>(1), result) and get() != std::char_traits<char>::eof(); | ||||
|     } | ||||
| 
 | ||||
|     /*!
 | ||||
|     @brief Parses a byte array input of length @a len from the BSON input. | ||||
|     @param[in] len  The length of the byte array to be read. | ||||
|     @param[in, out] result  A reference to the binary variable where the read | ||||
|                             array is to be stored. | ||||
|     @tparam NumberType The type of the length @a len | ||||
|     @pre len >= 0 | ||||
|     @return `true` if the byte array was successfully parsed | ||||
|     */ | ||||
|     template<typename NumberType> | ||||
|     bool get_bson_binary(const NumberType len, internal_binary_t& result) | ||||
|     { | ||||
|         if (JSON_HEDLEY_UNLIKELY(len < 0)) | ||||
|         { | ||||
|             auto last_token = get_token_string(); | ||||
|             return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::bson, "byte array length cannot be negative, is " + std::to_string(len), "binary"))); | ||||
|         } | ||||
| 
 | ||||
|         result.has_subtype = true; // All BSON binary values have a subtype
 | ||||
|         get_number<std::uint8_t>(input_format_t::bson, result.subtype); | ||||
| 
 | ||||
|         return get_binary(input_format_t::bson, len, result); | ||||
|     } | ||||
| 
 | ||||
|     /*!
 | ||||
|     @brief Read a BSON document element of the given @a element_type. | ||||
|     @param[in] element_type The BSON element type, c.f. http://bsonspec.org/spec.html
 | ||||
|  | @ -246,6 +271,13 @@ class binary_reader | |||
|                 return parse_bson_array(); | ||||
|             } | ||||
| 
 | ||||
|             case 0x05: // binary
 | ||||
|             { | ||||
|                 std::int32_t len; | ||||
|                 internal_binary_t value; | ||||
|                 return get_number<std::int32_t, true>(input_format_t::bson, len) and get_bson_binary(len, value) and sax->binary(value); | ||||
|             } | ||||
| 
 | ||||
|             case 0x08: // boolean
 | ||||
|             { | ||||
|                 return sax->boolean(get() != 0); | ||||
|  | @ -292,6 +324,7 @@ class binary_reader | |||
|     bool parse_bson_element_list(const bool is_array) | ||||
|     { | ||||
|         string_t key; | ||||
| 
 | ||||
|         while (int element_type = get()) | ||||
|         { | ||||
|             if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::bson, "element list"))) | ||||
|  | @ -466,6 +499,41 @@ class binary_reader | |||
|                         - static_cast<number_integer_t>(number)); | ||||
|             } | ||||
| 
 | ||||
|             // Binary data (0x00..0x17 bytes follow)
 | ||||
|             case 0x40: | ||||
|             case 0x41: | ||||
|             case 0x42: | ||||
|             case 0x43: | ||||
|             case 0x44: | ||||
|             case 0x45: | ||||
|             case 0x46: | ||||
|             case 0x47: | ||||
|             case 0x48: | ||||
|             case 0x49: | ||||
|             case 0x4A: | ||||
|             case 0x4B: | ||||
|             case 0x4C: | ||||
|             case 0x4D: | ||||
|             case 0x4E: | ||||
|             case 0x4F: | ||||
|             case 0x50: | ||||
|             case 0x51: | ||||
|             case 0x52: | ||||
|             case 0x53: | ||||
|             case 0x54: | ||||
|             case 0x55: | ||||
|             case 0x56: | ||||
|             case 0x57: | ||||
|             case 0x58: // Binary data (one-byte uint8_t for n follows)
 | ||||
|             case 0x59: // Binary data (two-byte uint16_t for n follow)
 | ||||
|             case 0x5A: // Binary data (four-byte uint32_t for n follow)
 | ||||
|             case 0x5B: // Binary data (eight-byte uint64_t for n follow)
 | ||||
|             case 0x5F: // Binary data (indefinite length)
 | ||||
|             { | ||||
|                 internal_binary_t b; | ||||
|                 return get_cbor_binary(b) and sax->binary(b); | ||||
|             } | ||||
| 
 | ||||
|             // UTF-8 string (0x00..0x17 bytes follow)
 | ||||
|             case 0x60: | ||||
|             case 0x61: | ||||
|  | @ -781,6 +849,101 @@ class binary_reader | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /*!
 | ||||
|     @brief reads a CBOR byte array | ||||
| 
 | ||||
|     This function first reads starting bytes to determine the expected | ||||
|     byte array length and then copies this number of bytes into the byte array. | ||||
|     Additionally, CBOR's byte arrays with indefinite lengths are supported. | ||||
| 
 | ||||
|     @param[out] result  created byte array | ||||
| 
 | ||||
|     @return whether byte array creation completed | ||||
|     */ | ||||
|     bool get_cbor_binary(internal_binary_t& result) | ||||
|     { | ||||
|         if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "binary"))) | ||||
|         { | ||||
|             return false; | ||||
|         } | ||||
| 
 | ||||
|         switch (current) | ||||
|         { | ||||
|             // Binary data (0x00..0x17 bytes follow)
 | ||||
|             case 0x40: | ||||
|             case 0x41: | ||||
|             case 0x42: | ||||
|             case 0x43: | ||||
|             case 0x44: | ||||
|             case 0x45: | ||||
|             case 0x46: | ||||
|             case 0x47: | ||||
|             case 0x48: | ||||
|             case 0x49: | ||||
|             case 0x4A: | ||||
|             case 0x4B: | ||||
|             case 0x4C: | ||||
|             case 0x4D: | ||||
|             case 0x4E: | ||||
|             case 0x4F: | ||||
|             case 0x50: | ||||
|             case 0x51: | ||||
|             case 0x52: | ||||
|             case 0x53: | ||||
|             case 0x54: | ||||
|             case 0x55: | ||||
|             case 0x56: | ||||
|             case 0x57: | ||||
|             { | ||||
|                 return get_binary(input_format_t::cbor, static_cast<unsigned int>(current) & 0x1Fu, result); | ||||
|             } | ||||
| 
 | ||||
|             case 0x58: // Binary data (one-byte uint8_t for n follows)
 | ||||
|             { | ||||
|                 std::uint8_t len; | ||||
|                 return get_number(input_format_t::cbor, len) and get_binary(input_format_t::cbor, len, result); | ||||
|             } | ||||
| 
 | ||||
|             case 0x59: // Binary data (two-byte uint16_t for n follow)
 | ||||
|             { | ||||
|                 std::uint16_t len; | ||||
|                 return get_number(input_format_t::cbor, len) and get_binary(input_format_t::cbor, len, result); | ||||
|             } | ||||
| 
 | ||||
|             case 0x5A: // Binary data (four-byte uint32_t for n follow)
 | ||||
|             { | ||||
|                 std::uint32_t len; | ||||
|                 return get_number(input_format_t::cbor, len) and get_binary(input_format_t::cbor, len, result); | ||||
|             } | ||||
| 
 | ||||
|             case 0x5B: // Binary data (eight-byte uint64_t for n follow)
 | ||||
|             { | ||||
|                 std::uint64_t len; | ||||
|                 return get_number(input_format_t::cbor, len) and get_binary(input_format_t::cbor, len, result); | ||||
|             } | ||||
| 
 | ||||
|             case 0x5F: // Binary data (indefinite length)
 | ||||
|             { | ||||
|                 while (get() != 0xFF) | ||||
|                 { | ||||
|                     internal_binary_t chunk; | ||||
|                     if (not get_cbor_binary(chunk)) | ||||
|                     { | ||||
|                         return false; | ||||
|                     } | ||||
|                     result.insert(result.end(), chunk.begin(), chunk.end()); | ||||
|                 } | ||||
|                 return true; | ||||
|             } | ||||
| 
 | ||||
|             default: | ||||
|             { | ||||
|                 auto last_token = get_token_string(); | ||||
|                 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::cbor, "expected length specification (0x40-0x5B) or indefinite binary array type (0x5F); last byte: 0x" + last_token, "binary"))); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /*!
 | ||||
|     @param[in] len  the length of the array or std::size_t(-1) for an | ||||
|                     array of indefinite size | ||||
|  | @ -1101,6 +1264,22 @@ class binary_reader | |||
|             case 0xC3: // true
 | ||||
|                 return sax->boolean(true); | ||||
| 
 | ||||
|             case 0xC4: // bin 8
 | ||||
|             case 0xC5: // bin 16
 | ||||
|             case 0xC6: // bin 32
 | ||||
|             case 0xC7: // ext 8
 | ||||
|             case 0xC8: // ext 16
 | ||||
|             case 0xC9: // ext 32
 | ||||
|             case 0xD4: // fixext 1
 | ||||
|             case 0xD5: // fixext 2
 | ||||
|             case 0xD6: // fixext 4
 | ||||
|             case 0xD7: // fixext 8
 | ||||
|             case 0xD8: // fixext 16
 | ||||
|             { | ||||
|                 internal_binary_t b; | ||||
|                 return get_msgpack_binary(b) and sax->binary(b); | ||||
|             } | ||||
| 
 | ||||
|             case 0xCA: // float 32
 | ||||
|             { | ||||
|                 float number; | ||||
|  | @ -1310,6 +1489,100 @@ class binary_reader | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /*!
 | ||||
|     @brief reads a MessagePack byte array | ||||
| 
 | ||||
|     This function first reads starting bytes to determine the expected | ||||
|     byte array length and then copies this number of bytes into a byte array. | ||||
| 
 | ||||
|     @param[out] result  created byte array | ||||
| 
 | ||||
|     @return whether byte array creation completed | ||||
|     */ | ||||
|     bool get_msgpack_binary(internal_binary_t& result) | ||||
|     { | ||||
|         switch (current) | ||||
|         { | ||||
|             case 0xC4: // bin 8
 | ||||
|             { | ||||
|                 std::uint8_t len; | ||||
|                 return get_number(input_format_t::msgpack, len) and get_binary(input_format_t::msgpack, len, result); | ||||
|             } | ||||
| 
 | ||||
|             case 0xC5: // bin 16
 | ||||
|             { | ||||
|                 std::uint16_t len; | ||||
|                 return get_number(input_format_t::msgpack, len) and get_binary(input_format_t::msgpack, len, result); | ||||
|             } | ||||
| 
 | ||||
|             case 0xC6: // bin 32
 | ||||
|             { | ||||
|                 std::uint32_t len; | ||||
|                 return get_number(input_format_t::msgpack, len) and get_binary(input_format_t::msgpack, len, result); | ||||
|             } | ||||
| 
 | ||||
|             case 0xC7: // ext 8
 | ||||
|             { | ||||
|                 std::uint8_t len; | ||||
|                 result.has_subtype = true; | ||||
|                 return get_number(input_format_t::msgpack, len) and | ||||
|                        get_number(input_format_t::msgpack, result.subtype) and | ||||
|                        get_binary(input_format_t::msgpack, len, result); | ||||
|             } | ||||
| 
 | ||||
|             case 0xC8: // ext 16
 | ||||
|             { | ||||
|                 std::uint16_t len; | ||||
|                 result.has_subtype = true; | ||||
|                 return get_number(input_format_t::msgpack, len) and | ||||
|                        get_number(input_format_t::msgpack, result.subtype) and | ||||
|                        get_binary(input_format_t::msgpack, len, result); | ||||
|             } | ||||
| 
 | ||||
|             case 0xC9: // ext 32
 | ||||
|             { | ||||
|                 std::uint32_t len; | ||||
|                 result.has_subtype = true; | ||||
|                 return get_number(input_format_t::msgpack, len) and | ||||
|                        get_number(input_format_t::msgpack, result.subtype) and | ||||
|                        get_binary(input_format_t::msgpack, len, result); | ||||
|             } | ||||
| 
 | ||||
|             case 0xD4: // fixext 1
 | ||||
|             { | ||||
|                 result.has_subtype = true; | ||||
|                 return get_number(input_format_t::msgpack, result.subtype) and get_binary(input_format_t::msgpack, 1, result); | ||||
|             } | ||||
| 
 | ||||
|             case 0xD5: // fixext 2
 | ||||
|             { | ||||
|                 result.has_subtype = true; | ||||
|                 return get_number(input_format_t::msgpack, result.subtype) and get_binary(input_format_t::msgpack, 2, result); | ||||
|             } | ||||
| 
 | ||||
|             case 0xD6: // fixext 4
 | ||||
|             { | ||||
|                 result.has_subtype = true; | ||||
|                 return get_number(input_format_t::msgpack, result.subtype) and get_binary(input_format_t::msgpack, 4, result); | ||||
|             } | ||||
| 
 | ||||
|             case 0xD7: // fixext 8
 | ||||
|             { | ||||
|                 result.has_subtype = true; | ||||
|                 return get_number(input_format_t::msgpack, result.subtype) and get_binary(input_format_t::msgpack, 8, result); | ||||
|             } | ||||
| 
 | ||||
|             case 0xD8: // fixext 16
 | ||||
|             { | ||||
|                 result.has_subtype = true; | ||||
|                 return get_number(input_format_t::msgpack, result.subtype) and get_binary(input_format_t::msgpack, 16, result); | ||||
|             } | ||||
| 
 | ||||
|             default:            // LCOV_EXCL_LINE
 | ||||
|                 assert(false);  // LCOV_EXCL_LINE
 | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /*!
 | ||||
|     @param[in] len  the length of the array | ||||
|     @return whether array creation completed | ||||
|  | @ -1794,6 +2067,9 @@ class binary_reader | |||
|         return sax->end_object(); | ||||
|     } | ||||
| 
 | ||||
|     // Note, no reader for UBJSON binary types is implemented because they do
 | ||||
|     // not exist
 | ||||
| 
 | ||||
|     ///////////////////////
 | ||||
|     // Utility functions //
 | ||||
|     ///////////////////////
 | ||||
|  | @ -1901,6 +2177,38 @@ class binary_reader | |||
|         return success; | ||||
|     } | ||||
| 
 | ||||
|     /*!
 | ||||
|     @brief create a byte array by reading bytes from the input | ||||
| 
 | ||||
|     @tparam NumberType the type of the number | ||||
|     @param[in] format the current format (for diagnostics) | ||||
|     @param[in] len number of bytes to read | ||||
|     @param[out] result byte array created by reading @a len bytes | ||||
| 
 | ||||
|     @return whether byte array creation completed | ||||
| 
 | ||||
|     @note We can not reserve @a len bytes for the result, because @a len | ||||
|           may be too large. Usually, @ref unexpect_eof() detects the end of | ||||
|           the input before we run out of memory. | ||||
|     */ | ||||
|     template<typename NumberType> | ||||
|     bool get_binary(const input_format_t format, | ||||
|                     const NumberType len, | ||||
|                     internal_binary_t& result) | ||||
|     { | ||||
|         bool success = true; | ||||
|         std::generate_n(std::back_inserter(result), len, [this, &success, &format]() | ||||
|         { | ||||
|             get(); | ||||
|             if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(format, "binary"))) | ||||
|             { | ||||
|                 success = false; | ||||
|             } | ||||
|             return static_cast<std::uint8_t>(current); | ||||
|         }); | ||||
|         return success; | ||||
|     } | ||||
| 
 | ||||
|     /*!
 | ||||
|     @param[in] format   the current format (for diagnostics) | ||||
|     @param[in] context  further context information (for diagnostics) | ||||
|  |  | |||
|  | @ -31,6 +31,7 @@ struct json_sax | |||
|     using number_float_t = typename BasicJsonType::number_float_t; | ||||
|     /// type for strings
 | ||||
|     using string_t = typename BasicJsonType::string_t; | ||||
|     using binary_t = typename BasicJsonType::binary_t; | ||||
| 
 | ||||
|     /*!
 | ||||
|     @brief a null value was read | ||||
|  | @ -75,6 +76,14 @@ struct json_sax | |||
|     */ | ||||
|     virtual bool string(string_t& val) = 0; | ||||
| 
 | ||||
|     /*!
 | ||||
|     @brief a binary string was read | ||||
|     @param[in] val  binary value | ||||
|     @return whether parsing should proceed | ||||
|     @note It is safe to move the passed binary. | ||||
|     */ | ||||
|     virtual bool binary(binary_t& val) = 0; | ||||
| 
 | ||||
|     /*!
 | ||||
|     @brief the beginning of an object was read | ||||
|     @param[in] elements  number of object elements or -1 if unknown | ||||
|  | @ -149,6 +158,7 @@ class json_sax_dom_parser | |||
|     using number_unsigned_t = typename BasicJsonType::number_unsigned_t; | ||||
|     using number_float_t = typename BasicJsonType::number_float_t; | ||||
|     using string_t = typename BasicJsonType::string_t; | ||||
|     using binary_t = typename BasicJsonType::binary_t; | ||||
| 
 | ||||
|     /*!
 | ||||
|     @param[in, out] r  reference to a JSON value that is manipulated while | ||||
|  | @ -202,6 +212,12 @@ class json_sax_dom_parser | |||
|         return true; | ||||
|     } | ||||
| 
 | ||||
|     bool binary(binary_t& val) | ||||
|     { | ||||
|         handle_value(BasicJsonType::binary_array(std::move(val))); | ||||
|         return true; | ||||
|     } | ||||
| 
 | ||||
|     bool start_object(std::size_t len) | ||||
|     { | ||||
|         ref_stack.push_back(handle_value(BasicJsonType::value_t::object)); | ||||
|  | @ -331,6 +347,7 @@ class json_sax_dom_callback_parser | |||
|     using number_unsigned_t = typename BasicJsonType::number_unsigned_t; | ||||
|     using number_float_t = typename BasicJsonType::number_float_t; | ||||
|     using string_t = typename BasicJsonType::string_t; | ||||
|     using binary_t = typename BasicJsonType::binary_t; | ||||
|     using parser_callback_t = typename BasicJsonType::parser_callback_t; | ||||
|     using parse_event_t = typename BasicJsonType::parse_event_t; | ||||
| 
 | ||||
|  | @ -385,6 +402,12 @@ class json_sax_dom_callback_parser | |||
|         return true; | ||||
|     } | ||||
| 
 | ||||
|     bool binary(binary_t& val) | ||||
|     { | ||||
|         handle_value(BasicJsonType::binary_array(val)); | ||||
|         return true; | ||||
|     } | ||||
| 
 | ||||
|     bool start_object(std::size_t len) | ||||
|     { | ||||
|         // check callback for object start
 | ||||
|  | @ -635,6 +658,7 @@ class json_sax_acceptor | |||
|     using number_unsigned_t = typename BasicJsonType::number_unsigned_t; | ||||
|     using number_float_t = typename BasicJsonType::number_float_t; | ||||
|     using string_t = typename BasicJsonType::string_t; | ||||
|     using binary_t = typename BasicJsonType::binary_t; | ||||
| 
 | ||||
|     bool null() | ||||
|     { | ||||
|  | @ -666,7 +690,12 @@ class json_sax_acceptor | |||
|         return true; | ||||
|     } | ||||
| 
 | ||||
|     bool start_object(std::size_t  /*unused*/ = std::size_t(-1)) | ||||
|     bool binary(binary_t& /*unused*/) | ||||
|     { | ||||
|         return true; | ||||
|     } | ||||
| 
 | ||||
|     bool start_object(std::size_t /*unused*/ = std::size_t(-1)) | ||||
|     { | ||||
|         return true; | ||||
|     } | ||||
|  | @ -681,7 +710,7 @@ class json_sax_acceptor | |||
|         return true; | ||||
|     } | ||||
| 
 | ||||
|     bool start_array(std::size_t  /*unused*/ = std::size_t(-1)) | ||||
|     bool start_array(std::size_t /*unused*/ = std::size_t(-1)) | ||||
|     { | ||||
|         return true; | ||||
|     } | ||||
|  |  | |||
|  | @ -344,13 +344,13 @@ class lexer : public lexer_base<BasicJsonType> | |||
|                                     } | ||||
|                                     else | ||||
|                                     { | ||||
|                                         error_message = "invalid string: surrogate U+DC00..U+DFFF must be followed by U+DC00..U+DFFF"; | ||||
|                                         error_message = "invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF"; | ||||
|                                         return token_type::parse_error; | ||||
|                                     } | ||||
|                                 } | ||||
|                                 else | ||||
|                                 { | ||||
|                                     error_message = "invalid string: surrogate U+DC00..U+DFFF must be followed by U+DC00..U+DFFF"; | ||||
|                                     error_message = "invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF"; | ||||
|                                     return token_type::parse_error; | ||||
|                                 } | ||||
|                             } | ||||
|  |  | |||
|  | @ -18,6 +18,8 @@ template<typename BasicJsonType> struct internal_iterator | |||
|     typename BasicJsonType::object_t::iterator object_iterator {}; | ||||
|     /// iterator for JSON arrays
 | ||||
|     typename BasicJsonType::array_t::iterator array_iterator {}; | ||||
|     /// iterator for JSON binary arrays
 | ||||
|     typename BasicJsonType::binary_t::iterator binary_iterator {}; | ||||
|     /// generic iterator for all other types
 | ||||
|     primitive_iterator_t primitive_iterator {}; | ||||
| }; | ||||
|  |  | |||
|  | @ -126,8 +126,8 @@ class json_pointer | |||
|     /*!
 | ||||
|     @brief append an array index at the end of this JSON pointer | ||||
| 
 | ||||
|     @param[in] array_index  array index to append | ||||
|     @return JSON pointer with @a array_index appended | ||||
|     @param[in] array_idx  array index to append | ||||
|     @return JSON pointer with @a array_idx appended | ||||
| 
 | ||||
|     @liveexample{The example shows the usage of `operator/=`.,json_pointer__operator_add} | ||||
| 
 | ||||
|  | @ -139,9 +139,9 @@ class json_pointer | |||
| 
 | ||||
|     @since version 3.6.0 | ||||
|     */ | ||||
|     json_pointer& operator/=(std::size_t array_index) | ||||
|     json_pointer& operator/=(std::size_t array_idx) | ||||
|     { | ||||
|         return *this /= std::to_string(array_index); | ||||
|         return *this /= std::to_string(array_idx); | ||||
|     } | ||||
| 
 | ||||
|     /*!
 | ||||
|  | @ -189,8 +189,8 @@ class json_pointer | |||
|     @brief create a new JSON pointer by appending the array-index-token at the end of the JSON pointer | ||||
| 
 | ||||
|     @param[in] ptr  JSON pointer | ||||
|     @param[in] array_index  array index | ||||
|     @return a new JSON pointer with @a array_index appended to @a ptr | ||||
|     @param[in] array_idx  array index | ||||
|     @return a new JSON pointer with @a array_idx appended to @a ptr | ||||
| 
 | ||||
|     @liveexample{The example shows the usage of `operator/`.,json_pointer__operator_add_binary} | ||||
| 
 | ||||
|  | @ -200,9 +200,9 @@ class json_pointer | |||
| 
 | ||||
|     @since version 3.6.0 | ||||
|     */ | ||||
|     friend json_pointer operator/(const json_pointer& ptr, std::size_t array_index) | ||||
|     friend json_pointer operator/(const json_pointer& ptr, std::size_t array_idx) | ||||
|     { | ||||
|         return json_pointer(ptr) /= array_index; | ||||
|         return json_pointer(ptr) /= array_idx; | ||||
|     } | ||||
| 
 | ||||
|     /*!
 | ||||
|  | @ -329,8 +329,30 @@ class json_pointer | |||
|     */ | ||||
|     static int array_index(const std::string& s) | ||||
|     { | ||||
|         // error condition (cf. RFC 6901, Sect. 4)
 | ||||
|         if (JSON_HEDLEY_UNLIKELY(s.size() > 1 and s[0] == '0')) | ||||
|         { | ||||
|             JSON_THROW(detail::parse_error::create(106, 0, | ||||
|                                                    "array index '" + s + | ||||
|                                                    "' must not begin with '0'")); | ||||
|         } | ||||
| 
 | ||||
|         // error condition (cf. RFC 6901, Sect. 4)
 | ||||
|         if (JSON_HEDLEY_UNLIKELY(s.size() > 1 and not (s[0] >= '1' and s[0] <= '9'))) | ||||
|         { | ||||
|             JSON_THROW(detail::parse_error::create(109, 0, "array index '" + s + "' is not a number")); | ||||
|         } | ||||
| 
 | ||||
|         std::size_t processed_chars = 0; | ||||
|         const int res = std::stoi(s, &processed_chars); | ||||
|         int res = 0; | ||||
|         JSON_TRY | ||||
|         { | ||||
|             res = std::stoi(s, &processed_chars); | ||||
|         } | ||||
|         JSON_CATCH(std::out_of_range&) | ||||
|         { | ||||
|             JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + s + "'")); | ||||
|         } | ||||
| 
 | ||||
|         // check if the string was completely read
 | ||||
|         if (JSON_HEDLEY_UNLIKELY(processed_chars != s.size())) | ||||
|  | @ -397,14 +419,7 @@ class json_pointer | |||
|                 case detail::value_t::array: | ||||
|                 { | ||||
|                     // create an entry in the array
 | ||||
|                     JSON_TRY | ||||
|                     { | ||||
|                         result = &result->operator[](static_cast<size_type>(array_index(reference_token))); | ||||
|                     } | ||||
|                     JSON_CATCH(std::invalid_argument&) | ||||
|                     { | ||||
|                         JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number")); | ||||
|                     } | ||||
|                     result = &result->operator[](static_cast<size_type>(array_index(reference_token))); | ||||
|                     break; | ||||
|                 } | ||||
| 
 | ||||
|  | @ -474,14 +489,6 @@ class json_pointer | |||
| 
 | ||||
|                 case detail::value_t::array: | ||||
|                 { | ||||
|                     // error condition (cf. RFC 6901, Sect. 4)
 | ||||
|                     if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) | ||||
|                     { | ||||
|                         JSON_THROW(detail::parse_error::create(106, 0, | ||||
|                                                                "array index '" + reference_token + | ||||
|                                                                "' must not begin with '0'")); | ||||
|                     } | ||||
| 
 | ||||
|                     if (reference_token == "-") | ||||
|                     { | ||||
|                         // explicitly treat "-" as index beyond the end
 | ||||
|  | @ -490,15 +497,8 @@ class json_pointer | |||
|                     else | ||||
|                     { | ||||
|                         // convert array index to number; unchecked access
 | ||||
|                         JSON_TRY | ||||
|                         { | ||||
|                             ptr = &ptr->operator[]( | ||||
|                                 static_cast<size_type>(array_index(reference_token))); | ||||
|                         } | ||||
|                         JSON_CATCH(std::invalid_argument&) | ||||
|                         { | ||||
|                             JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number")); | ||||
|                         } | ||||
|                         ptr = &ptr->operator[]( | ||||
|                                   static_cast<size_type>(array_index(reference_token))); | ||||
|                     } | ||||
|                     break; | ||||
|                 } | ||||
|  | @ -541,23 +541,8 @@ class json_pointer | |||
|                                                                 ") is out of range")); | ||||
|                     } | ||||
| 
 | ||||
|                     // error condition (cf. RFC 6901, Sect. 4)
 | ||||
|                     if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) | ||||
|                     { | ||||
|                         JSON_THROW(detail::parse_error::create(106, 0, | ||||
|                                                                "array index '" + reference_token + | ||||
|                                                                "' must not begin with '0'")); | ||||
|                     } | ||||
| 
 | ||||
|                     // note: at performs range check
 | ||||
|                     JSON_TRY | ||||
|                     { | ||||
|                         ptr = &ptr->at(static_cast<size_type>(array_index(reference_token))); | ||||
|                     } | ||||
|                     JSON_CATCH(std::invalid_argument&) | ||||
|                     { | ||||
|                         JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number")); | ||||
|                     } | ||||
|                     ptr = &ptr->at(static_cast<size_type>(array_index(reference_token))); | ||||
|                     break; | ||||
|                 } | ||||
| 
 | ||||
|  | @ -606,24 +591,9 @@ class json_pointer | |||
|                                                                 ") is out of range")); | ||||
|                     } | ||||
| 
 | ||||
|                     // error condition (cf. RFC 6901, Sect. 4)
 | ||||
|                     if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) | ||||
|                     { | ||||
|                         JSON_THROW(detail::parse_error::create(106, 0, | ||||
|                                                                "array index '" + reference_token + | ||||
|                                                                "' must not begin with '0'")); | ||||
|                     } | ||||
| 
 | ||||
|                     // use unchecked array access
 | ||||
|                     JSON_TRY | ||||
|                     { | ||||
|                         ptr = &ptr->operator[]( | ||||
|                             static_cast<size_type>(array_index(reference_token))); | ||||
|                     } | ||||
|                     JSON_CATCH(std::invalid_argument&) | ||||
|                     { | ||||
|                         JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number")); | ||||
|                     } | ||||
|                     ptr = &ptr->operator[]( | ||||
|                               static_cast<size_type>(array_index(reference_token))); | ||||
|                     break; | ||||
|                 } | ||||
| 
 | ||||
|  | @ -665,23 +635,8 @@ class json_pointer | |||
|                                                                 ") is out of range")); | ||||
|                     } | ||||
| 
 | ||||
|                     // error condition (cf. RFC 6901, Sect. 4)
 | ||||
|                     if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) | ||||
|                     { | ||||
|                         JSON_THROW(detail::parse_error::create(106, 0, | ||||
|                                                                "array index '" + reference_token + | ||||
|                                                                "' must not begin with '0'")); | ||||
|                     } | ||||
| 
 | ||||
|                     // note: at performs range check
 | ||||
|                     JSON_TRY | ||||
|                     { | ||||
|                         ptr = &ptr->at(static_cast<size_type>(array_index(reference_token))); | ||||
|                     } | ||||
|                     JSON_CATCH(std::invalid_argument&) | ||||
|                     { | ||||
|                         JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number")); | ||||
|                     } | ||||
|                     ptr = &ptr->at(static_cast<size_type>(array_index(reference_token))); | ||||
|                     break; | ||||
|                 } | ||||
| 
 | ||||
|  | @ -723,31 +678,36 @@ class json_pointer | |||
|                         // "-" always fails the range check
 | ||||
|                         return false; | ||||
|                     } | ||||
| 
 | ||||
|                     // error condition (cf. RFC 6901, Sect. 4)
 | ||||
|                     if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) | ||||
|                     if (JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 and not ("0" <= reference_token and reference_token <= "9"))) | ||||
|                     { | ||||
|                         JSON_THROW(detail::parse_error::create(106, 0, | ||||
|                                                                "array index '" + reference_token + | ||||
|                                                                "' must not begin with '0'")); | ||||
|                         // invalid char
 | ||||
|                         return false; | ||||
|                     } | ||||
| 
 | ||||
|                     JSON_TRY | ||||
|                     if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1)) | ||||
|                     { | ||||
|                         const auto idx = static_cast<size_type>(array_index(reference_token)); | ||||
|                         if (idx >= ptr->size()) | ||||
|                         if (JSON_HEDLEY_UNLIKELY(not ('1' <= reference_token[0] and reference_token[0] <= '9'))) | ||||
|                         { | ||||
|                             // index out of range
 | ||||
|                             // first char should be between '1' and '9'
 | ||||
|                             return false; | ||||
|                         } | ||||
|                         for (std::size_t i = 1; i < reference_token.size(); i++) | ||||
|                         { | ||||
|                             if (JSON_HEDLEY_UNLIKELY(not ('0' <= reference_token[i] and reference_token[i] <= '9'))) | ||||
|                             { | ||||
|                                 // other char should be between '0' and '9'
 | ||||
|                                 return false; | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
| 
 | ||||
|                         ptr = &ptr->operator[](idx); | ||||
|                         break; | ||||
|                     } | ||||
|                     JSON_CATCH(std::invalid_argument&) | ||||
|                     const auto idx = static_cast<size_type>(array_index(reference_token)); | ||||
|                     if (idx >= ptr->size()) | ||||
|                     { | ||||
|                         JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number")); | ||||
|                         // index out of range
 | ||||
|                         return false; | ||||
|                     } | ||||
| 
 | ||||
|                     ptr = &ptr->operator[](idx); | ||||
|                     break; | ||||
|                 } | ||||
| 
 | ||||
|  |  | |||
|  | @ -113,9 +113,10 @@ | |||
|              class StringType, class BooleanType, class NumberIntegerType, \ | ||||
|              class NumberUnsignedType, class NumberFloatType,              \ | ||||
|              template<typename> class AllocatorType,                       \ | ||||
|              template<typename, typename = void> class JSONSerializer> | ||||
|              template<typename, typename = void> class JSONSerializer,     \ | ||||
|              class BinaryType> | ||||
| 
 | ||||
| #define NLOHMANN_BASIC_JSON_TPL                                            \ | ||||
|     basic_json<ObjectType, ArrayType, StringType, BooleanType,             \ | ||||
|     NumberIntegerType, NumberUnsignedType, NumberFloatType,                \ | ||||
|     AllocatorType, JSONSerializer> | ||||
|     AllocatorType, JSONSerializer, BinaryType> | ||||
|  |  | |||
|  | @ -41,6 +41,19 @@ template<typename> struct is_basic_json : std::false_type {}; | |||
| NLOHMANN_BASIC_JSON_TPL_DECLARATION | ||||
| struct is_basic_json<NLOHMANN_BASIC_JSON_TPL> : std::true_type {}; | ||||
| 
 | ||||
| //////////////////////
 | ||||
| // json_ref helpers //
 | ||||
| //////////////////////
 | ||||
| 
 | ||||
| template <typename> | ||||
| class json_ref; | ||||
| 
 | ||||
| template<typename> | ||||
| struct is_json_ref : std::false_type {}; | ||||
| 
 | ||||
| template <typename T> | ||||
| struct is_json_ref<json_ref<T>> : std::true_type {}; | ||||
| 
 | ||||
| //////////////////////////
 | ||||
| // aliases for detected //
 | ||||
| //////////////////////////
 | ||||
|  |  | |||
|  | @ -26,6 +26,7 @@ template<typename BasicJsonType, typename CharType> | |||
| class binary_writer | ||||
| { | ||||
|     using string_t = typename BasicJsonType::string_t; | ||||
|     using internal_binary_t = typename BasicJsonType::internal_binary_t; | ||||
| 
 | ||||
|   public: | ||||
|     /*!
 | ||||
|  | @ -258,6 +259,45 @@ class binary_writer | |||
|                 break; | ||||
|             } | ||||
| 
 | ||||
|             case value_t::binary: | ||||
|             { | ||||
|                 // step 1: write control byte and the binary array size
 | ||||
|                 const auto N = j.m_value.binary->size(); | ||||
|                 if (N <= 0x17) | ||||
|                 { | ||||
|                     write_number(static_cast<std::uint8_t>(0x40 + N)); | ||||
|                 } | ||||
|                 else if (N <= (std::numeric_limits<std::uint8_t>::max)()) | ||||
|                 { | ||||
|                     oa->write_character(to_char_type(0x58)); | ||||
|                     write_number(static_cast<std::uint8_t>(N)); | ||||
|                 } | ||||
|                 else if (N <= (std::numeric_limits<std::uint16_t>::max)()) | ||||
|                 { | ||||
|                     oa->write_character(to_char_type(0x59)); | ||||
|                     write_number(static_cast<std::uint16_t>(N)); | ||||
|                 } | ||||
|                 else if (N <= (std::numeric_limits<std::uint32_t>::max)()) | ||||
|                 { | ||||
|                     oa->write_character(to_char_type(0x5A)); | ||||
|                     write_number(static_cast<std::uint32_t>(N)); | ||||
|                 } | ||||
|                 // LCOV_EXCL_START
 | ||||
|                 else if (N <= (std::numeric_limits<std::uint64_t>::max)()) | ||||
|                 { | ||||
|                     oa->write_character(to_char_type(0x5B)); | ||||
|                     write_number(static_cast<std::uint64_t>(N)); | ||||
|                 } | ||||
|                 // LCOV_EXCL_STOP
 | ||||
| 
 | ||||
|                 // step 2: write each element
 | ||||
|                 oa->write_characters( | ||||
|                     reinterpret_cast<const CharType*>(j.m_value.binary->data()), | ||||
|                     N); | ||||
| 
 | ||||
|                 break; | ||||
|             } | ||||
| 
 | ||||
|             case value_t::object: | ||||
|             { | ||||
|                 // step 1: write control byte and the object size
 | ||||
|  | @ -506,6 +546,101 @@ class binary_writer | |||
|                 break; | ||||
|             } | ||||
| 
 | ||||
|             case value_t::binary: | ||||
|             { | ||||
|                 // step 0: determine if the binary type has a set subtype to
 | ||||
|                 // determine whether or not to use the ext or fixext types
 | ||||
|                 const bool use_ext = j.m_value.binary->has_subtype; | ||||
| 
 | ||||
|                 // step 1: write control byte and the byte string length
 | ||||
|                 const auto N = j.m_value.binary->size(); | ||||
|                 if (N <= (std::numeric_limits<std::uint8_t>::max)()) | ||||
|                 { | ||||
|                     std::uint8_t output_type; | ||||
|                     bool fixed = true; | ||||
|                     if (use_ext) | ||||
|                     { | ||||
|                         switch (N) | ||||
|                         { | ||||
|                             case 1: | ||||
|                                 output_type = 0xD4; // fixext 1
 | ||||
|                                 break; | ||||
|                             case 2: | ||||
|                                 output_type = 0xD5; // fixext 2
 | ||||
|                                 break; | ||||
|                             case 4: | ||||
|                                 output_type = 0xD6; // fixext 4
 | ||||
|                                 break; | ||||
|                             case 8: | ||||
|                                 output_type = 0xD7; // fixext 8
 | ||||
|                                 break; | ||||
|                             case 16: | ||||
|                                 output_type = 0xD8; // fixext 16
 | ||||
|                                 break; | ||||
|                             default: | ||||
|                                 output_type = 0xC7; // ext 8
 | ||||
|                                 fixed = false; | ||||
|                                 break; | ||||
|                         } | ||||
| 
 | ||||
|                     } | ||||
|                     else | ||||
|                     { | ||||
|                         output_type = 0xC4; // bin 8
 | ||||
|                         fixed = false; | ||||
|                     } | ||||
| 
 | ||||
|                     oa->write_character(to_char_type(output_type)); | ||||
|                     if (not fixed) | ||||
|                     { | ||||
|                         write_number(static_cast<std::uint8_t>(N)); | ||||
|                     } | ||||
|                 } | ||||
|                 else if (N <= (std::numeric_limits<std::uint16_t>::max)()) | ||||
|                 { | ||||
|                     std::uint8_t output_type; | ||||
|                     if (use_ext) | ||||
|                     { | ||||
|                         output_type = 0xC8; // ext 16
 | ||||
|                     } | ||||
|                     else | ||||
|                     { | ||||
|                         output_type = 0xC5; // bin 16
 | ||||
|                     } | ||||
| 
 | ||||
|                     oa->write_character(to_char_type(output_type)); | ||||
|                     write_number(static_cast<std::uint16_t>(N)); | ||||
|                 } | ||||
|                 else if (N <= (std::numeric_limits<std::uint32_t>::max)()) | ||||
|                 { | ||||
|                     std::uint8_t output_type; | ||||
|                     if (use_ext) | ||||
|                     { | ||||
|                         output_type = 0xC9; // ext 32
 | ||||
|                     } | ||||
|                     else | ||||
|                     { | ||||
|                         output_type = 0xC6; // bin 32
 | ||||
|                     } | ||||
| 
 | ||||
|                     oa->write_character(to_char_type(output_type)); | ||||
|                     write_number(static_cast<std::uint32_t>(N)); | ||||
|                 } | ||||
| 
 | ||||
|                 // step 1.5: if this is an ext type, write the subtype
 | ||||
|                 if (use_ext) | ||||
|                 { | ||||
|                     write_number(j.m_value.binary->subtype); | ||||
|                 } | ||||
| 
 | ||||
|                 // step 2: write the byte string
 | ||||
|                 oa->write_characters( | ||||
|                     reinterpret_cast<const CharType*>(j.m_value.binary->data()), | ||||
|                     N); | ||||
| 
 | ||||
|                 break; | ||||
|             } | ||||
| 
 | ||||
|             case value_t::object: | ||||
|             { | ||||
|                 // step 1: write control byte and the object size
 | ||||
|  | @ -649,6 +784,49 @@ class binary_writer | |||
|                 break; | ||||
|             } | ||||
| 
 | ||||
|             case value_t::binary: | ||||
|             { | ||||
|                 if (add_prefix) | ||||
|                 { | ||||
|                     oa->write_character(to_char_type('[')); | ||||
|                 } | ||||
| 
 | ||||
|                 if (use_type and not j.m_value.binary->empty()) | ||||
|                 { | ||||
|                     assert(use_count); | ||||
|                     oa->write_character(to_char_type('$')); | ||||
|                     oa->write_character('U'); | ||||
|                 } | ||||
| 
 | ||||
|                 if (use_count) | ||||
|                 { | ||||
|                     oa->write_character(to_char_type('#')); | ||||
|                     write_number_with_ubjson_prefix(j.m_value.binary->size(), true); | ||||
|                 } | ||||
| 
 | ||||
|                 if (use_type) | ||||
|                 { | ||||
|                     oa->write_characters( | ||||
|                         reinterpret_cast<const CharType*>(j.m_value.binary->data()), | ||||
|                         j.m_value.binary->size()); | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     for (size_t i = 0; i < j.m_value.binary->size(); ++i) | ||||
|                     { | ||||
|                         oa->write_character(to_char_type('U')); | ||||
|                         oa->write_character(j.m_value.binary->data()[i]); | ||||
|                     } | ||||
|                 } | ||||
| 
 | ||||
|                 if (not use_count) | ||||
|                 { | ||||
|                     oa->write_character(to_char_type(']')); | ||||
|                 } | ||||
| 
 | ||||
|                 break; | ||||
|             } | ||||
| 
 | ||||
|             case value_t::object: | ||||
|             { | ||||
|                 if (add_prefix) | ||||
|  | @ -871,6 +1049,14 @@ class binary_writer | |||
|         return sizeof(std::int32_t) + embedded_document_size + 1ul; | ||||
|     } | ||||
| 
 | ||||
|     /*!
 | ||||
|     @return The size of the BSON-encoded binary array @a value | ||||
|     */ | ||||
|     static std::size_t calc_bson_binary_size(const typename BasicJsonType::internal_binary_t& value) | ||||
|     { | ||||
|         return sizeof(std::int32_t) + value.size() + 1ul; | ||||
|     } | ||||
| 
 | ||||
|     /*!
 | ||||
|     @brief Writes a BSON element with key @a name and array @a value | ||||
|     */ | ||||
|  | @ -890,6 +1076,27 @@ class binary_writer | |||
|         oa->write_character(to_char_type(0x00)); | ||||
|     } | ||||
| 
 | ||||
|     /*!
 | ||||
|     @brief Writes a BSON element with key @a name and binary value @a value | ||||
|     */ | ||||
|     void write_bson_binary(const string_t& name, | ||||
|                            const internal_binary_t& value) | ||||
|     { | ||||
|         write_bson_entry_header(name, 0x05); | ||||
| 
 | ||||
|         write_number<std::int32_t, true>(static_cast<std::int32_t>(value.size())); | ||||
|         std::uint8_t subtype = 0x00; // Generic Binary Subtype
 | ||||
|         if (value.has_subtype) | ||||
|         { | ||||
|             subtype = value.subtype; | ||||
|         } | ||||
|         write_number(subtype); | ||||
| 
 | ||||
|         oa->write_characters( | ||||
|             reinterpret_cast<const CharType*>(value.data()), | ||||
|             value.size()); | ||||
|     } | ||||
| 
 | ||||
|     /*!
 | ||||
|     @brief Calculates the size necessary to serialize the JSON value @a j with its @a name | ||||
|     @return The calculated size for the BSON document entry for @a j with the given @a name. | ||||
|  | @ -906,6 +1113,9 @@ class binary_writer | |||
|             case value_t::array: | ||||
|                 return header_size + calc_bson_array_size(*j.m_value.array); | ||||
| 
 | ||||
|             case value_t::binary: | ||||
|                 return header_size + calc_bson_binary_size(*j.m_value.binary); | ||||
| 
 | ||||
|             case value_t::boolean: | ||||
|                 return header_size + 1ul; | ||||
| 
 | ||||
|  | @ -950,6 +1160,9 @@ class binary_writer | |||
|             case value_t::array: | ||||
|                 return write_bson_array(name, *j.m_value.array); | ||||
| 
 | ||||
|             case value_t::binary: | ||||
|                 return write_bson_binary(name, *j.m_value.binary); | ||||
| 
 | ||||
|             case value_t::boolean: | ||||
|                 return write_bson_boolean(name, j.m_value.boolean); | ||||
| 
 | ||||
|  | @ -1230,7 +1443,8 @@ class binary_writer | |||
|             case value_t::string: | ||||
|                 return 'S'; | ||||
| 
 | ||||
|             case value_t::array: | ||||
|             case value_t::array: // fallthrough
 | ||||
|             case value_t::binary: | ||||
|                 return '['; | ||||
| 
 | ||||
|             case value_t::object: | ||||
|  | @ -1300,7 +1514,7 @@ class binary_writer | |||
|     static CharType to_char_type(std::uint8_t x) noexcept | ||||
|     { | ||||
|         static_assert(sizeof(std::uint8_t) == sizeof(CharType), "size of CharType must be equal to std::uint8_t"); | ||||
|         static_assert(std::is_pod<CharType>::value, "CharType must be POD"); | ||||
|         static_assert(std::is_trivial<CharType>::value, "CharType must be trivial"); | ||||
|         CharType result; | ||||
|         std::memcpy(&result, &x, sizeof(x)); | ||||
|         return result; | ||||
|  |  | |||
|  | @ -45,6 +45,7 @@ class serializer | |||
|     using number_float_t = typename BasicJsonType::number_float_t; | ||||
|     using number_integer_t = typename BasicJsonType::number_integer_t; | ||||
|     using number_unsigned_t = typename BasicJsonType::number_unsigned_t; | ||||
|     using binary_t = typename BasicJsonType::binary_t; | ||||
|     static constexpr std::uint8_t UTF8_ACCEPT = 0; | ||||
|     static constexpr std::uint8_t UTF8_REJECT = 1; | ||||
| 
 | ||||
|  | @ -83,16 +84,19 @@ class serializer | |||
|     - strings and object keys are escaped using `escape_string()` | ||||
|     - integer numbers are converted implicitly via `operator<<` | ||||
|     - floating-point numbers are converted to a string using `"%g"` format | ||||
|     - if specified to, binary values are output using the syntax `b[]`, otherwise an exception is thrown | ||||
| 
 | ||||
|     @param[in] val             value to serialize | ||||
|     @param[in] pretty_print    whether the output shall be pretty-printed | ||||
|     @param[in] indent_step     the indent level | ||||
|     @param[in] current_indent  the current indent level (only used internally) | ||||
|     @param[in] val               value to serialize | ||||
|     @param[in] pretty_print      whether the output shall be pretty-printed | ||||
|     @param[in] indent_step       the indent level | ||||
|     @param[in] current_indent    the current indent level (only used internally) | ||||
|     @param[in] serialize_binary  whether the output shall include non-standard binary output | ||||
|     */ | ||||
|     void dump(const BasicJsonType& val, const bool pretty_print, | ||||
|               const bool ensure_ascii, | ||||
|               const unsigned int indent_step, | ||||
|               const unsigned int current_indent = 0) | ||||
|               const unsigned int current_indent = 0, | ||||
|               const bool serialize_binary = false) | ||||
|     { | ||||
|         switch (val.m_type) | ||||
|         { | ||||
|  | @ -123,7 +127,7 @@ class serializer | |||
|                         o->write_character('\"'); | ||||
|                         dump_escaped(i->first, ensure_ascii); | ||||
|                         o->write_characters("\": ", 3); | ||||
|                         dump(i->second, true, ensure_ascii, indent_step, new_indent); | ||||
|                         dump(i->second, true, ensure_ascii, indent_step, new_indent, serialize_binary); | ||||
|                         o->write_characters(",\n", 2); | ||||
|                     } | ||||
| 
 | ||||
|  | @ -134,7 +138,7 @@ class serializer | |||
|                     o->write_character('\"'); | ||||
|                     dump_escaped(i->first, ensure_ascii); | ||||
|                     o->write_characters("\": ", 3); | ||||
|                     dump(i->second, true, ensure_ascii, indent_step, new_indent); | ||||
|                     dump(i->second, true, ensure_ascii, indent_step, new_indent, serialize_binary); | ||||
| 
 | ||||
|                     o->write_character('\n'); | ||||
|                     o->write_characters(indent_string.c_str(), current_indent); | ||||
|  | @ -151,7 +155,7 @@ class serializer | |||
|                         o->write_character('\"'); | ||||
|                         dump_escaped(i->first, ensure_ascii); | ||||
|                         o->write_characters("\":", 2); | ||||
|                         dump(i->second, false, ensure_ascii, indent_step, current_indent); | ||||
|                         dump(i->second, false, ensure_ascii, indent_step, current_indent, serialize_binary); | ||||
|                         o->write_character(','); | ||||
|                     } | ||||
| 
 | ||||
|  | @ -161,7 +165,7 @@ class serializer | |||
|                     o->write_character('\"'); | ||||
|                     dump_escaped(i->first, ensure_ascii); | ||||
|                     o->write_characters("\":", 2); | ||||
|                     dump(i->second, false, ensure_ascii, indent_step, current_indent); | ||||
|                     dump(i->second, false, ensure_ascii, indent_step, current_indent, serialize_binary); | ||||
| 
 | ||||
|                     o->write_character('}'); | ||||
|                 } | ||||
|  | @ -193,14 +197,14 @@ class serializer | |||
|                             i != val.m_value.array->cend() - 1; ++i) | ||||
|                     { | ||||
|                         o->write_characters(indent_string.c_str(), new_indent); | ||||
|                         dump(*i, true, ensure_ascii, indent_step, new_indent); | ||||
|                         dump(*i, true, ensure_ascii, indent_step, new_indent, serialize_binary); | ||||
|                         o->write_characters(",\n", 2); | ||||
|                     } | ||||
| 
 | ||||
|                     // last element
 | ||||
|                     assert(not val.m_value.array->empty()); | ||||
|                     o->write_characters(indent_string.c_str(), new_indent); | ||||
|                     dump(val.m_value.array->back(), true, ensure_ascii, indent_step, new_indent); | ||||
|                     dump(val.m_value.array->back(), true, ensure_ascii, indent_step, new_indent, serialize_binary); | ||||
| 
 | ||||
|                     o->write_character('\n'); | ||||
|                     o->write_characters(indent_string.c_str(), current_indent); | ||||
|  | @ -214,13 +218,13 @@ class serializer | |||
|                     for (auto i = val.m_value.array->cbegin(); | ||||
|                             i != val.m_value.array->cend() - 1; ++i) | ||||
|                     { | ||||
|                         dump(*i, false, ensure_ascii, indent_step, current_indent); | ||||
|                         dump(*i, false, ensure_ascii, indent_step, current_indent, serialize_binary); | ||||
|                         o->write_character(','); | ||||
|                     } | ||||
| 
 | ||||
|                     // last element
 | ||||
|                     assert(not val.m_value.array->empty()); | ||||
|                     dump(val.m_value.array->back(), false, ensure_ascii, indent_step, current_indent); | ||||
|                     dump(val.m_value.array->back(), false, ensure_ascii, indent_step, current_indent, serialize_binary); | ||||
| 
 | ||||
|                     o->write_character(']'); | ||||
|                 } | ||||
|  | @ -236,6 +240,33 @@ class serializer | |||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             case value_t::binary: | ||||
|             { | ||||
|                 if (not serialize_binary) | ||||
|                 { | ||||
|                     JSON_THROW(type_error::create(317, "cannot serialize binary data to text JSON")); | ||||
|                 } | ||||
| 
 | ||||
|                 if (val.m_value.binary->empty()) | ||||
|                 { | ||||
|                     o->write_characters("b[]", 3); | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     o->write_characters("b[", 2); | ||||
|                     for (auto i = val.m_value.binary->cbegin(); | ||||
|                             i != val.m_value.binary->cend() - 1; ++i) | ||||
|                     { | ||||
|                         dump_integer(*i); | ||||
|                         o->write_character(','); | ||||
|                     } | ||||
| 
 | ||||
|                     dump_integer(val.m_value.binary->back()); | ||||
|                     o->write_character(']'); | ||||
|                 } | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             case value_t::boolean: | ||||
|             { | ||||
|                 if (val.m_value.boolean) | ||||
|  | @ -592,7 +623,8 @@ class serializer | |||
|     */ | ||||
|     template<typename NumberType, detail::enable_if_t< | ||||
|                  std::is_same<NumberType, number_unsigned_t>::value or | ||||
|                  std::is_same<NumberType, number_integer_t>::value, | ||||
|                  std::is_same<NumberType, number_integer_t>::value or | ||||
|                  std::is_same<NumberType, typename binary_t::value_type>::value, | ||||
|                  int> = 0> | ||||
|     void dump_integer(NumberType x) | ||||
|     { | ||||
|  | @ -630,7 +662,7 @@ class serializer | |||
|         if (is_negative) | ||||
|         { | ||||
|             *buffer_ptr = '-'; | ||||
|             abs_value = remove_sign(x); | ||||
|             abs_value = remove_sign(static_cast<number_integer_t>(x)); | ||||
| 
 | ||||
|             // account one more byte for the minus sign
 | ||||
|             n_chars = 1 + count_digits(abs_value); | ||||
|  | @ -807,7 +839,9 @@ class serializer | |||
|                 ? (byte & 0x3fu) | (codep << 6u) | ||||
|                 : (0xFFu >> type) & (byte); | ||||
| 
 | ||||
|         state = utf8d[256u + state * 16u + type]; | ||||
|         std::size_t index = 256u + static_cast<size_t>(state) * 16u + static_cast<size_t>(type); | ||||
|         assert(index < 400); | ||||
|         state = utf8d[index]; | ||||
|         return state; | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -48,6 +48,7 @@ enum class value_t : std::uint8_t | |||
|     number_integer,   ///< number value (signed integer)
 | ||||
|     number_unsigned,  ///< number value (unsigned integer)
 | ||||
|     number_float,     ///< number value (floating-point)
 | ||||
|     binary,           ///< binary array (ordered collection of bytes)
 | ||||
|     discarded         ///< discarded by the parser callback function
 | ||||
| }; | ||||
| 
 | ||||
|  | @ -55,17 +56,21 @@ enum class value_t : std::uint8_t | |||
| @brief comparison operator for JSON types | ||||
| 
 | ||||
| Returns an ordering that is similar to Python: | ||||
| - order: null < boolean < number < object < array < string | ||||
| - order: null < boolean < number < object < array < string < binary | ||||
| - furthermore, each type is not smaller than itself | ||||
| - discarded values are not comparable | ||||
| - binary is represented as a b"" string in python and directly comparable to a | ||||
|   string; however, making a binary array directly comparable with a string would | ||||
|   be surprising behavior in a JSON file. | ||||
| 
 | ||||
| @since version 1.0.0 | ||||
| */ | ||||
| inline bool operator<(const value_t lhs, const value_t rhs) noexcept | ||||
| { | ||||
|     static constexpr std::array<std::uint8_t, 8> order = {{ | ||||
|     static constexpr std::array<std::uint8_t, 9> order = {{ | ||||
|             0 /* null */, 3 /* object */, 4 /* array */, 5 /* string */, | ||||
|             1 /* boolean */, 2 /* integer */, 2 /* unsigned */, 2 /* float */ | ||||
|             1 /* boolean */, 2 /* integer */, 2 /* unsigned */, 2 /* float */, | ||||
|             6 /* binary */ | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|  |  | |||
|  | @ -97,6 +97,9 @@ default; will be used in @ref number_integer_t) | |||
| `uint64_t` by default; will be used in @ref number_unsigned_t) | ||||
| @tparam NumberFloatType type for JSON floating-point numbers (`double` by | ||||
| default; will be used in @ref number_float_t) | ||||
| @tparam BinaryType type for packed binary data for compatibility with binary | ||||
| serialization formats (`std::vector<std::uint8_t>` by default; will be used in | ||||
| @ref binary_t) | ||||
| @tparam AllocatorType type of the allocator to use (`std::allocator` by | ||||
| default) | ||||
| @tparam JSONSerializer the serializer to resolve internal calls to `to_json()` | ||||
|  | @ -830,6 +833,100 @@ class basic_json | |||
|     */ | ||||
|     using number_float_t = NumberFloatType; | ||||
| 
 | ||||
|     /*!
 | ||||
|     @brief a type for a packed binary type | ||||
| 
 | ||||
|     This type is a type designed to carry binary data that appears in various | ||||
|     serialized formats, such as CBOR's Major Type 2, MessagePack's bin, and | ||||
|     BSON's generic binary subtype.  This type is NOT a part of standard JSON and | ||||
|     exists solely for compatibility with these binary types.  As such, it is | ||||
|     simply defined as an ordered sequence of zero or more byte values. | ||||
| 
 | ||||
|     Additionally, as an implementation detail, the subtype of the binary data is | ||||
|     carried around as a `unint8_t`, which is compatible with both of the binary | ||||
|     data formats that use binary subtyping, (though the specific numbering is | ||||
|     incompatible with each other, and it is up to the user to translate between | ||||
|     them). | ||||
| 
 | ||||
|     [CBOR's RFC 7049](https://tools.ietf.org/html/rfc7049) describes this type
 | ||||
|     as: | ||||
|     > Major type 2:  a byte string.  The string's length in bytes is | ||||
|     > represented following the rules for positive integers (major type | ||||
|     > 0). | ||||
| 
 | ||||
|     [MessagePack's documentation on the bin type | ||||
|     family](https://github.com/msgpack/msgpack/blob/master/spec.md#bin-format-family)
 | ||||
|     describes this type as: | ||||
|     > Bin format family stores an byte array in 2, 3, or 5 bytes of extra bytes | ||||
|     > in addition to the size of the byte array. | ||||
| 
 | ||||
|     [BSON's specifications](http://bsonspec.org/spec.html) describe several
 | ||||
|     binary types; however, this type is intended to represent the generic binary | ||||
|     type which has the description: | ||||
|     > Generic binary subtype - This is the most commonly used binary subtype and | ||||
|     > should be the 'default' for drivers and tools. | ||||
| 
 | ||||
|     None of these impose any limitations on the internal representation other | ||||
|     than the basic unit of storage be some type of array whose parts are | ||||
|     decomposible into bytes. | ||||
| 
 | ||||
|     The default representation of this binary format is a | ||||
|     `std::vector<std::uint8_t>`, which is a very common way to represent a byte | ||||
|     array in modern C++. | ||||
| 
 | ||||
|     #### Default type | ||||
| 
 | ||||
|     The default values for @a BinaryType is `std::vector<std::uint8_t>` | ||||
| 
 | ||||
|     #### Storage | ||||
| 
 | ||||
|     Binary Arrays are stored as pointers in a @ref basic_json type.  That is, | ||||
|     for any access to array values, a pointer of the type `binary_t*` must be | ||||
|     dereferenced. | ||||
| 
 | ||||
|     @sa @ref array_t -- type for an array value | ||||
| 
 | ||||
|     @since version 3.8.0 | ||||
|     */ | ||||
|     using binary_t = BinaryType; | ||||
| 
 | ||||
|     /*!
 | ||||
|     @brief an internal type for a backed binary type | ||||
| 
 | ||||
|     This type is designed to be `binary_t` but with the subtype implementation | ||||
|     detail.  This type exists so that the user does not have to specify a struct | ||||
|     his- or herself with a specific naming scheme in order to override the | ||||
|     binary type.  I.e. it's for ease of use. | ||||
|     */ | ||||
|     struct internal_binary_t : public BinaryType | ||||
|     { | ||||
|         using BinaryType::BinaryType; | ||||
|         internal_binary_t() noexcept(noexcept(BinaryType())) | ||||
|             : BinaryType() | ||||
|         {} | ||||
|         internal_binary_t(const BinaryType& bint) noexcept(noexcept(BinaryType(bint))) | ||||
|             : BinaryType(bint) | ||||
|         {} | ||||
|         internal_binary_t(BinaryType&& bint) noexcept(noexcept(BinaryType(std::move(bint)))) | ||||
|             : BinaryType(std::move(bint)) | ||||
|         {} | ||||
|         internal_binary_t(const BinaryType& bint, std::uint8_t st) noexcept(noexcept(BinaryType(bint))) | ||||
|             : BinaryType(bint) | ||||
|             , subtype(st) | ||||
|             , has_subtype(true) | ||||
|         {} | ||||
|         internal_binary_t(BinaryType&& bint, std::uint8_t st) noexcept(noexcept(BinaryType(std::move(bint)))) | ||||
|             : BinaryType(std::move(bint)) | ||||
|             , subtype(st) | ||||
|             , has_subtype(true) | ||||
|         {} | ||||
| 
 | ||||
|         // TOOD: If minimum C++ version is ever bumped to C++17, this field
 | ||||
|         // deserves to be a std::optional
 | ||||
|         std::uint8_t subtype = 0; | ||||
|         bool has_subtype = false; | ||||
|     }; | ||||
| 
 | ||||
|     /// @}
 | ||||
| 
 | ||||
|   private: | ||||
|  | @ -872,6 +969,7 @@ class basic_json | |||
|     number    | number_integer  | @ref number_integer_t | ||||
|     number    | number_unsigned | @ref number_unsigned_t | ||||
|     number    | number_float    | @ref number_float_t | ||||
|     binary    | binary          | pointer to @ref internal_binary_t | ||||
|     null      | null            | *no value is stored* | ||||
| 
 | ||||
|     @note Variable-length types (objects, arrays, and strings) are stored as | ||||
|  | @ -888,6 +986,8 @@ class basic_json | |||
|         array_t* array; | ||||
|         /// string (stored with pointer to save storage)
 | ||||
|         string_t* string; | ||||
|         /// binary (stored with pointer to save storage)
 | ||||
|         internal_binary_t* binary; | ||||
|         /// boolean
 | ||||
|         boolean_t boolean; | ||||
|         /// number (integer)
 | ||||
|  | @ -930,6 +1030,12 @@ class basic_json | |||
|                     break; | ||||
|                 } | ||||
| 
 | ||||
|                 case value_t::binary: | ||||
|                 { | ||||
|                     binary = create<internal_binary_t>(); | ||||
|                     break; | ||||
|                 } | ||||
| 
 | ||||
|                 case value_t::boolean: | ||||
|                 { | ||||
|                     boolean = boolean_t(false); | ||||
|  | @ -1008,6 +1114,30 @@ class basic_json | |||
|             array = create<array_t>(std::move(value)); | ||||
|         } | ||||
| 
 | ||||
|         /// constructor for binary arrays
 | ||||
|         json_value(const binary_t& value) | ||||
|         { | ||||
|             binary = create<internal_binary_t>(value); | ||||
|         } | ||||
| 
 | ||||
|         /// constructor for rvalue binary arrays
 | ||||
|         json_value(binary_t&& value) | ||||
|         { | ||||
|             binary = create<internal_binary_t>(std::move(value)); | ||||
|         } | ||||
| 
 | ||||
|         /// constructor for binary arrays (internal type)
 | ||||
|         json_value(const internal_binary_t& value) | ||||
|         { | ||||
|             binary = create<internal_binary_t>(value); | ||||
|         } | ||||
| 
 | ||||
|         /// constructor for rvalue binary arrays (internal type)
 | ||||
|         json_value(internal_binary_t&& value) | ||||
|         { | ||||
|             binary = create<internal_binary_t>(std::move(value)); | ||||
|         } | ||||
| 
 | ||||
|         void destroy(value_t t) noexcept | ||||
|         { | ||||
|             // flatten the current json_value to a heap-allocated stack
 | ||||
|  | @ -1083,6 +1213,14 @@ class basic_json | |||
|                     break; | ||||
|                 } | ||||
| 
 | ||||
|                 case value_t::binary: | ||||
|                 { | ||||
|                     AllocatorType<internal_binary_t> alloc; | ||||
|                     std::allocator_traits<decltype(alloc)>::destroy(alloc, binary); | ||||
|                     std::allocator_traits<decltype(alloc)>::deallocate(alloc, binary, 1); | ||||
|                     break; | ||||
|                 } | ||||
| 
 | ||||
|                 default: | ||||
|                 { | ||||
|                     break; | ||||
|  | @ -1105,6 +1243,7 @@ class basic_json | |||
|         assert(m_type != value_t::object or m_value.object != nullptr); | ||||
|         assert(m_type != value_t::array or m_value.array != nullptr); | ||||
|         assert(m_type != value_t::string or m_value.string != nullptr); | ||||
|         assert(m_type != value_t::binary or m_value.binary != nullptr); | ||||
|     } | ||||
| 
 | ||||
|   public: | ||||
|  | @ -1203,6 +1342,7 @@ class basic_json | |||
|     number      | `0` | ||||
|     object      | `{}` | ||||
|     array       | `[]` | ||||
|     binary      | empty array | ||||
| 
 | ||||
|     @param[in] v  the type of the value to create | ||||
| 
 | ||||
|  | @ -1274,6 +1414,12 @@ class basic_json | |||
|       @ref number_float_t, and all convertible number types such as `int`, | ||||
|       `size_t`, `int64_t`, `float` or `double` can be used. | ||||
|     - **boolean**: @ref boolean_t / `bool` can be used. | ||||
|     - **binary**: @ref binary_t / `std::vector<uint8_t>` may be used, | ||||
|       unfortunately because string literals cannot be distinguished from binary | ||||
|       character arrays by the C++ type system, all types compatible with `const | ||||
|       char*` will be directed to the string constructor instead.  This is both | ||||
|       for backwards compatibility, and due to the fact that a binary type is not | ||||
|       a standard JSON type. | ||||
| 
 | ||||
|     See the examples below. | ||||
| 
 | ||||
|  | @ -1355,6 +1501,7 @@ class basic_json | |||
|         using other_string_t = typename BasicJsonType::string_t; | ||||
|         using other_object_t = typename BasicJsonType::object_t; | ||||
|         using other_array_t = typename BasicJsonType::array_t; | ||||
|         using other_binary_t = typename BasicJsonType::internal_binary_t; | ||||
| 
 | ||||
|         switch (val.type()) | ||||
|         { | ||||
|  | @ -1379,6 +1526,9 @@ class basic_json | |||
|             case value_t::array: | ||||
|                 JSONSerializer<other_array_t>::to_json(*this, val.template get_ref<const other_array_t&>()); | ||||
|                 break; | ||||
|             case value_t::binary: | ||||
|                 JSONSerializer<other_binary_t>::to_json(*this, val.template get_ref<const other_binary_t&>()); | ||||
|                 break; | ||||
|             case value_t::null: | ||||
|                 *this = nullptr; | ||||
|                 break; | ||||
|  | @ -1517,6 +1667,96 @@ class basic_json | |||
|         assert_invariant(); | ||||
|     } | ||||
| 
 | ||||
|     /*!
 | ||||
|     @brief explicitly create a binary array from an already constructed copy of | ||||
|     its base type | ||||
| 
 | ||||
|     Creates a JSON binary array value from a given `binary_t`. Binary values are | ||||
|     part of various binary formats, such as CBOR, MsgPack, and BSON.  And this | ||||
|     constructor is used to create a value for serialization to those formats. | ||||
| 
 | ||||
|     @note Note, this function exists because of the difficulty in correctly | ||||
|     specifying the correct template overload in the standard value ctor, as both | ||||
|     JSON arrays and JSON binary arrays are backed with some form of a | ||||
|     `std::vector`.  Because JSON binary arrays are a non-standard extension it | ||||
|     was decided that it would be best to prevent automatic initialization of a | ||||
|     binary array type, for backwards compatibility and so it does not happen on | ||||
|     accident. | ||||
| 
 | ||||
|     @param[in] init  `binary_t` with JSON values to create a binary array from | ||||
| 
 | ||||
|     @return JSON binary array value | ||||
| 
 | ||||
|     @complexity Linear in the size of @a init. | ||||
| 
 | ||||
|     @exceptionsafety Strong guarantee: if an exception is thrown, there are no | ||||
|     changes to any JSON value. | ||||
| 
 | ||||
|     @since version 3.8.0 | ||||
|     */ | ||||
|     JSON_HEDLEY_WARN_UNUSED_RESULT | ||||
|     static basic_json binary_array(const binary_t& init) | ||||
|     { | ||||
|         auto res = basic_json(); | ||||
|         res.m_type = value_t::binary; | ||||
|         res.m_value = init; | ||||
|         return res; | ||||
|     } | ||||
| 
 | ||||
|     JSON_HEDLEY_WARN_UNUSED_RESULT | ||||
|     static basic_json binary_array(const binary_t& init, std::uint8_t subtype) | ||||
|     { | ||||
|         auto res = basic_json(); | ||||
|         res.m_type = value_t::binary; | ||||
|         res.m_value = internal_binary_t(init, subtype); | ||||
|         return res; | ||||
|     } | ||||
| 
 | ||||
|     /*!
 | ||||
|     @brief explicitly create a binary array from an already constructed rvalue | ||||
|     copy of its base type | ||||
| 
 | ||||
|     Creates a JSON binary array value from a given `binary_t`. Binary values are | ||||
|     part of various binary formats, such as CBOR, MsgPack, and BSON.  And this | ||||
|     constructor is used to create a value for serialization to those formats. | ||||
| 
 | ||||
|     @note Note, this function exists because of the difficulty in correctly | ||||
|     specifying the correct template overload in the standard value ctor, as both | ||||
|     JSON arrays and JSON binary arrays are backed with some form of a | ||||
|     `std::vector`.  Because JSON binary arrays are a non-standard extension it | ||||
|     was decided that it would be best to prevent automatic initialization of a | ||||
|     binary array type, for backwards compatibility and so it doesn't happen on | ||||
|     accident. | ||||
| 
 | ||||
|     @param[in] init  `binary_t` with JSON values to create a binary array from | ||||
| 
 | ||||
|     @return JSON binary array value | ||||
| 
 | ||||
|     @complexity Linear in the size of @a init. | ||||
| 
 | ||||
|     @exceptionsafety Strong guarantee: if an exception is thrown, there are no | ||||
|     changes to any JSON value. | ||||
| 
 | ||||
|     @since version 3.8.0 | ||||
|     */ | ||||
|     JSON_HEDLEY_WARN_UNUSED_RESULT | ||||
|     static basic_json binary_array(binary_t&& init) | ||||
|     { | ||||
|         auto res = basic_json(); | ||||
|         res.m_type = value_t::binary; | ||||
|         res.m_value = std::move(init); | ||||
|         return res; | ||||
|     } | ||||
| 
 | ||||
|     JSON_HEDLEY_WARN_UNUSED_RESULT | ||||
|     static basic_json binary_array(binary_t&& init, std::uint8_t subtype) | ||||
|     { | ||||
|         auto res = basic_json(); | ||||
|         res.m_type = value_t::binary; | ||||
|         res.m_value = internal_binary_t(std::move(init), subtype); | ||||
|         return res; | ||||
|     } | ||||
| 
 | ||||
|     /*!
 | ||||
|     @brief explicitly create an array from an initializer list | ||||
| 
 | ||||
|  | @ -1772,6 +2012,12 @@ class basic_json | |||
|                 break; | ||||
|             } | ||||
| 
 | ||||
|             case value_t::binary: | ||||
|             { | ||||
|                 m_value = *first.m_object->m_value.binary; | ||||
|                 break; | ||||
|             } | ||||
| 
 | ||||
|             default: | ||||
|                 JSON_THROW(invalid_iterator::create(206, "cannot construct with iterators from " + | ||||
|                                                     std::string(first.m_object->type_name()))); | ||||
|  | @ -1785,10 +2031,10 @@ class basic_json | |||
|     // other constructors and destructor //
 | ||||
|     ///////////////////////////////////////
 | ||||
| 
 | ||||
|     /// @private
 | ||||
|     basic_json(const detail::json_ref<basic_json>& ref) | ||||
|         : basic_json(ref.moved_or_copied()) | ||||
|     {} | ||||
|     template <typename JsonRef, | ||||
|               detail::enable_if_t<detail::conjunction<detail::is_json_ref<JsonRef>, | ||||
|                                   std::is_same<typename JsonRef::value_type, basic_json>>::value, int> = 0 > | ||||
|     basic_json(const JsonRef& ref) : basic_json(ref.moved_or_copied()) {} | ||||
| 
 | ||||
|     /*!
 | ||||
|     @brief copy constructor | ||||
|  | @ -1865,6 +2111,12 @@ class basic_json | |||
|                 break; | ||||
|             } | ||||
| 
 | ||||
|             case value_t::binary: | ||||
|             { | ||||
|                 m_value = *other.m_value.binary; | ||||
|                 break; | ||||
|             } | ||||
| 
 | ||||
|             default: | ||||
|                 break; | ||||
|         } | ||||
|  | @ -2005,6 +2257,11 @@ class basic_json | |||
|     possible values: `strict` (throws and exception in case a decoding error | ||||
|     occurs; default), `replace` (replace invalid UTF-8 sequences with U+FFFD), | ||||
|     and `ignore` (ignore invalid UTF-8 sequences during serialization). | ||||
|     @param[in] serialize_binary Whether or not to allow serialization of binary | ||||
|     types to JSON.  Because binary types are non-standard, this will produce | ||||
|     non-conformant JSON, and is disabled by default.  This flag is primarily | ||||
|     useful for debugging.  Will output the binary value as a list of 8-bit | ||||
|     numbers prefixed by "b" (e.g. "bindata" = b[3, 0, 42, 255]). | ||||
| 
 | ||||
|     @return string containing the serialization of the JSON value | ||||
| 
 | ||||
|  | @ -2029,18 +2286,19 @@ class basic_json | |||
|     string_t dump(const int indent = -1, | ||||
|                   const char indent_char = ' ', | ||||
|                   const bool ensure_ascii = false, | ||||
|                   const error_handler_t error_handler = error_handler_t::strict) const | ||||
|                   const error_handler_t error_handler = error_handler_t::strict, | ||||
|                   const bool serialize_binary = false) const | ||||
|     { | ||||
|         string_t result; | ||||
|         serializer s(detail::output_adapter<char, string_t>(result), indent_char, error_handler); | ||||
| 
 | ||||
|         if (indent >= 0) | ||||
|         { | ||||
|             s.dump(*this, true, ensure_ascii, static_cast<unsigned int>(indent)); | ||||
|             s.dump(*this, true, ensure_ascii, static_cast<unsigned int>(indent), 0, serialize_binary); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             s.dump(*this, false, ensure_ascii, 0); | ||||
|             s.dump(*this, false, ensure_ascii, 0, 0, serialize_binary); | ||||
|         } | ||||
| 
 | ||||
|         return result; | ||||
|  | @ -2063,6 +2321,7 @@ class basic_json | |||
|             number (floating-point)   | value_t::number_float | ||||
|             object                    | value_t::object | ||||
|             array                     | value_t::array | ||||
|             binary                    | value_t::binary | ||||
|             discarded                 | value_t::discarded | ||||
| 
 | ||||
|     @complexity Constant. | ||||
|  | @ -2105,12 +2364,13 @@ class basic_json | |||
|     @sa @ref is_string() -- returns whether JSON value is a string | ||||
|     @sa @ref is_boolean() -- returns whether JSON value is a boolean | ||||
|     @sa @ref is_number() -- returns whether JSON value is a number | ||||
|     @sa @ref is_binary() -- returns whether JSON value is a binary array | ||||
| 
 | ||||
|     @since version 1.0.0 | ||||
|     */ | ||||
|     constexpr bool is_primitive() const noexcept | ||||
|     { | ||||
|         return is_null() or is_string() or is_boolean() or is_number(); | ||||
|         return is_null() or is_string() or is_boolean() or is_number() or is_binary(); | ||||
|     } | ||||
| 
 | ||||
|     /*!
 | ||||
|  | @ -2365,6 +2625,28 @@ class basic_json | |||
|         return m_type == value_t::string; | ||||
|     } | ||||
| 
 | ||||
|     /*!
 | ||||
|     @brief return whether value is a binary array | ||||
| 
 | ||||
|     This function returns true if and only if the JSON value is a binary array. | ||||
| 
 | ||||
|     @return `true` if type is binary array, `false` otherwise. | ||||
| 
 | ||||
|     @complexity Constant. | ||||
| 
 | ||||
|     @exceptionsafety No-throw guarantee: this member function never throws | ||||
|     exceptions. | ||||
| 
 | ||||
|     @liveexample{The following code exemplifies `is_binary()` for all JSON | ||||
|     types.,is_binary} | ||||
| 
 | ||||
|     @since version 3.8.0 | ||||
|     */ | ||||
|     constexpr bool is_binary() const noexcept | ||||
|     { | ||||
|         return m_type == value_t::binary; | ||||
|     } | ||||
| 
 | ||||
|     /*!
 | ||||
|     @brief return whether value is discarded | ||||
| 
 | ||||
|  | @ -2520,6 +2802,30 @@ class basic_json | |||
|         return is_number_float() ? &m_value.number_float : nullptr; | ||||
|     } | ||||
| 
 | ||||
|     /// get a pointer to the value (binary)
 | ||||
|     binary_t* get_impl_ptr(binary_t* /*unused*/) noexcept | ||||
|     { | ||||
|         return is_binary() ? reinterpret_cast<binary_t*>(m_value.binary) : nullptr; | ||||
|     } | ||||
| 
 | ||||
|     /// get a pointer to the value (binary)
 | ||||
|     constexpr const binary_t* get_impl_ptr(const binary_t* /*unused*/) const noexcept | ||||
|     { | ||||
|         return is_binary() ? m_value.binary : nullptr; | ||||
|     } | ||||
| 
 | ||||
|     /// get a pointer to the value (binary)
 | ||||
|     internal_binary_t* get_impl_ptr(internal_binary_t* /*unused*/) noexcept | ||||
|     { | ||||
|         return is_binary() ? m_value.binary : nullptr; | ||||
|     } | ||||
| 
 | ||||
|     /// get a pointer to the value (binary)
 | ||||
|     constexpr const internal_binary_t* get_impl_ptr(const internal_binary_t* /*unused*/) const noexcept | ||||
|     { | ||||
|         return is_binary() ? m_value.binary : nullptr; | ||||
|     } | ||||
| 
 | ||||
|     /*!
 | ||||
|     @brief helper function to implement get_ref() | ||||
| 
 | ||||
|  | @ -2933,12 +3239,9 @@ class basic_json | |||
|                    not std::is_same<ValueType, detail::json_ref<basic_json>>::value and | ||||
|                    not std::is_same<ValueType, typename string_t::value_type>::value and | ||||
|                    not detail::is_basic_json<ValueType>::value | ||||
| 
 | ||||
| #ifndef _MSC_VER  // fix for issue #167 operator<< ambiguity under VS2015
 | ||||
|                    and not std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>::value | ||||
| #if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) and _MSC_VER <= 1914)) | ||||
|                    and not std::is_same<ValueType, typename std::string_view>::value | ||||
| #endif | ||||
| #endif | ||||
|                    and detail::is_detected<detail::get_template_function, const basic_json_t&, ValueType>::value | ||||
|                    , int >::type = 0 > | ||||
|  | @ -3570,6 +3873,120 @@ class basic_json | |||
|         return value(ptr, string_t(default_value)); | ||||
|     } | ||||
| 
 | ||||
|     /*!
 | ||||
|     @brief return the binary subtype | ||||
| 
 | ||||
|     Returns the numerical subtype of the JSON value, if the JSON value is of | ||||
|     type "binary", and it has a subtype.  If it does not have a subtype (or the | ||||
|     object is not of type binary) this function will return size_t(-1) as a | ||||
|     sentinel value. | ||||
| 
 | ||||
|     @return the numerical subtype of the binary JSON value | ||||
| 
 | ||||
|     @complexity Constant. | ||||
| 
 | ||||
|     @exceptionsafety No-throw guarantee: this member function never throws | ||||
|     exceptions. | ||||
| 
 | ||||
|     @sa @ref set_subtype() -- sets the binary subtype | ||||
|     @sa @ref clear_subtype() -- clears the binary subtype | ||||
|     @sa @ref has_subtype() -- returns whether or not the binary value has a | ||||
|     subtype | ||||
| 
 | ||||
|     @since version 3.8.0 | ||||
|     */ | ||||
|     std::size_t get_subtype() const noexcept | ||||
|     { | ||||
|         if (is_binary() and m_value.binary->has_subtype) | ||||
|         { | ||||
|             return m_value.binary->subtype; | ||||
|         } | ||||
| 
 | ||||
|         return std::size_t(-1); | ||||
|     } | ||||
| 
 | ||||
|     /*!
 | ||||
|     @brief sets the binary subtype | ||||
| 
 | ||||
|     Sets the binary subtype of the JSON value, also flags a binary JSON value as | ||||
|     having a subtype, which has implications for serialization to msgpack (will | ||||
|     prefer ext file formats over bin).  If the JSON value is not a binary value, | ||||
|     this function does nothing. | ||||
| 
 | ||||
|     @complexity Constant. | ||||
| 
 | ||||
|     @exceptionsafety No-throw guarantee: this member function never throws | ||||
|     exceptions. | ||||
| 
 | ||||
|     @sa @ref get_subtype() -- return the binary subtype | ||||
|     @sa @ref clear_subtype() -- clears the binary subtype | ||||
|     @sa @ref has_subtype() -- returns whether or not the binary value has a | ||||
|     subtype | ||||
| 
 | ||||
|     @since version 3.8.0 | ||||
|     */ | ||||
| 
 | ||||
|     void set_subtype(std::uint8_t subtype) noexcept | ||||
|     { | ||||
|         if (is_binary()) | ||||
|         { | ||||
|             m_value.binary->has_subtype = true; | ||||
|             m_value.binary->subtype = subtype; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /*!
 | ||||
|     @brief clears the binary subtype | ||||
| 
 | ||||
|     Clears the binary subtype of the JSON value, also flags a binary JSON value | ||||
|     as not having a subtype, which has implications for serialization to msgpack | ||||
|     (will prefer bin file formats over ext).  If the JSON value is not a binary | ||||
|     value, this function does nothing. | ||||
| 
 | ||||
|     @complexity Constant. | ||||
| 
 | ||||
|     @exceptionsafety No-throw guarantee: this member function never throws | ||||
|     exceptions. | ||||
| 
 | ||||
|     @sa @ref get_subtype() -- return the binary subtype | ||||
|     @sa @ref set_subtype() -- sets the binary subtype | ||||
|     @sa @ref has_subtype() -- returns whether or not the binary value has a | ||||
|     subtype | ||||
| 
 | ||||
|     @since version 3.8.0 | ||||
|     */ | ||||
|     void clear_subtype() noexcept | ||||
|     { | ||||
|         if (is_binary()) | ||||
|         { | ||||
|             m_value.binary->has_subtype = false; | ||||
|             m_value.binary->subtype = 0; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /*!
 | ||||
|     @brief return whether or not the binary subtype has a value | ||||
| 
 | ||||
|     Returns whether or not the binary subtype has a value. | ||||
| 
 | ||||
|     @return whether or not the binary subtype has a value. | ||||
| 
 | ||||
|     @complexity Constant. | ||||
| 
 | ||||
|     @exceptionsafety No-throw guarantee: this member function never throws | ||||
|     exceptions. | ||||
| 
 | ||||
|     @sa @ref get_subtype() -- return the binary subtype | ||||
|     @sa @ref set_subtype() -- sets the binary subtype | ||||
|     @sa @ref clear_subtype() -- clears the binary subtype | ||||
| 
 | ||||
|     @since version 3.8.0 | ||||
|     */ | ||||
|     bool has_subtype() const noexcept | ||||
|     { | ||||
|         return is_binary() and m_value.binary->has_subtype; | ||||
|     } | ||||
| 
 | ||||
|     /*!
 | ||||
|     @brief access the first element | ||||
| 
 | ||||
|  | @ -3577,8 +3994,8 @@ class basic_json | |||
|     container `c`, the expression `c.front()` is equivalent to `*c.begin()`. | ||||
| 
 | ||||
|     @return In case of a structured type (array or object), a reference to the | ||||
|     first element is returned. In case of number, string, or boolean values, a | ||||
|     reference to the value is returned. | ||||
|     first element is returned. In case of number, string, boolean, or binary | ||||
|     values, a reference to the value is returned. | ||||
| 
 | ||||
|     @complexity Constant. | ||||
| 
 | ||||
|  | @ -3620,8 +4037,8 @@ class basic_json | |||
|     @endcode | ||||
| 
 | ||||
|     @return In case of a structured type (array or object), a reference to the | ||||
|     last element is returned. In case of number, string, or boolean values, a | ||||
|     reference to the value is returned. | ||||
|     last element is returned. In case of number, string, boolean, or binary | ||||
|     values, a reference to the value is returned. | ||||
| 
 | ||||
|     @complexity Constant. | ||||
| 
 | ||||
|  | @ -3687,7 +4104,7 @@ class basic_json | |||
|     @complexity The complexity depends on the type: | ||||
|     - objects: amortized constant | ||||
|     - arrays: linear in distance between @a pos and the end of the container | ||||
|     - strings: linear in the length of the string | ||||
|     - strings and binary: linear in the length of the member | ||||
|     - other types: constant | ||||
| 
 | ||||
|     @liveexample{The example shows the result of `erase()` for different JSON | ||||
|  | @ -3723,6 +4140,7 @@ class basic_json | |||
|             case value_t::number_integer: | ||||
|             case value_t::number_unsigned: | ||||
|             case value_t::string: | ||||
|             case value_t::binary: | ||||
|             { | ||||
|                 if (JSON_HEDLEY_UNLIKELY(not pos.m_it.primitive_iterator.is_begin())) | ||||
|                 { | ||||
|  | @ -3736,6 +4154,13 @@ class basic_json | |||
|                     std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.string, 1); | ||||
|                     m_value.string = nullptr; | ||||
|                 } | ||||
|                 else if (is_binary()) | ||||
|                 { | ||||
|                     AllocatorType<internal_binary_t> alloc; | ||||
|                     std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.binary); | ||||
|                     std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.binary, 1); | ||||
|                     m_value.binary = nullptr; | ||||
|                 } | ||||
| 
 | ||||
|                 m_type = value_t::null; | ||||
|                 assert_invariant(); | ||||
|  | @ -3793,7 +4218,7 @@ class basic_json | |||
|     - objects: `log(size()) + std::distance(first, last)` | ||||
|     - arrays: linear in the distance between @a first and @a last, plus linear | ||||
|       in the distance between @a last and end of the container | ||||
|     - strings: linear in the length of the string | ||||
|     - strings and binary: linear in the length of the member | ||||
|     - other types: constant | ||||
| 
 | ||||
|     @liveexample{The example shows the result of `erase()` for different JSON | ||||
|  | @ -3828,6 +4253,7 @@ class basic_json | |||
|             case value_t::number_integer: | ||||
|             case value_t::number_unsigned: | ||||
|             case value_t::string: | ||||
|             case value_t::binary: | ||||
|             { | ||||
|                 if (JSON_HEDLEY_LIKELY(not first.m_it.primitive_iterator.is_begin() | ||||
|                                        or not last.m_it.primitive_iterator.is_end())) | ||||
|  | @ -3842,6 +4268,13 @@ class basic_json | |||
|                     std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.string, 1); | ||||
|                     m_value.string = nullptr; | ||||
|                 } | ||||
|                 else if (is_binary()) | ||||
|                 { | ||||
|                     AllocatorType<internal_binary_t> alloc; | ||||
|                     std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.binary); | ||||
|                     std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.binary, 1); | ||||
|                     m_value.binary = nullptr; | ||||
|                 } | ||||
| 
 | ||||
|                 m_type = value_t::null; | ||||
|                 assert_invariant(); | ||||
|  | @ -4561,6 +4994,7 @@ class basic_json | |||
|             boolean     | `false` | ||||
|             string      | `false` | ||||
|             number      | `false` | ||||
|             binary      | `false` | ||||
|             object      | result of function `object_t::empty()` | ||||
|             array       | result of function `array_t::empty()` | ||||
| 
 | ||||
|  | @ -4632,6 +5066,7 @@ class basic_json | |||
|             boolean     | `1` | ||||
|             string      | `1` | ||||
|             number      | `1` | ||||
|             binary      | `1` | ||||
|             object      | result of function object_t::size() | ||||
|             array       | result of function array_t::size() | ||||
| 
 | ||||
|  | @ -4706,6 +5141,7 @@ class basic_json | |||
|             boolean     | `1` (same as `size()`) | ||||
|             string      | `1` (same as `size()`) | ||||
|             number      | `1` (same as `size()`) | ||||
|             binary      | `1` (same as `size()`) | ||||
|             object      | result of function `object_t::max_size()` | ||||
|             array       | result of function `array_t::max_size()` | ||||
| 
 | ||||
|  | @ -4778,6 +5214,7 @@ class basic_json | |||
|     boolean     | `false` | ||||
|     string      | `""` | ||||
|     number      | `0` | ||||
|     binary      | An empty byte vector | ||||
|     object      | `{}` | ||||
|     array       | `[]` | ||||
| 
 | ||||
|  | @ -4835,6 +5272,12 @@ class basic_json | |||
|                 break; | ||||
|             } | ||||
| 
 | ||||
|             case value_t::binary: | ||||
|             { | ||||
|                 m_value.binary->clear(); | ||||
|                 break; | ||||
|             } | ||||
| 
 | ||||
|             case value_t::array: | ||||
|             { | ||||
|                 m_value.array->clear(); | ||||
|  | @ -4890,9 +5333,7 @@ class basic_json | |||
| 
 | ||||
|         // add element to array (move semantics)
 | ||||
|         m_value.array->push_back(std::move(val)); | ||||
|         // invalidate object: mark it null so we do not call the destructor
 | ||||
|         // cppcheck-suppress accessMoved
 | ||||
|         val.m_type = value_t::null; | ||||
|         // if val is moved from, basic_json move constructor marks it null so we do not call the destructor
 | ||||
|     } | ||||
| 
 | ||||
|     /*!
 | ||||
|  | @ -5631,6 +6072,39 @@ class basic_json | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /*!
 | ||||
|     @brief exchanges the values | ||||
| 
 | ||||
|     Exchanges the contents of a JSON string with those of @a other. Does not | ||||
|     invoke any move, copy, or swap operations on individual elements. All | ||||
|     iterators and references remain valid. The past-the-end iterator is | ||||
|     invalidated. | ||||
| 
 | ||||
|     @param[in,out] other binary to exchange the contents with | ||||
| 
 | ||||
|     @throw type_error.310 when JSON value is not a string; example: `"cannot | ||||
|     use swap() with boolean"` | ||||
| 
 | ||||
|     @complexity Constant. | ||||
| 
 | ||||
|     @liveexample{The example below shows how strings can be swapped with | ||||
|     `swap()`.,swap__binary_t} | ||||
| 
 | ||||
|     @since version 3.8.0 | ||||
|     */ | ||||
|     void swap(binary_t& other) | ||||
|     { | ||||
|         // swap only works for strings
 | ||||
|         if (JSON_HEDLEY_LIKELY(is_binary())) | ||||
|         { | ||||
|             std::swap(*(m_value.binary), other); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name()))); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /// @}
 | ||||
| 
 | ||||
|   public: | ||||
|  | @ -5649,13 +6123,13 @@ class basic_json | |||
|       their stored values are the same according to their respective | ||||
|       `operator==`. | ||||
|     - Integer and floating-point numbers are automatically converted before | ||||
|       comparison. Note than two NaN values are always treated as unequal. | ||||
|       comparison. Note that two NaN values are always treated as unequal. | ||||
|     - Two JSON null values are equal. | ||||
| 
 | ||||
|     @note Floating-point inside JSON values numbers are compared with | ||||
|     `json::number_float_t::operator==` which is `double::operator==` by | ||||
|     default. To compare floating-point while respecting an epsilon, an alternative | ||||
|     [comparison function](https://github.com/mariokonrad/marnav/blob/master/src/marnav/math/floatingpoint.hpp#L34-#L39)
 | ||||
|     [comparison function](https://github.com/mariokonrad/marnav/blob/master/include/marnav/math/floatingpoint.hpp#L34-#L39)
 | ||||
|     could be used, for instance | ||||
|     @code {.cpp} | ||||
|     template<typename T, typename = typename std::enable_if<std::is_floating_point<T>::value, T>::type> | ||||
|  | @ -5664,6 +6138,22 @@ class basic_json | |||
|         return std::abs(a - b) <= epsilon; | ||||
|     } | ||||
|     @endcode | ||||
|     Or you can self-defined operator equal function like this: | ||||
|     @code {.cpp} | ||||
|     bool my_equal(const_reference lhs, const_reference rhs) { | ||||
|     const auto lhs_type lhs.type(); | ||||
|     const auto rhs_type rhs.type(); | ||||
|     if (lhs_type == rhs_type) { | ||||
|         switch(lhs_type) | ||||
|             // self_defined case
 | ||||
|             case value_t::number_float: | ||||
|                 return std::abs(lhs - rhs) <= std::numeric_limits<float>::epsilon(); | ||||
|             // other cases remain the same with the original
 | ||||
|             ... | ||||
|     } | ||||
|     ... | ||||
|     } | ||||
|     @endcode | ||||
| 
 | ||||
|     @note NaN values never compare equal to themselves or to other NaN values. | ||||
| 
 | ||||
|  | @ -5713,6 +6203,9 @@ class basic_json | |||
|                 case value_t::number_float: | ||||
|                     return lhs.m_value.number_float == rhs.m_value.number_float; | ||||
| 
 | ||||
|                 case value_t::binary: | ||||
|                     return *lhs.m_value.binary == *rhs.m_value.binary; | ||||
| 
 | ||||
|                 default: | ||||
|                     return false; | ||||
|             } | ||||
|  | @ -5873,6 +6366,9 @@ class basic_json | |||
|                 case value_t::number_float: | ||||
|                     return (lhs.m_value.number_float) < (rhs.m_value.number_float); | ||||
| 
 | ||||
|                 case value_t::binary: | ||||
|                     return (*lhs.m_value.binary) < (*rhs.m_value.binary); | ||||
| 
 | ||||
|                 default: | ||||
|                     return false; | ||||
|             } | ||||
|  | @ -6317,7 +6813,6 @@ class basic_json | |||
|                           const bool strict = true) | ||||
|     { | ||||
|         assert(sax); | ||||
| 
 | ||||
|         auto ia = i.get(); | ||||
|         return format == input_format_t::json | ||||
|                ? parser(std::move(ia)).sax_parse(sax, strict) | ||||
|  | @ -6472,6 +6967,7 @@ class basic_json | |||
|             number      | `"number"` (for all number types) | ||||
|             object      | `"object"` | ||||
|             array       | `"array"` | ||||
|             binary      | `"binary"` | ||||
|             discarded   | `"discarded"` | ||||
| 
 | ||||
|     @exceptionsafety No-throw guarantee: this function never throws exceptions. | ||||
|  | @ -6503,6 +6999,8 @@ class basic_json | |||
|                     return "string"; | ||||
|                 case value_t::boolean: | ||||
|                     return "boolean"; | ||||
|                 case value_t::binary: | ||||
|                     return "binary"; | ||||
|                 case value_t::discarded: | ||||
|                     return "discarded"; | ||||
|                 default: | ||||
|  | @ -6578,6 +7076,11 @@ class basic_json | |||
|     object          | *size*: 256..65535                         | map (2 bytes follow)               | 0xB9 | ||||
|     object          | *size*: 65536..4294967295                  | map (4 bytes follow)               | 0xBA | ||||
|     object          | *size*: 4294967296..18446744073709551615   | map (8 bytes follow)               | 0xBB | ||||
|     binary          | *size*: 0..23                              | byte string                        | 0x40..0x57 | ||||
|     binary          | *size*: 23..255                            | byte string (1 byte follow)        | 0x58 | ||||
|     binary          | *size*: 256..65535                         | byte string (2 bytes follow)       | 0x59 | ||||
|     binary          | *size*: 65536..4294967295                  | byte string (4 bytes follow)       | 0x5A | ||||
|     binary          | *size*: 4294967296..18446744073709551615   | byte string (8 bytes follow)       | 0x5B | ||||
| 
 | ||||
|     @note The mapping is **complete** in the sense that any JSON value type | ||||
|           can be converted to a CBOR value. | ||||
|  | @ -6587,10 +7090,10 @@ class basic_json | |||
|           function which serializes NaN or Infinity to `null`. | ||||
| 
 | ||||
|     @note The following CBOR types are not used in the conversion: | ||||
|           - byte strings (0x40..0x5F) | ||||
|           - UTF-8 strings terminated by "break" (0x7F) | ||||
|           - arrays terminated by "break" (0x9F) | ||||
|           - maps terminated by "break" (0xBF) | ||||
|           - byte strings terminated by "break" (0x5F) | ||||
|           - date/time (0xC0..0xC1) | ||||
|           - bignum (0xC2..0xC3) | ||||
|           - decimal fraction (0xC4) | ||||
|  | @ -6677,20 +7180,21 @@ class basic_json | |||
|     object          | *size*: 0..15                     | fix map          | 0x80..0x8F | ||||
|     object          | *size*: 16..65535                 | map 16           | 0xDE | ||||
|     object          | *size*: 65536..4294967295         | map 32           | 0xDF | ||||
|     binary          | *size*: 0..255                    | bin 8            | 0xC4 | ||||
|     binary          | *size*: 256..65535                | bin 16           | 0xC5 | ||||
|     binary          | *size*: 65536..4294967295         | bin 32           | 0xC6 | ||||
| 
 | ||||
|     @note The mapping is **complete** in the sense that any JSON value type | ||||
|           can be converted to a MessagePack value. | ||||
| 
 | ||||
|     @note The following values can **not** be converted to a MessagePack value: | ||||
|           - strings with more than 4294967295 bytes | ||||
|           - byte strings with more than 4294967295 bytes | ||||
|           - arrays with more than 4294967295 elements | ||||
|           - objects with more than 4294967295 elements | ||||
| 
 | ||||
|     @note The following MessagePack types are not used in the conversion: | ||||
|           - bin 8 - bin 32 (0xC4..0xC6) | ||||
|           - ext 8 - ext 32 (0xC7..0xC9) | ||||
|           - float 32 (0xCA) | ||||
|           - fixext 1 - fixext 16 (0xD4..0xD8) | ||||
| 
 | ||||
|     @note Any MessagePack output created @ref to_msgpack can be successfully | ||||
|           parsed by @ref from_msgpack. | ||||
|  | @ -6793,6 +7297,12 @@ class basic_json | |||
|           the benefit of this parameter is that the receiving side is | ||||
|           immediately informed on the number of elements of the container. | ||||
| 
 | ||||
|     @note If the JSON data contains the binary type, the value stored is a list | ||||
|           of integers, as suggested by the UBJSON documentation.  In particular, | ||||
|           this means that serialization and the deserialization of a JSON | ||||
|           containing binary values into UBJSON and back will result in a | ||||
|           different JSON object. | ||||
| 
 | ||||
|     @param[in] j  JSON value to serialize | ||||
|     @param[in] use_size  whether to add size annotations to container types | ||||
|     @param[in] use_type  whether to add type annotations to container types | ||||
|  | @ -6857,6 +7367,7 @@ class basic_json | |||
|     string          | *any value*                       | string      | 0x02 | ||||
|     array           | *any value*                       | document    | 0x04 | ||||
|     object          | *any value*                       | document    | 0x03 | ||||
|     binary          | *any value*                       | binary      | 0x05 | ||||
| 
 | ||||
|     @warning The mapping is **incomplete**, since only JSON-objects (and things | ||||
|     contained therein) can be serialized to BSON. | ||||
|  | @ -6938,7 +7449,11 @@ class basic_json | |||
|     Negative integer       | number_integer  | 0x39 | ||||
|     Negative integer       | number_integer  | 0x3A | ||||
|     Negative integer       | number_integer  | 0x3B | ||||
|     Negative integer       | number_integer  | 0x40..0x57 | ||||
|     Byte string            | binary          | 0x40..0x57 | ||||
|     Byte string            | binary          | 0x58 | ||||
|     Byte string            | binary          | 0x59 | ||||
|     Byte string            | binary          | 0x5A | ||||
|     Byte string            | binary          | 0x5B | ||||
|     UTF-8 string           | string          | 0x60..0x77 | ||||
|     UTF-8 string           | string          | 0x78 | ||||
|     UTF-8 string           | string          | 0x79 | ||||
|  | @ -6967,7 +7482,6 @@ class basic_json | |||
|     @warning The mapping is **incomplete** in the sense that not all CBOR | ||||
|              types can be converted to a JSON value. The following CBOR types | ||||
|              are not supported and will yield parse errors (parse_error.112): | ||||
|              - byte strings (0x40..0x5F) | ||||
|              - date/time (0xC0..0xC1) | ||||
|              - bignum (0xC2..0xC3) | ||||
|              - decimal fraction (0xC4) | ||||
|  | @ -7091,15 +7605,19 @@ class basic_json | |||
|     array 32         | array           | 0xDD | ||||
|     map 16           | object          | 0xDE | ||||
|     map 32           | object          | 0xDF | ||||
|     bin 8            | binary          | 0xC4 | ||||
|     bin 16           | binary          | 0xC5 | ||||
|     bin 32           | binary          | 0xC6 | ||||
|     ext 8            | binary          | 0xC7 | ||||
|     ext 16           | binary          | 0xC8 | ||||
|     ext 32           | binary          | 0xC9 | ||||
|     fixext 1         | binary          | 0xD4 | ||||
|     fixext 2         | binary          | 0xD5 | ||||
|     fixext 4         | binary          | 0xD6 | ||||
|     fixext 8         | binary          | 0xD7 | ||||
|     fixext 16        | binary          | 0xD8 | ||||
|     negative fixint  | number_integer  | 0xE0-0xFF | ||||
| 
 | ||||
|     @warning The mapping is **incomplete** in the sense that not all | ||||
|              MessagePack types can be converted to a JSON value. The following | ||||
|              MessagePack types are not supported and will yield parse errors: | ||||
|               - bin 8 - bin 32 (0xC4..0xC6) | ||||
|               - ext 8 - ext 32 (0xC7..0xC9) | ||||
|               - fixext 1 - fixext 16 (0xD4..0xD8) | ||||
| 
 | ||||
|     @note Any MessagePack output created @ref to_msgpack can be successfully | ||||
|           parsed by @ref from_msgpack. | ||||
| 
 | ||||
|  | @ -8018,7 +8536,7 @@ class basic_json | |||
|                     result.push_back( | ||||
|                     { | ||||
|                         {"op", "add"}, | ||||
|                         {"path", path + "/" + std::to_string(i)}, | ||||
|                         {"path", path + "/-"}, | ||||
|                         {"value", target[i]} | ||||
|                     }); | ||||
|                     ++i; | ||||
|  |  | |||
|  | @ -33,7 +33,8 @@ template<template<typename U, typename V, typename... Args> class ObjectType = | |||
|          class NumberFloatType = double, | ||||
|          template<typename U> class AllocatorType = std::allocator, | ||||
|          template<typename T, typename SFINAE = void> class JSONSerializer = | ||||
|          adl_serializer> | ||||
|          adl_serializer, | ||||
|          class BinaryType = std::vector<std::uint8_t>> | ||||
| class basic_json; | ||||
| 
 | ||||
| /*!
 | ||||
|  |  | |||
							
								
								
									
										676
									
								
								include/nlohmann/thirdparty/hedley/hedley.hpp
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										676
									
								
								include/nlohmann/thirdparty/hedley/hedley.hpp
									
										
									
									
										vendored
									
									
								
							|  | @ -10,11 +10,11 @@ | |||
|  * SPDX-License-Identifier: CC0-1.0 | ||||
|  */ | ||||
| 
 | ||||
| #if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 11) | ||||
| #if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 13) | ||||
| #if defined(JSON_HEDLEY_VERSION) | ||||
|     #undef JSON_HEDLEY_VERSION | ||||
| #endif | ||||
| #define JSON_HEDLEY_VERSION 11 | ||||
| #define JSON_HEDLEY_VERSION 13 | ||||
| 
 | ||||
| #if defined(JSON_HEDLEY_STRINGIFY_EX) | ||||
|     #undef JSON_HEDLEY_STRINGIFY_EX | ||||
|  | @ -36,6 +36,16 @@ | |||
| #endif | ||||
| #define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b) | ||||
| 
 | ||||
| #if defined(JSON_HEDLEY_CONCAT3_EX) | ||||
|     #undef JSON_HEDLEY_CONCAT3_EX | ||||
| #endif | ||||
| #define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c | ||||
| 
 | ||||
| #if defined(JSON_HEDLEY_CONCAT3) | ||||
|     #undef JSON_HEDLEY_CONCAT3 | ||||
| #endif | ||||
| #define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c) | ||||
| 
 | ||||
| #if defined(JSON_HEDLEY_VERSION_ENCODE) | ||||
|     #undef JSON_HEDLEY_VERSION_ENCODE | ||||
| #endif | ||||
|  | @ -211,9 +221,17 @@ | |||
| #if defined(JSON_HEDLEY_TI_VERSION) | ||||
|     #undef JSON_HEDLEY_TI_VERSION | ||||
| #endif | ||||
| #if defined(__TI_COMPILER_VERSION__) | ||||
| #if \ | ||||
|     defined(__TI_COMPILER_VERSION__) && \ | ||||
|     ( \ | ||||
|       defined(__TMS470__) || defined(__TI_ARM__) || \ | ||||
|       defined(__MSP430__) || \ | ||||
|       defined(__TMS320C2000__) \ | ||||
|     ) | ||||
| #if (__TI_COMPILER_VERSION__ >= 16000000) | ||||
|     #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) | ||||
| #endif | ||||
| #endif | ||||
| 
 | ||||
| #if defined(JSON_HEDLEY_TI_VERSION_CHECK) | ||||
|     #undef JSON_HEDLEY_TI_VERSION_CHECK | ||||
|  | @ -224,6 +242,102 @@ | |||
|     #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0) | ||||
| #endif | ||||
| 
 | ||||
| #if defined(JSON_HEDLEY_TI_CL2000_VERSION) | ||||
|     #undef JSON_HEDLEY_TI_CL2000_VERSION | ||||
| #endif | ||||
| #if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__) | ||||
|     #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) | ||||
| #endif | ||||
| 
 | ||||
| #if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK) | ||||
|     #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK | ||||
| #endif | ||||
| #if defined(JSON_HEDLEY_TI_CL2000_VERSION) | ||||
|     #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) | ||||
| #else | ||||
|     #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0) | ||||
| #endif | ||||
| 
 | ||||
| #if defined(JSON_HEDLEY_TI_CL430_VERSION) | ||||
|     #undef JSON_HEDLEY_TI_CL430_VERSION | ||||
| #endif | ||||
| #if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__) | ||||
|     #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) | ||||
| #endif | ||||
| 
 | ||||
| #if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK) | ||||
|     #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK | ||||
| #endif | ||||
| #if defined(JSON_HEDLEY_TI_CL430_VERSION) | ||||
|     #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) | ||||
| #else | ||||
|     #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0) | ||||
| #endif | ||||
| 
 | ||||
| #if defined(JSON_HEDLEY_TI_ARMCL_VERSION) | ||||
|     #undef JSON_HEDLEY_TI_ARMCL_VERSION | ||||
| #endif | ||||
| #if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__)) | ||||
|     #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) | ||||
| #endif | ||||
| 
 | ||||
| #if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK) | ||||
|     #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK | ||||
| #endif | ||||
| #if defined(JSON_HEDLEY_TI_ARMCL_VERSION) | ||||
|     #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) | ||||
| #else | ||||
|     #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0) | ||||
| #endif | ||||
| 
 | ||||
| #if defined(JSON_HEDLEY_TI_CL6X_VERSION) | ||||
|     #undef JSON_HEDLEY_TI_CL6X_VERSION | ||||
| #endif | ||||
| #if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__) | ||||
|     #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) | ||||
| #endif | ||||
| 
 | ||||
| #if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK) | ||||
|     #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK | ||||
| #endif | ||||
| #if defined(JSON_HEDLEY_TI_CL6X_VERSION) | ||||
|     #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) | ||||
| #else | ||||
|     #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0) | ||||
| #endif | ||||
| 
 | ||||
| #if defined(JSON_HEDLEY_TI_CL7X_VERSION) | ||||
|     #undef JSON_HEDLEY_TI_CL7X_VERSION | ||||
| #endif | ||||
| #if defined(__TI_COMPILER_VERSION__) && defined(__C7000__) | ||||
|     #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) | ||||
| #endif | ||||
| 
 | ||||
| #if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK) | ||||
|     #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK | ||||
| #endif | ||||
| #if defined(JSON_HEDLEY_TI_CL7X_VERSION) | ||||
|     #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) | ||||
| #else | ||||
|     #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0) | ||||
| #endif | ||||
| 
 | ||||
| #if defined(JSON_HEDLEY_TI_CLPRU_VERSION) | ||||
|     #undef JSON_HEDLEY_TI_CLPRU_VERSION | ||||
| #endif | ||||
| #if defined(__TI_COMPILER_VERSION__) && defined(__PRU__) | ||||
|     #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) | ||||
| #endif | ||||
| 
 | ||||
| #if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK) | ||||
|     #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK | ||||
| #endif | ||||
| #if defined(JSON_HEDLEY_TI_CLPRU_VERSION) | ||||
|     #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) | ||||
| #else | ||||
|     #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0) | ||||
| #endif | ||||
| 
 | ||||
| #if defined(JSON_HEDLEY_CRAY_VERSION) | ||||
|     #undef JSON_HEDLEY_CRAY_VERSION | ||||
| #endif | ||||
|  | @ -338,6 +452,12 @@ | |||
|     !defined(JSON_HEDLEY_PGI_VERSION) && \ | ||||
|     !defined(JSON_HEDLEY_ARM_VERSION) && \ | ||||
|     !defined(JSON_HEDLEY_TI_VERSION) && \ | ||||
|     !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \ | ||||
|     !defined(JSON_HEDLEY_TI_CL430_VERSION) && \ | ||||
|     !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \ | ||||
|     !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \ | ||||
|     !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \ | ||||
|     !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \ | ||||
|     !defined(__COMPCERT__) | ||||
|     #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION | ||||
| #endif | ||||
|  | @ -397,6 +517,7 @@ | |||
|     #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0) | ||||
| #elif \ | ||||
|     !defined(JSON_HEDLEY_PGI_VERSION) && \ | ||||
|     !defined(JSON_HEDLEY_IAR_VERSION) && \ | ||||
|     (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \ | ||||
|     (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0)) | ||||
|     #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute) | ||||
|  | @ -562,14 +683,85 @@ | |||
| #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_) | ||||
|     #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ | ||||
| #endif | ||||
| #if defined(__cplusplus) && JSON_HEDLEY_HAS_WARNING("-Wc++98-compat") | ||||
| #  define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ | ||||
| #if defined(__cplusplus) | ||||
| #  if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat") | ||||
| #    if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions") | ||||
| #      define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ | ||||
|     JSON_HEDLEY_DIAGNOSTIC_PUSH \ | ||||
|     _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ | ||||
|     _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ | ||||
|     xpr \ | ||||
|     JSON_HEDLEY_DIAGNOSTIC_POP | ||||
| #    else | ||||
| #      define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ | ||||
|     JSON_HEDLEY_DIAGNOSTIC_PUSH \ | ||||
|     _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ | ||||
|     xpr \ | ||||
|     JSON_HEDLEY_DIAGNOSTIC_POP | ||||
| #    endif | ||||
| #  endif | ||||
| #endif | ||||
| #if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_) | ||||
|     #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x | ||||
| #endif | ||||
| 
 | ||||
| #if defined(JSON_HEDLEY_CONST_CAST) | ||||
|     #undef JSON_HEDLEY_CONST_CAST | ||||
| #endif | ||||
| #if defined(__cplusplus) | ||||
| #  define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr)) | ||||
| #elif \ | ||||
|   JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \ | ||||
|   JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \ | ||||
|   JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) | ||||
| #  define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \ | ||||
|         JSON_HEDLEY_DIAGNOSTIC_PUSH \ | ||||
|         JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \ | ||||
|         ((T) (expr)); \ | ||||
|         JSON_HEDLEY_DIAGNOSTIC_POP \ | ||||
|     })) | ||||
| #else | ||||
| #  define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x | ||||
| #  define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr)) | ||||
| #endif | ||||
| 
 | ||||
| #if defined(JSON_HEDLEY_REINTERPRET_CAST) | ||||
|     #undef JSON_HEDLEY_REINTERPRET_CAST | ||||
| #endif | ||||
| #if defined(__cplusplus) | ||||
|     #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr)) | ||||
| #else | ||||
|     #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr)) | ||||
| #endif | ||||
| 
 | ||||
| #if defined(JSON_HEDLEY_STATIC_CAST) | ||||
|     #undef JSON_HEDLEY_STATIC_CAST | ||||
| #endif | ||||
| #if defined(__cplusplus) | ||||
|     #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr)) | ||||
| #else | ||||
|     #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr)) | ||||
| #endif | ||||
| 
 | ||||
| #if defined(JSON_HEDLEY_CPP_CAST) | ||||
|     #undef JSON_HEDLEY_CPP_CAST | ||||
| #endif | ||||
| #if defined(__cplusplus) | ||||
| #  if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast") | ||||
| #    define JSON_HEDLEY_CPP_CAST(T, expr) \ | ||||
|     JSON_HEDLEY_DIAGNOSTIC_PUSH \ | ||||
|     _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \ | ||||
|     ((T) (expr)) \ | ||||
|     JSON_HEDLEY_DIAGNOSTIC_POP | ||||
| #  elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0) | ||||
| #    define JSON_HEDLEY_CPP_CAST(T, expr) \ | ||||
|     JSON_HEDLEY_DIAGNOSTIC_PUSH \ | ||||
|     _Pragma("diag_suppress=Pe137") \ | ||||
|     JSON_HEDLEY_DIAGNOSTIC_POP \ | ||||
| #  else | ||||
| #    define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr)) | ||||
| #  endif | ||||
| #else | ||||
| #  define JSON_HEDLEY_CPP_CAST(T, expr) (expr) | ||||
| #endif | ||||
| 
 | ||||
| #if \ | ||||
|  | @ -580,7 +772,13 @@ | |||
|     JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ | ||||
|     JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ | ||||
|     JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ | ||||
|     JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) || \ | ||||
|     JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ | ||||
|     JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \ | ||||
|     JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \ | ||||
|     JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \ | ||||
|     JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \ | ||||
|     JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ | ||||
|     JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ | ||||
|     JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \ | ||||
|     JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \ | ||||
|     JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \ | ||||
|  | @ -613,7 +811,13 @@ | |||
| #elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) | ||||
|     #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push") | ||||
|     #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop") | ||||
| #elif JSON_HEDLEY_TI_VERSION_CHECK(8,1,0) | ||||
| #elif \ | ||||
|     JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ | ||||
|     JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ | ||||
|     JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \ | ||||
|     JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \ | ||||
|     JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ | ||||
|     JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) | ||||
|     #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push") | ||||
|     #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop") | ||||
| #elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) | ||||
|  | @ -637,7 +841,18 @@ | |||
|     #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") | ||||
| #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) | ||||
|     #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996)) | ||||
| #elif JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) | ||||
| #elif \ | ||||
|     JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ | ||||
|     (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|     JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ | ||||
|     (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|     JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ | ||||
|     (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|     JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ | ||||
|     (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|     JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ | ||||
|     JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ | ||||
|     JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) | ||||
|     #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718") | ||||
| #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus) | ||||
|     #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)") | ||||
|  | @ -664,7 +879,13 @@ | |||
|     #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"") | ||||
| #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) | ||||
|     #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068)) | ||||
| #elif JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) | ||||
| #elif \ | ||||
|     JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \ | ||||
|     JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \ | ||||
|     JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ | ||||
|     JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) | ||||
|     #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") | ||||
| #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) | ||||
|     #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") | ||||
| #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) | ||||
|     #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161") | ||||
|  | @ -687,8 +908,13 @@ | |||
|     #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097") | ||||
| #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus) | ||||
|     #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)") | ||||
| #elif JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) | ||||
| #elif \ | ||||
|     JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \ | ||||
|     JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \ | ||||
|     JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) | ||||
|     #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173") | ||||
| #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) | ||||
|     #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097") | ||||
| #else | ||||
|     #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES | ||||
| #endif | ||||
|  | @ -712,7 +938,10 @@ | |||
| #if defined(JSON_HEDLEY_DEPRECATED_FOR) | ||||
|     #undef JSON_HEDLEY_DEPRECATED_FOR | ||||
| #endif | ||||
| #if defined(__cplusplus) && (__cplusplus >= 201402L) | ||||
| #if JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) | ||||
|     #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since)) | ||||
|     #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement)) | ||||
| #elif defined(__cplusplus) && (__cplusplus >= 201402L) | ||||
|     #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]]) | ||||
|     #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]]) | ||||
| #elif \ | ||||
|  | @ -722,20 +951,30 @@ | |||
|     JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ | ||||
|     JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \ | ||||
|     JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ | ||||
|     JSON_HEDLEY_TI_VERSION_CHECK(8,3,0) | ||||
|     JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \ | ||||
|     JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \ | ||||
|     JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \ | ||||
|     JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ | ||||
|     JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) | ||||
|     #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since))) | ||||
|     #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement))) | ||||
| #elif \ | ||||
|     JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \ | ||||
|     JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ | ||||
|     JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ | ||||
|     JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ | ||||
|     (JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) | ||||
|     JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ | ||||
|     (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|     JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ | ||||
|     (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|     JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ | ||||
|     (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|     JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ | ||||
|     (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|     JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ | ||||
|     JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ | ||||
|     JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) | ||||
|     #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__)) | ||||
|     #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__)) | ||||
| #elif JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) | ||||
|     #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since)) | ||||
|     #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement)) | ||||
| #elif \ | ||||
|     JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ | ||||
|     JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) | ||||
|  | @ -764,21 +1003,40 @@ | |||
| #if defined(JSON_HEDLEY_WARN_UNUSED_RESULT) | ||||
|     #undef JSON_HEDLEY_WARN_UNUSED_RESULT | ||||
| #endif | ||||
| #if defined(__cplusplus) && (__cplusplus >= 201703L) | ||||
| #if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG) | ||||
|     #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG | ||||
| #endif | ||||
| #if (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L) | ||||
|     #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) | ||||
|     #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]]) | ||||
| #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) | ||||
|     #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) | ||||
|     #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) | ||||
| #elif \ | ||||
|     JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \ | ||||
|     JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ | ||||
|     JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ | ||||
|     JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ | ||||
|     (JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|     JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ | ||||
|     (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|     JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ | ||||
|     (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|     JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ | ||||
|     (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|     JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ | ||||
|     (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|     JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ | ||||
|     JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ | ||||
|     JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ | ||||
|     (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ | ||||
|     JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) | ||||
|     #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) | ||||
|     #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__)) | ||||
| #elif defined(_Check_return_) /* SAL */ | ||||
|     #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_ | ||||
|     #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_ | ||||
| #else | ||||
|     #define JSON_HEDLEY_WARN_UNUSED_RESULT | ||||
|     #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) | ||||
| #endif | ||||
| 
 | ||||
| #if defined(JSON_HEDLEY_SENTINEL) | ||||
|  | @ -811,14 +1069,23 @@ | |||
|     JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ | ||||
|     JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ | ||||
|     JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ | ||||
|     JSON_HEDLEY_TI_VERSION_CHECK(18,0,0) || \ | ||||
|     (JSON_HEDLEY_TI_VERSION_CHECK(17,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) | ||||
|     JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ | ||||
|     (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|     JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ | ||||
|     (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|     JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ | ||||
|     (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|     JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ | ||||
|     (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|     JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ | ||||
|     JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ | ||||
|     JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) | ||||
|     #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) | ||||
| #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) | ||||
|     #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return") | ||||
| #elif JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) | ||||
|     #define JSON_HEDLEY_NO_RETURN __declspec(noreturn) | ||||
| #elif JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) | ||||
| #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus) | ||||
|     #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;") | ||||
| #elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) | ||||
|     #define JSON_HEDLEY_NO_RETURN __attribute((noreturn)) | ||||
|  | @ -843,31 +1110,6 @@ | |||
| #if defined(JSON_HEDLEY_UNREACHABLE_RETURN) | ||||
|     #undef JSON_HEDLEY_UNREACHABLE_RETURN | ||||
| #endif | ||||
| #if \ | ||||
|     (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \ | ||||
|     JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ | ||||
|     JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ | ||||
|     JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) | ||||
|     #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable() | ||||
| #elif JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) | ||||
|     #define JSON_HEDLEY_UNREACHABLE() __assume(0) | ||||
| #elif JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) | ||||
|     #if defined(__cplusplus) | ||||
|         #define JSON_HEDLEY_UNREACHABLE() std::_nassert(0) | ||||
|     #else | ||||
|         #define JSON_HEDLEY_UNREACHABLE() _nassert(0) | ||||
|     #endif | ||||
|     #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return value | ||||
| #elif defined(EXIT_FAILURE) | ||||
|     #define JSON_HEDLEY_UNREACHABLE() abort() | ||||
| #else | ||||
|     #define JSON_HEDLEY_UNREACHABLE() | ||||
|     #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return value | ||||
| #endif | ||||
| #if !defined(JSON_HEDLEY_UNREACHABLE_RETURN) | ||||
|     #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE() | ||||
| #endif | ||||
| 
 | ||||
| #if defined(JSON_HEDLEY_ASSUME) | ||||
|     #undef JSON_HEDLEY_ASSUME | ||||
| #endif | ||||
|  | @ -877,20 +1119,45 @@ | |||
|     #define JSON_HEDLEY_ASSUME(expr) __assume(expr) | ||||
| #elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume) | ||||
|     #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr) | ||||
| #elif JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) | ||||
| #elif \ | ||||
|     JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ | ||||
|     JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) | ||||
|     #if defined(__cplusplus) | ||||
|         #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr) | ||||
|     #else | ||||
|         #define JSON_HEDLEY_ASSUME(expr) _nassert(expr) | ||||
|     #endif | ||||
| #elif \ | ||||
|     (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && !defined(JSON_HEDLEY_ARM_VERSION)) || \ | ||||
| #endif | ||||
| #if \ | ||||
|     (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \ | ||||
|     JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ | ||||
|     JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \ | ||||
|     JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ | ||||
|     JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) | ||||
|     #define JSON_HEDLEY_ASSUME(expr) ((void) ((expr) ? 1 : (__builtin_unreachable(), 1))) | ||||
|     #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable() | ||||
| #elif defined(JSON_HEDLEY_ASSUME) | ||||
|     #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0) | ||||
| #endif | ||||
| #if !defined(JSON_HEDLEY_ASSUME) | ||||
|     #if defined(JSON_HEDLEY_UNREACHABLE) | ||||
|         #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1))) | ||||
|     #else | ||||
|         #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr) | ||||
|     #endif | ||||
| #endif | ||||
| #if defined(JSON_HEDLEY_UNREACHABLE) | ||||
|     #if  \ | ||||
|         JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ | ||||
|         JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) | ||||
|         #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value)) | ||||
|     #else | ||||
|         #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE() | ||||
|     #endif | ||||
| #else | ||||
|     #define JSON_HEDLEY_ASSUME(expr) ((void) (expr)) | ||||
|     #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value) | ||||
| #endif | ||||
| #if !defined(JSON_HEDLEY_UNREACHABLE) | ||||
|     #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0) | ||||
| #endif | ||||
| 
 | ||||
| JSON_HEDLEY_DIAGNOSTIC_PUSH | ||||
|  | @ -934,8 +1201,17 @@ JSON_HEDLEY_DIAGNOSTIC_POP | |||
|     JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ | ||||
|     JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ | ||||
|     JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ | ||||
|     JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ | ||||
|     (JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) | ||||
|     JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ | ||||
|     (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|     JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ | ||||
|     (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|     JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ | ||||
|     (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|     JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ | ||||
|     (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|     JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ | ||||
|     JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ | ||||
|     JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) | ||||
|     #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check))) | ||||
| #elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0) | ||||
|     #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check)) | ||||
|  | @ -968,19 +1244,16 @@ JSON_HEDLEY_DIAGNOSTIC_POP | |||
|     #undef JSON_HEDLEY_UNPREDICTABLE | ||||
| #endif | ||||
| #if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable) | ||||
|     #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable(!!(expr)) | ||||
|     #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr)) | ||||
| #endif | ||||
| #if \ | ||||
|   JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) || \ | ||||
|   JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) | ||||
| #  define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability(expr, value, probability) | ||||
| #  define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1, probability) | ||||
| #  define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0, probability) | ||||
| #  define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) | ||||
| #  define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) | ||||
| #if !defined(JSON_HEDLEY_BUILTIN_UNPREDICTABLE) | ||||
|     #define JSON_HEDLEY_BUILTIN_UNPREDICTABLE(expr) __builtin_expect_with_probability(!!(expr), 1, 0.5) | ||||
| #endif | ||||
| #  define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability(  (expr), (value), (probability)) | ||||
| #  define JSON_HEDLEY_PREDICT_TRUE(expr, probability)   __builtin_expect_with_probability(!!(expr),    1   , (probability)) | ||||
| #  define JSON_HEDLEY_PREDICT_FALSE(expr, probability)  __builtin_expect_with_probability(!!(expr),    0   , (probability)) | ||||
| #  define JSON_HEDLEY_LIKELY(expr)                      __builtin_expect                 (!!(expr),    1                  ) | ||||
| #  define JSON_HEDLEY_UNLIKELY(expr)                    __builtin_expect                 (!!(expr),    0                  ) | ||||
| #elif \ | ||||
|   JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) || \ | ||||
|   JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ | ||||
|  | @ -988,24 +1261,31 @@ JSON_HEDLEY_DIAGNOSTIC_POP | |||
|   (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ | ||||
|   JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ | ||||
|   JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ | ||||
|   JSON_HEDLEY_TI_VERSION_CHECK(6,1,0) || \ | ||||
|   JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) | ||||
|   JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ | ||||
|   JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \ | ||||
|   JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \ | ||||
|   JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \ | ||||
|   JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ | ||||
|   JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ | ||||
|   JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ | ||||
|   JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \ | ||||
|   JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) | ||||
| #  define JSON_HEDLEY_PREDICT(expr, expected, probability) \ | ||||
|     (((probability) >= 0.9) ? __builtin_expect(!!(expr), (expected)) : (((void) (expected)), !!(expr))) | ||||
|     (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))) | ||||
| #  define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \ | ||||
|     (__extension__ ({ \ | ||||
|         JSON_HEDLEY_CONSTEXPR double hedley_probability_ = (probability); \ | ||||
|         double hedley_probability_ = (probability); \ | ||||
|         ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \ | ||||
|     })) | ||||
| #  define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \ | ||||
|     (__extension__ ({ \ | ||||
|         JSON_HEDLEY_CONSTEXPR double hedley_probability_ = (probability); \ | ||||
|         double hedley_probability_ = (probability); \ | ||||
|         ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \ | ||||
|     })) | ||||
| #  define JSON_HEDLEY_LIKELY(expr)   __builtin_expect(!!(expr), 1) | ||||
| #  define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) | ||||
| #else | ||||
| #  define JSON_HEDLEY_PREDICT(expr, expected, probability) (((void) (expected)), !!(expr)) | ||||
| #  define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)) | ||||
| #  define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr)) | ||||
| #  define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr)) | ||||
| #  define JSON_HEDLEY_LIKELY(expr) (!!(expr)) | ||||
|  | @ -1025,8 +1305,17 @@ JSON_HEDLEY_DIAGNOSTIC_POP | |||
|     JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ | ||||
|     JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ | ||||
|     JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ | ||||
|     JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ | ||||
|     (JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) | ||||
|     JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ | ||||
|     (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|     JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ | ||||
|     (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|     JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ | ||||
|     (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|     JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ | ||||
|     (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|     JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ | ||||
|     JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ | ||||
|     JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) | ||||
|     #define JSON_HEDLEY_MALLOC __attribute__((__malloc__)) | ||||
| #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) | ||||
|     #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory") | ||||
|  | @ -1040,22 +1329,36 @@ JSON_HEDLEY_DIAGNOSTIC_POP | |||
|     #undef JSON_HEDLEY_PURE | ||||
| #endif | ||||
| #if \ | ||||
|     JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \ | ||||
|     JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \ | ||||
|     JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ | ||||
|     JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ | ||||
|     JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ | ||||
|     JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ | ||||
|     JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ | ||||
|     (JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|     JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) | ||||
|     #define JSON_HEDLEY_PURE __attribute__((__pure__)) | ||||
|   JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \ | ||||
|   JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \ | ||||
|   JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ | ||||
|   JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ | ||||
|   JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ | ||||
|   JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ | ||||
|   JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ | ||||
|   (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|   JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ | ||||
|   (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|   JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ | ||||
|   (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|   JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ | ||||
|   (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|   JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ | ||||
|   JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ | ||||
|   JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ | ||||
|   JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) | ||||
| #  define JSON_HEDLEY_PURE __attribute__((__pure__)) | ||||
| #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) | ||||
|     #define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data") | ||||
| #elif JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) | ||||
|     #define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;") | ||||
| #  define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data") | ||||
| #elif defined(__cplusplus) && \ | ||||
|     ( \ | ||||
|       JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \ | ||||
|       JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \ | ||||
|       JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \ | ||||
|     ) | ||||
| #  define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;") | ||||
| #else | ||||
|     #define JSON_HEDLEY_PURE | ||||
| #  define JSON_HEDLEY_PURE | ||||
| #endif | ||||
| 
 | ||||
| #if defined(JSON_HEDLEY_CONST) | ||||
|  | @ -1068,8 +1371,17 @@ JSON_HEDLEY_DIAGNOSTIC_POP | |||
|     JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ | ||||
|     JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ | ||||
|     JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ | ||||
|     JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ | ||||
|     (JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|     JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ | ||||
|     (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|     JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ | ||||
|     (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|     JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ | ||||
|     (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|     JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ | ||||
|     (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|     JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ | ||||
|     JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ | ||||
|     JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ | ||||
|     JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) | ||||
|     #define JSON_HEDLEY_CONST __attribute__((__const__)) | ||||
| #elif \ | ||||
|  | @ -1091,7 +1403,10 @@ JSON_HEDLEY_DIAGNOSTIC_POP | |||
|     JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ | ||||
|     JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ | ||||
|     JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ | ||||
|     JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ | ||||
|     JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ | ||||
|     JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \ | ||||
|     JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \ | ||||
|     JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ | ||||
|     (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \ | ||||
|     JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ | ||||
|     defined(__clang__) | ||||
|  | @ -1116,7 +1431,12 @@ JSON_HEDLEY_DIAGNOSTIC_POP | |||
| #elif \ | ||||
|     JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ | ||||
|     JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ | ||||
|     JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) | ||||
|     JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \ | ||||
|     JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \ | ||||
|     JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ | ||||
|     JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \ | ||||
|     JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ | ||||
|     JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) | ||||
|     #define JSON_HEDLEY_INLINE __inline | ||||
| #else | ||||
|     #define JSON_HEDLEY_INLINE | ||||
|  | @ -1126,23 +1446,40 @@ JSON_HEDLEY_DIAGNOSTIC_POP | |||
|     #undef JSON_HEDLEY_ALWAYS_INLINE | ||||
| #endif | ||||
| #if \ | ||||
|     JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \ | ||||
|     JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ | ||||
|     JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ | ||||
|     JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ | ||||
|     JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ | ||||
|     JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ | ||||
|     JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ | ||||
|     (JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) | ||||
|     #define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE | ||||
|   JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \ | ||||
|   JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ | ||||
|   JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ | ||||
|   JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ | ||||
|   JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ | ||||
|   JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ | ||||
|   JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ | ||||
|   (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|   JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ | ||||
|   (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|   JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ | ||||
|   (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|   JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ | ||||
|   (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|   JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ | ||||
|   JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ | ||||
|   JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) | ||||
| #  define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE | ||||
| #elif JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) | ||||
|     #define JSON_HEDLEY_ALWAYS_INLINE __forceinline | ||||
| #elif JSON_HEDLEY_TI_VERSION_CHECK(7,0,0) && defined(__cplusplus) | ||||
|     #define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;") | ||||
| #  define JSON_HEDLEY_ALWAYS_INLINE __forceinline | ||||
| #elif defined(__cplusplus) && \ | ||||
|     ( \ | ||||
|       JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ | ||||
|       JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ | ||||
|       JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ | ||||
|       JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ | ||||
|       JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ | ||||
|       JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \ | ||||
|     ) | ||||
| #  define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;") | ||||
| #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) | ||||
|     #define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced") | ||||
| #  define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced") | ||||
| #else | ||||
|     #define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE | ||||
| #  define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE | ||||
| #endif | ||||
| 
 | ||||
| #if defined(JSON_HEDLEY_NEVER_INLINE) | ||||
|  | @ -1155,14 +1492,23 @@ JSON_HEDLEY_DIAGNOSTIC_POP | |||
|     JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ | ||||
|     JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ | ||||
|     JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ | ||||
|     JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ | ||||
|     (JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) | ||||
|     JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ | ||||
|     (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|     JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ | ||||
|     (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|     JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ | ||||
|     (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|     JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ | ||||
|     (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|     JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ | ||||
|     JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ | ||||
|     JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) | ||||
|     #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__)) | ||||
| #elif JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) | ||||
|     #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline) | ||||
| #elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0) | ||||
|     #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline") | ||||
| #elif JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) | ||||
| #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus) | ||||
|     #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;") | ||||
| #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) | ||||
|     #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never") | ||||
|  | @ -1184,26 +1530,31 @@ JSON_HEDLEY_DIAGNOSTIC_POP | |||
|     #undef JSON_HEDLEY_IMPORT | ||||
| #endif | ||||
| #if defined(_WIN32) || defined(__CYGWIN__) | ||||
|     #define JSON_HEDLEY_PRIVATE | ||||
|     #define JSON_HEDLEY_PUBLIC   __declspec(dllexport) | ||||
|     #define JSON_HEDLEY_IMPORT   __declspec(dllimport) | ||||
| #  define JSON_HEDLEY_PRIVATE | ||||
| #  define JSON_HEDLEY_PUBLIC   __declspec(dllexport) | ||||
| #  define JSON_HEDLEY_IMPORT   __declspec(dllimport) | ||||
| #else | ||||
|     #if \ | ||||
|         JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \ | ||||
|         JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ | ||||
|         JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ | ||||
|         JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ | ||||
|         JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ | ||||
|         JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ | ||||
|         JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ | ||||
|         (JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_EABI__) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) | ||||
|         #define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden"))) | ||||
|         #define JSON_HEDLEY_PUBLIC  __attribute__((__visibility__("default"))) | ||||
|     #else | ||||
|         #define JSON_HEDLEY_PRIVATE | ||||
|         #define JSON_HEDLEY_PUBLIC | ||||
|     #endif | ||||
|     #define JSON_HEDLEY_IMPORT    extern | ||||
| #  if \ | ||||
|     JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \ | ||||
|     JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ | ||||
|     JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ | ||||
|     JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ | ||||
|     JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ | ||||
|     JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ | ||||
|     ( \ | ||||
|       defined(__TI_EABI__) && \ | ||||
|       ( \ | ||||
|         (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ | ||||
|         JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \ | ||||
|       ) \ | ||||
|     ) | ||||
| #    define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden"))) | ||||
| #    define JSON_HEDLEY_PUBLIC  __attribute__((__visibility__("default"))) | ||||
| #  else | ||||
| #    define JSON_HEDLEY_PRIVATE | ||||
| #    define JSON_HEDLEY_PUBLIC | ||||
| #  endif | ||||
| #  define JSON_HEDLEY_IMPORT    extern | ||||
| #endif | ||||
| 
 | ||||
| #if defined(JSON_HEDLEY_NO_THROW) | ||||
|  | @ -1225,7 +1576,9 @@ JSON_HEDLEY_DIAGNOSTIC_POP | |||
| #if defined(JSON_HEDLEY_FALL_THROUGH) | ||||
|     #undef JSON_HEDLEY_FALL_THROUGH | ||||
| #endif | ||||
| #if JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(fallthrough,7,0,0) && !defined(JSON_HEDLEY_PGI_VERSION) | ||||
| #if \ | ||||
|     JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \ | ||||
|     JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) | ||||
|     #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__)) | ||||
| #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough) | ||||
|     #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]]) | ||||
|  | @ -1282,7 +1635,7 @@ JSON_HEDLEY_DIAGNOSTIC_POP | |||
|     JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \ | ||||
|     JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ | ||||
|     JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ | ||||
|     JSON_HEDLEY_TI_VERSION_CHECK(6,1,0) || \ | ||||
|     JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ | ||||
|     (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \ | ||||
|     JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) | ||||
|     #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr) | ||||
|  | @ -1303,7 +1656,11 @@ JSON_HEDLEY_DIAGNOSTIC_POP | |||
|     #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*) | ||||
| #endif | ||||
| #  elif \ | ||||
|        (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && !defined(JSON_HEDLEY_SUNPRO_VERSION) && !defined(JSON_HEDLEY_PGI_VERSION)) || \ | ||||
|        ( \ | ||||
|           defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \ | ||||
|           !defined(JSON_HEDLEY_SUNPRO_VERSION) && \ | ||||
|           !defined(JSON_HEDLEY_PGI_VERSION) && \ | ||||
|           !defined(JSON_HEDLEY_IAR_VERSION)) || \ | ||||
|        JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) || \ | ||||
|        JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ | ||||
|        JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \ | ||||
|  | @ -1319,7 +1676,12 @@ JSON_HEDLEY_DIAGNOSTIC_POP | |||
|        defined(JSON_HEDLEY_GCC_VERSION) || \ | ||||
|        defined(JSON_HEDLEY_INTEL_VERSION) || \ | ||||
|        defined(JSON_HEDLEY_TINYC_VERSION) || \ | ||||
|        defined(JSON_HEDLEY_TI_VERSION) || \ | ||||
|        defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \ | ||||
|        JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \ | ||||
|        defined(JSON_HEDLEY_TI_CL2000_VERSION) || \ | ||||
|        defined(JSON_HEDLEY_TI_CL6X_VERSION) || \ | ||||
|        defined(JSON_HEDLEY_TI_CL7X_VERSION) || \ | ||||
|        defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \ | ||||
|        defined(__clang__) | ||||
| #    define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \ | ||||
|         sizeof(void) != \ | ||||
|  | @ -1377,59 +1739,12 @@ JSON_HEDLEY_DIAGNOSTIC_POP | |||
| #  define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message) | ||||
| #elif \ | ||||
|   (defined(__cplusplus) && (__cplusplus >= 201103L)) || \ | ||||
|   JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \ | ||||
|   (defined(__cplusplus) && JSON_HEDLEY_TI_VERSION_CHECK(8,3,0)) | ||||
|   JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) | ||||
| #  define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message)) | ||||
| #else | ||||
| #  define JSON_HEDLEY_STATIC_ASSERT(expr, message) | ||||
| #endif | ||||
| 
 | ||||
| #if defined(JSON_HEDLEY_CONST_CAST) | ||||
|     #undef JSON_HEDLEY_CONST_CAST | ||||
| #endif | ||||
| #if defined(__cplusplus) | ||||
| #  define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr)) | ||||
| #elif \ | ||||
|   JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \ | ||||
|   JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \ | ||||
|   JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) | ||||
| #  define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \ | ||||
|         JSON_HEDLEY_DIAGNOSTIC_PUSH \ | ||||
|         JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \ | ||||
|         ((T) (expr)); \ | ||||
|         JSON_HEDLEY_DIAGNOSTIC_POP \ | ||||
|     })) | ||||
| #else | ||||
| #  define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr)) | ||||
| #endif | ||||
| 
 | ||||
| #if defined(JSON_HEDLEY_REINTERPRET_CAST) | ||||
|     #undef JSON_HEDLEY_REINTERPRET_CAST | ||||
| #endif | ||||
| #if defined(__cplusplus) | ||||
|     #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr)) | ||||
| #else | ||||
|     #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (*((T*) &(expr))) | ||||
| #endif | ||||
| 
 | ||||
| #if defined(JSON_HEDLEY_STATIC_CAST) | ||||
|     #undef JSON_HEDLEY_STATIC_CAST | ||||
| #endif | ||||
| #if defined(__cplusplus) | ||||
|     #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr)) | ||||
| #else | ||||
|     #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr)) | ||||
| #endif | ||||
| 
 | ||||
| #if defined(JSON_HEDLEY_CPP_CAST) | ||||
|     #undef JSON_HEDLEY_CPP_CAST | ||||
| #endif | ||||
| #if defined(__cplusplus) | ||||
|     #define JSON_HEDLEY_CPP_CAST(T, expr) static_cast<T>(expr) | ||||
| #else | ||||
|     #define JSON_HEDLEY_CPP_CAST(T, expr) (expr) | ||||
| #endif | ||||
| 
 | ||||
| #if defined(JSON_HEDLEY_NULL) | ||||
|     #undef JSON_HEDLEY_NULL | ||||
| #endif | ||||
|  | @ -1481,7 +1796,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP | |||
|     JSON_HEDLEY_DIAGNOSTIC_POP | ||||
| #elif \ | ||||
|   JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \ | ||||
|   JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) | ||||
|   JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ | ||||
|   JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) | ||||
| #  define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg) | ||||
| #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) | ||||
| #  define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg)) | ||||
|  |  | |||
|  | @ -4,7 +4,6 @@ | |||
| #undef JSON_HEDLEY_ARRAY_PARAM | ||||
| #undef JSON_HEDLEY_ASSUME | ||||
| #undef JSON_HEDLEY_BEGIN_C_DECLS | ||||
| #undef JSON_HEDLEY_C_DECL | ||||
| #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE | ||||
| #undef JSON_HEDLEY_CLANG_HAS_BUILTIN | ||||
| #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE | ||||
|  | @ -15,13 +14,16 @@ | |||
| #undef JSON_HEDLEY_COMPCERT_VERSION | ||||
| #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK | ||||
| #undef JSON_HEDLEY_CONCAT | ||||
| #undef JSON_HEDLEY_CONCAT3 | ||||
| #undef JSON_HEDLEY_CONCAT3_EX | ||||
| #undef JSON_HEDLEY_CONCAT_EX | ||||
| #undef JSON_HEDLEY_CONST | ||||
| #undef JSON_HEDLEY_CONST_CAST | ||||
| #undef JSON_HEDLEY_CONSTEXPR | ||||
| #undef JSON_HEDLEY_CONST_CAST | ||||
| #undef JSON_HEDLEY_CPP_CAST | ||||
| #undef JSON_HEDLEY_CRAY_VERSION | ||||
| #undef JSON_HEDLEY_CRAY_VERSION_CHECK | ||||
| #undef JSON_HEDLEY_C_DECL | ||||
| #undef JSON_HEDLEY_DEPRECATED | ||||
| #undef JSON_HEDLEY_DEPRECATED_FOR | ||||
| #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL | ||||
|  | @ -37,7 +39,6 @@ | |||
| #undef JSON_HEDLEY_EMSCRIPTEN_VERSION | ||||
| #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK | ||||
| #undef JSON_HEDLEY_END_C_DECLS | ||||
| #undef JSON_HEDLEY_FALL_THROUGH | ||||
| #undef JSON_HEDLEY_FLAGS | ||||
| #undef JSON_HEDLEY_FLAGS_CAST | ||||
| #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE | ||||
|  | @ -83,8 +84,8 @@ | |||
| #undef JSON_HEDLEY_MSVC_VERSION | ||||
| #undef JSON_HEDLEY_MSVC_VERSION_CHECK | ||||
| #undef JSON_HEDLEY_NEVER_INLINE | ||||
| #undef JSON_HEDLEY_NO_ESCAPE | ||||
| #undef JSON_HEDLEY_NON_NULL | ||||
| #undef JSON_HEDLEY_NO_ESCAPE | ||||
| #undef JSON_HEDLEY_NO_RETURN | ||||
| #undef JSON_HEDLEY_NO_THROW | ||||
| #undef JSON_HEDLEY_NULL | ||||
|  | @ -112,6 +113,18 @@ | |||
| #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK | ||||
| #undef JSON_HEDLEY_TINYC_VERSION | ||||
| #undef JSON_HEDLEY_TINYC_VERSION_CHECK | ||||
| #undef JSON_HEDLEY_TI_ARMCL_VERSION | ||||
| #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK | ||||
| #undef JSON_HEDLEY_TI_CL2000_VERSION | ||||
| #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK | ||||
| #undef JSON_HEDLEY_TI_CL430_VERSION | ||||
| #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK | ||||
| #undef JSON_HEDLEY_TI_CL6X_VERSION | ||||
| #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK | ||||
| #undef JSON_HEDLEY_TI_CL7X_VERSION | ||||
| #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK | ||||
| #undef JSON_HEDLEY_TI_CLPRU_VERSION | ||||
| #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK | ||||
| #undef JSON_HEDLEY_TI_VERSION | ||||
| #undef JSON_HEDLEY_TI_VERSION_CHECK | ||||
| #undef JSON_HEDLEY_UNAVAILABLE | ||||
|  | @ -126,3 +139,5 @@ | |||
| #undef JSON_HEDLEY_VERSION_ENCODE | ||||
| #undef JSON_HEDLEY_WARNING | ||||
| #undef JSON_HEDLEY_WARN_UNUSED_RESULT | ||||
| #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG | ||||
| #undef JSON_HEDLEY_FALL_THROUGH | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue