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