MCPcopy Create free account
hub / github.com/apache/fory / read_uint_target

Function read_uint_target

cpp/fory/serialization/compatible_scalar.cc:1326–1418  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1324}
1325
1326bool read_uint_target(ReadContext &ctx, uint32_t remote_type_id,
1327 uint32_t local_type_id, std::string_view field,
1328 uint64_t max_value, uint64_t &out) {
1329 int64_t signed_value = 0;
1330 uint64_t unsigned_value = 0;
1331 bool is_unsigned = false;
1332 switch (static_cast<TypeId>(remote_type_id)) {
1333 case TypeId::BOOL: {
1334 uint8_t raw = ctx.read_uint8(ctx.error());
1335 if (FORY_PREDICT_FALSE(ctx.has_error())) {
1336 return false;
1337 }
1338 if (FORY_PREDICT_FALSE(raw != 0 && raw != 1)) {
1339 conversion_error(ctx, remote_type_id, local_type_id, field,
1340 "invalid bool payload");
1341 return false;
1342 }
1343 signed_value = raw != 0 ? 1 : 0;
1344 break;
1345 }
1346 case TypeId::INT8:
1347 signed_value = ctx.read_int8(ctx.error());
1348 break;
1349 case TypeId::INT16:
1350 signed_value = ctx.read_int16(ctx.error());
1351 break;
1352 case TypeId::INT32:
1353 signed_value = ctx.read_int32(ctx.error());
1354 break;
1355 case TypeId::VARINT32:
1356 signed_value = ctx.read_var_int32(ctx.error());
1357 break;
1358 case TypeId::INT64:
1359 signed_value = ctx.read_int64(ctx.error());
1360 break;
1361 case TypeId::VARINT64:
1362 signed_value = ctx.read_var_int64(ctx.error());
1363 break;
1364 case TypeId::TAGGED_INT64:
1365 signed_value = ctx.read_tagged_int64(ctx.error());
1366 break;
1367 case TypeId::UINT8:
1368 is_unsigned = true;
1369 unsigned_value = ctx.read_uint8(ctx.error());
1370 break;
1371 case TypeId::UINT16:
1372 is_unsigned = true;
1373 unsigned_value = static_cast<uint16_t>(ctx.read_int16(ctx.error()));
1374 break;
1375 case TypeId::UINT32:
1376 is_unsigned = true;
1377 unsigned_value = static_cast<uint32_t>(ctx.read_int32(ctx.error()));
1378 break;
1379 case TypeId::VAR_UINT32:
1380 is_unsigned = true;
1381 unsigned_value = ctx.read_var_uint32(ctx.error());
1382 break;
1383 case TypeId::UINT64:

Callers 4

read_compatible_uint8Function · 0.85
read_compatible_uint16Function · 0.85
read_compatible_uint32Function · 0.85
read_compatible_uint64Function · 0.85

Calls 14

conversion_errorFunction · 0.70
errorMethod · 0.65
read_uint8Method · 0.45
has_errorMethod · 0.45
read_int8Method · 0.45
read_int16Method · 0.45
read_int32Method · 0.45
read_var_int32Method · 0.45
read_int64Method · 0.45
read_var_int64Method · 0.45
read_tagged_int64Method · 0.45
read_var_uint32Method · 0.45

Tested by

no test coverage detected