| 91 | } |
| 92 | |
| 93 | static Value value_from_binary(ByteReader& reader) { |
| 94 | ubyte typecode = reader.get(); |
| 95 | switch (typecode) { |
| 96 | case BJSON_TYPE_DOCUMENT: |
| 97 | reader.getInt32(); |
| 98 | return Map_sptr(object_from_binary(reader).release()); |
| 99 | case BJSON_TYPE_LIST: |
| 100 | return List_sptr(array_from_binary(reader).release()); |
| 101 | case BJSON_TYPE_BYTE: |
| 102 | return static_cast<integer_t>(reader.get()); |
| 103 | case BJSON_TYPE_INT16: |
| 104 | return static_cast<integer_t>(reader.getInt16()); |
| 105 | case BJSON_TYPE_INT32: |
| 106 | return static_cast<integer_t>(reader.getInt32()); |
| 107 | case BJSON_TYPE_INT64: |
| 108 | return reader.getInt64(); |
| 109 | case BJSON_TYPE_NUMBER: |
| 110 | return reader.getFloat64(); |
| 111 | case BJSON_TYPE_FALSE: |
| 112 | case BJSON_TYPE_TRUE: |
| 113 | return (typecode - BJSON_TYPE_FALSE) != 0; |
| 114 | case BJSON_TYPE_STRING: |
| 115 | return reader.getString(); |
| 116 | default: |
| 117 | throw std::runtime_error( |
| 118 | "type "+std::to_string(typecode)+" is not supported" |
| 119 | ); |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | static std::unique_ptr<List> array_from_binary(ByteReader& reader) { |
| 124 | auto array = std::make_unique<List>(); |
no test coverage detected