Implementation:Alibaba MNN FlatBuffers Minireflect Header
| Knowledge Sources | |
|---|---|
| Domains | Serialization, Reflection |
| Last Updated | 2026-02-10 12:00 GMT |
Overview
Lightweight reflection API for iterating over FlatBuffer fields without the full reflection schema.
Description
minireflect.h provides a minimal reflection mechanism that allows traversal of FlatBuffer data using compact type tables generated alongside normal accessors. Unlike the full reflection API, mini-reflection does not require a binary schema and adds very little code size. It enables generic operations such as printing FlatBuffers as text, comparing objects field-by-field, and performing schema-independent transformations.
Usage
Vendored dependency used internally by MNN for model serialization. Not directly imported by end users.
Code Reference
Source Location
- Repository: Alibaba_MNN
- File:
3rd_party/flatbuffers/include/flatbuffers/minireflect.h - Lines: 1-386
Signature
struct TypeTable;
struct TypeFunction;
void IterateObject(const uint8_t *obj, const TypeTable *type_table,
IterationVisitor *visitor);
std::string FlatBufferToString(const uint8_t *buffer,
const TypeTable *type_table);
Import
#include "flatbuffers/minireflect.h"
I/O Contract
| Input | Output |
|---|---|
Serialized FlatBuffer bytes + TypeTable |
Visitor callbacks for each field, or text representation |
Usage Examples
#include "flatbuffers/minireflect.h"
// Assuming MonsterTypeTable() is generated
auto buffer = GetBufferPointer();
std::string text = flatbuffers::FlatBufferToString(
buffer, MonsterTypeTable());
// text contains a human-readable dump of the buffer