| 2503 | // A BufferRef does not own its buffer. |
| 2504 | struct BufferRefBase {}; // for std::is_base_of |
| 2505 | template<typename T> struct BufferRef : BufferRefBase { |
| 2506 | BufferRef() : buf(nullptr), len(0), must_free(false) {} |
| 2507 | BufferRef(uint8_t *_buf, uoffset_t _len) |
| 2508 | : buf(_buf), len(_len), must_free(false) {} |
| 2509 | |
| 2510 | ~BufferRef() { |
| 2511 | if (must_free) free(buf); |
| 2512 | } |
| 2513 | |
| 2514 | const T *GetRoot() const { return flatbuffers::GetRoot<T>(buf); } |
| 2515 | |
| 2516 | bool Verify() { |
| 2517 | Verifier verifier(buf, len); |
| 2518 | return verifier.VerifyBuffer<T>(nullptr); |
| 2519 | } |
| 2520 | |
| 2521 | uint8_t *buf; |
| 2522 | uoffset_t len; |
| 2523 | bool must_free; |
| 2524 | }; |
| 2525 | |
| 2526 | // "structs" are flat structures that do not have an offset table, thus |
| 2527 | // always have all members present and do not support forwards/backwards |
nothing calls this directly
no outgoing calls
no test coverage detected