Skip to content

confgen: support multi-key map #265

@Kybxd

Description

@Kybxd

Sometimes we want to map multiple different keys to the same value, but we don't want to occupy too many cells. So we expect keys with the same value can be defined in the same cell. For example:

Group1ItemID Group1ItemWeight Group2ItemID Group2ItemWeight Group3ItemID Group3ItemWeight
map<uint32, Group>|{multikey:true} int32 uint32 int32 uint32 int32
Group1’s ItemID Group1’s ItemWeight Group2’s ItemID Group2’s ItemWeight Group3’s ItemID Group3’s ItemWeight
101,102,103 100 201,202 200 301 300

This worksheet generates proto:

message ItemConf {
  option (tableau.worksheet) = {name:"ItemConf"};

  map<uint32, Group> group_map = 1 [(tableau.field) = {name:"Group" key:"ItemID" layout:LAYOUT_HORIZONTAL prop:{multikey:true}}];
  message Group {
    uint32 item_id = 1 [(tableau.field) = {name:"ItemID"}];
    int32 item_weight = 2 [(tableau.field) = {name:"ItemWeight"}];
  }
}

And json:

{
    "groupMap": {
        "101": {
            "itemId": 101,
            "itemWeight": 100
        },
        "102": {
            "itemId": 102,
            "itemWeight": 100
        },
        "103": {
            "itemId": 103,
            "itemWeight": 100
        },
        "201": {
            "itemId": 201,
            "itemWeight": 200
        },
        "202": {
            "itemId": 202,
            "itemWeight": 200
        },
        "301": {
            "itemId": 301,
            "itemWeight": 300
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions