| 1328 | } |
| 1329 | |
| 1330 | void Finish() { |
| 1331 | // If you hit this assert, you likely have objects that were never included |
| 1332 | // in a parent. You need to have exactly one root to finish a buffer. |
| 1333 | // Check your Start/End calls are matched, and all objects are inside |
| 1334 | // some other object. |
| 1335 | FLATBUFFERS_ASSERT(stack_.size() == 1); |
| 1336 | |
| 1337 | // Write root value. |
| 1338 | auto byte_width = Align(stack_[0].ElemWidth(buf_.size(), 0)); |
| 1339 | WriteAny(stack_[0], byte_width); |
| 1340 | // Write root type. |
| 1341 | Write(stack_[0].StoredPackedType(), 1); |
| 1342 | // Write root size. Normally determined by parent, but root has no parent :) |
| 1343 | Write(byte_width, 1); |
| 1344 | |
| 1345 | finished_ = true; |
| 1346 | } |
| 1347 | |
| 1348 | private: |
| 1349 | void Finished() const { |
nothing calls this directly
no test coverage detected