MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / ScalarVector

Function ScalarVector

Libs/flatbuffers/flexbuffers.h:1515–1533  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1513
1514 template<typename T>
1515 size_t ScalarVector(const T *elems, size_t len, bool fixed) {
1516 auto vector_type = GetScalarType<T>();
1517 auto byte_width = sizeof(T);
1518 auto bit_width = WidthB(byte_width);
1519 // If you get this assert, you're trying to write a vector with a size
1520 // field that is bigger than the scalars you're trying to write (e.g. a
1521 // byte vector > 255 elements). For such types, write a "blob" instead.
1522 // TODO: instead of asserting, could write vector with larger elements
1523 // instead, though that would be wasteful.
1524 FLATBUFFERS_ASSERT(WidthU(len) <= bit_width);
1525 Align(bit_width);
1526 if (!fixed) Write<uint64_t>(len, byte_width);
1527 auto vloc = buf_.size();
1528 for (size_t i = 0; i < len; i++) Write(elems[i], byte_width);
1529 stack_.push_back(Value(static_cast<uint64_t>(vloc),
1530 ToTypedVector(vector_type, fixed ? len : 0),
1531 bit_width));
1532 return vloc;
1533 }
1534
1535 Value CreateVector(size_t start, size_t vec_len, size_t step, bool typed,
1536 bool fixed, const Value *keys = nullptr) {

Callers 2

VectorFunction · 0.85
FixedTypedVectorFunction · 0.85

Calls 8

WidthBFunction · 0.85
WidthUFunction · 0.85
WriteFunction · 0.85
ToTypedVectorFunction · 0.85
AlignFunction · 0.70
ValueClass · 0.70
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected