For the following proto message:
message FruitConf {
option (tableau.worksheet) = {
ordered_map: true
};
map<int32, Fruit> fruit_map = 1 [(tableau.field) = { name: "Fruit" key: "Key" layout: LAYOUT_INCELL }];
message Fruit {
protoconf.FruitType key = 1 [(tableau.field) = { name: "Key" }];
map<int32, int32> value_list = 3 [(tableau.field) = { name: "Value" layout: LAYOUT_INCELL }];
}
}
The generated 1-level ordered map getter accepts int32 as func param. It would be better to replace int32 with enum type.
const FruitConf::OrderedMap_int32Map* FruitConf::GetOrderedMap(int32_t key) const {
const auto* conf = GetOrderedMap();
if (conf == nullptr) {
return nullptr;
}
auto iter = conf->find(key);
if (iter == conf->end()) {
return nullptr;
}
return &iter->second.first;
}
// GetOrderedMap1 finds value in the 1-level ordered map. It will return
// NotFound error if the key is not found.
func (x *FruitConf) GetOrderedMap1(key int32) (*OrderedMap_FruitConf_int32Map, error) {
conf := x.orderedMap
if val, ok := conf.Get(key); !ok {
return nil, fmt.Errorf("key(%v) %w", key, ErrNotFound)
} else {
return val.First, nil
}
}
For the following proto message:
The generated 1-level ordered map getter accepts int32 as func param. It would be better to replace int32 with enum type.