We already are using a flatbuffer with a similar scheme
namespace potter;
union Magic { Weapon, Wand }
table Weapon {
name:string;
power:int;
}
table Wand {
make:string;
animal:string;
}
table MagicHolder {
name:string;
age:int;
magic:Magic;
}
root_type MagicHolder;
Now, if we want to add two things.
level:string
in theMagicHolder
- Under the
Wand
akey:value
type, wherekey:string
, andvalue
can be eitherstring or int or float or bool
What I’m trying is
table MagicHolder {
name:string;
age:int;
level:string; /*new addition*/
magic:Magic;
}
table KeyValue {
key:string;
vint:int;
vfloat:float;
vbool:bool;
vstring:string;
vtype:string; /* since I cannot differentiate between bool set or not, trying to store type here */
}
table Wand {
make:string;
animal:string;
kv:KeyValue;
}
Is this the best approach? What would be the pros/cons.. Any other recommended ways to do this new additions more efficiently