MCPcopy Create free account
hub / github.com/bytedance/Fastbot_Android / ParseArray

Method ParseArray

native/thirdpart/flatbuffers/idl_parser.cpp:1619–1664  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1617}
1618
1619CheckedError Parser::ParseArray(Value &array) {
1620 std::vector<Value> stack;
1621 FlatBufferBuilder builder;
1622 const auto &type = array.type.VectorType();
1623 auto length = array.type.fixed_length;
1624 uoffset_t count = 0;
1625 auto err = ParseVectorDelimiters(count, [&](uoffset_t &) -> CheckedError {
1626 vector_emplace_back(&stack, Value());
1627 auto &val = stack.back();
1628 val.type = type;
1629 if (IsStruct(type)) {
1630 ECHECK(ParseTable(*val.type.struct_def, &val.constant, nullptr));
1631 } else {
1632 ECHECK(ParseSingleValue(nullptr, val, false));
1633 }
1634 return NoError();
1635 });
1636 ECHECK(err);
1637 if (length != count) return Error("Fixed-length array size is incorrect.");
1638
1639 for (auto it = stack.rbegin(); it != stack.rend(); ++it) {
1640 auto &val = *it;
1641 // clang-format off
1642 switch (val.type.base_type) {
1643 #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, ...) \
1644 case BASE_TYPE_ ## ENUM: \
1645 if (IsStruct(val.type)) { \
1646 SerializeStruct(builder, *val.type.struct_def, val); \
1647 } else { \
1648 CTYPE elem; \
1649 ECHECK(atot(val.constant.c_str(), *this, &elem)); \
1650 builder.PushElement(elem); \
1651 } \
1652 break;
1653 FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD)
1654 #undef FLATBUFFERS_TD
1655 default: FLATBUFFERS_ASSERT(0);
1656 }
1657 // clang-format on
1658 }
1659
1660 array.constant.assign(
1661 reinterpret_cast<const char *>(builder.GetCurrentBufferPointer()),
1662 InlineSize(array.type));
1663 return NoError();
1664}
1665
1666CheckedError Parser::ParseNestedFlatbuffer(Value &val, FieldDef *field,
1667 size_t fieldn,

Callers

nothing calls this directly

Calls 9

vector_emplace_backFunction · 0.85
IsStructFunction · 0.85
NoErrorFunction · 0.85
ErrorFunction · 0.85
VectorTypeMethod · 0.80
ValueClass · 0.70
InlineSizeFunction · 0.70
rbeginMethod · 0.45
rendMethod · 0.45

Tested by

no test coverage detected