MCPcopy Create free account
hub / github.com/MihailRis/voxelcore / value_from_binary

Function value_from_binary

src/coders/binary_json.cpp:93–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

91}
92
93static 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
123static std::unique_ptr<List> array_from_binary(ByteReader& reader) {
124 auto array = std::make_unique<List>();

Callers 3

array_from_binaryFunction · 0.85
object_from_binaryFunction · 0.85
from_binaryMethod · 0.85

Calls 9

object_from_binaryFunction · 0.85
array_from_binaryFunction · 0.85
getInt32Method · 0.80
getInt16Method · 0.80
getInt64Method · 0.80
getFloat64Method · 0.80
getStringMethod · 0.80
to_stringFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected