存储数据列表和自动分配给结构的最佳方法是什么

问题描述 投票:0回答:1

编辑:我没有正确解释自己。再试一次。

我正在写一个保存游戏编辑器。编辑器在保存游戏中加载,检查版本。版本信息保存在各种“数据”语句中,一旦检查了版本,就加载了正确的偏移量。然后将偏移分配给变量。以下是两个版本游戏(Sensible World of Soccer)的偏移量示例:

Swos_Beta_09 = {  # _update: 95/96
'num_players_pos': 56717,       # - Number of players in the team
'team_name_pos': 55429,         # - Team Name
'mgr_forename_pos': 54987,      # - Managers forename
'mgr_surname_pos': 54996,       # - Managers Surname
'mgr_fullname_pos': 55460,      # - Managers Full Name (Yes it is stored twice!!)
'plr1_Position_pos': 55500,     # - Position of the first player in the file. This is then 38 bytes of data
'money_pos': 54742,             # - Money
'tact_pos': 88374,              # - First Tactic
'first_team': 90635,            # - First team in the file
'CJOffset': 90614,              # - File position of the version number
'CJ': "CJ281112",               # - This is the version we are expecting
'version_pos': "Sensible World of Soccer v0.09 - 28/11/1994 11.00am"  # - And this is the version

Swos_Release_v10 =                 # _update: 95/96
'num_players_pos': 56719,       # - Number of players in the team
'team_name_pos': 55431,         # - Team Name
'mgr_forename_pos': 54989,      # - Managers forename
'mgr_surname_pos': 54998,       # - Managers Surname
'mgr_fullname_pos': 55462,      # - Managers Full Name (Yes it is stored twice!!)

在python中我使用了字典,然后一旦检查了版本(例如CJ031223),它就将正确的偏移复制到另一个字典(或列表)中,允许我访问数据。

注意:我将为球队和球员使用课程,我在这里并不关心。我正在寻找在c ++中执行此操作的最佳方法。

c++ list vector structure
1个回答
0
投票

看看unordered_map的cpp“词典”等价物。对于json解析器,你可能比boost's json parser更糟糕。

© www.soinside.com 2019 - 2024. All rights reserved.