Implementation:Alibaba MNN FlatBuffers Monster Generated H
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Serialization, Code_Generation |
| Last Updated | 2026-02-10 12:00 GMT |
Overview
Generated C++ code for the canonical Monster sample schema, demonstrating FlatBuffers code generation output.
Description
monster_generated.h is the C++ source generated by flatc from the Monster tutorial schema. It defines accessor classes such as Monster, Weapon, Vec3, and associated builder types. This file serves as a reference example of what flatc produces for C++ and is included in the vendored tree as part of the FlatBuffers samples.
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/samples/monster_generated.h - Lines: 1-820
Signature
namespace MyGame { namespace Sample {
struct Monster;
struct MonsterBuilder;
struct Weapon;
struct Vec3;
}}
Import
#include "monster_generated.h"
I/O Contract
| Input | Output |
|---|---|
| Builder API calls with Monster fields | Serialized Monster FlatBuffer |
| Raw Monster FlatBuffer bytes | Zero-copy Monster accessor with typed getters
|
Usage Examples
#include "monster_generated.h"
using namespace MyGame::Sample;
flatbuffers::FlatBufferBuilder builder(256);
auto name = builder.CreateString("Orc");
auto monster = CreateMonster(builder, /* pos */ nullptr,
/* mana */ 150, /* hp */ 80, name);
builder.Finish(monster);
auto m = GetMonster(builder.GetBufferPointer());
assert(m->name()->str() == "Orc");
Related Pages
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment