| 436 | |
| 437 | template<typename T> |
| 438 | void ResizeVector(const reflection::Schema &schema, uoffset_t newsize, T val, |
| 439 | const Vector<T> *vec, std::vector<uint8_t> *flatbuf, |
| 440 | const reflection::Object *root_table = nullptr) { |
| 441 | auto delta_elem = static_cast<int>(newsize) - static_cast<int>(vec->size()); |
| 442 | auto newelems = ResizeAnyVector( |
| 443 | schema, newsize, reinterpret_cast<const VectorOfAny *>(vec), vec->size(), |
| 444 | static_cast<uoffset_t>(sizeof(T)), flatbuf, root_table); |
| 445 | // Set new elements to "val". |
| 446 | for (int i = 0; i < delta_elem; i++) { |
| 447 | auto loc = newelems + i * sizeof(T); |
| 448 | auto is_scalar = flatbuffers::is_scalar<T>::value; |
| 449 | if (is_scalar) { |
| 450 | WriteScalar(loc, val); |
| 451 | } else { // struct |
| 452 | *reinterpret_cast<T *>(loc) = val; |
| 453 | } |
| 454 | } |
| 455 | } |
| 456 | |
| 457 | // Adds any new data (in the form of a new FlatBuffer) to an existing |
| 458 | // FlatBuffer. This can be used when any of the above methods are not |
nothing calls this directly
no test coverage detected