String Tables¶
Manages incremental key/value side tables such as instancebaseline and CombatLogNames, including create/update flows.
See also: String Tables
gem.string_table.StringTables
¶
Container for all string tables registered during a replay.
Attributes:
| Name | Type | Description |
|---|---|---|
tables |
dict[int, StringTable]
|
Mapping of table index → StringTable. |
name_index |
dict[str, int]
|
Mapping of table name → table index. |
Source code in src/gem/string_table.py
add(table: StringTable) -> None
¶
Register a StringTable in the container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table
|
StringTable
|
The StringTable to register. |
required |
get_by_name(name: str) -> StringTable | None
¶
Return the table with the given name, or None if not found.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The table name to look up. |
required |
Returns:
| Type | Description |
|---|---|
StringTable | None
|
The StringTable, or None. |
Source code in src/gem/string_table.py
get_by_id(table_id: int) -> StringTable | None
¶
Return the table with the given index, or None if not found.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table_id
|
int
|
The integer table index. |
required |
Returns:
| Type | Description |
|---|---|
StringTable | None
|
The StringTable, or None. |
Source code in src/gem/string_table.py
gem.string_table.StringTable
dataclass
¶
A named string table with its metadata and current items.
Attributes:
| Name | Type | Description |
|---|---|---|
index |
int
|
Table index assigned at creation time. |
name |
str
|
Table name (e.g. |
items |
dict[int, tuple[str, bytes]]
|
Mapping of item index → (key, value) tuple. |
user_data_fixed_size |
bool
|
If True, all values have the same bit width. |
user_data_size_bits |
int
|
Bit width of each value when fixed-size. |
flags |
int
|
Table flags bitmask. |
varint_bit_counts |
bool
|
If True, value sizes are encoded as ubit_var. |
Source code in src/gem/string_table.py
gem.string_table.StringTableItem
¶
gem.string_table.parse_string_table(buf: bytes, num_updates: int, name: str, user_data_fixed_size: bool, user_data_size_bits: int, flags: int, varint_bit_counts: bool) -> list[StringTableItem]
¶
Parse a string table data blob into a list of item updates.
Each update contains an index, an optional key, and an optional value.
Keys may reference a 32-entry history ring buffer for prefix compression.
Values may be Snappy-compressed when flags & 0x1 and the compression
bit is set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
buf
|
bytes
|
Raw bytes from the string table message's |
required |
num_updates
|
int
|
Number of entries to read. |
required |
name
|
str
|
Table name (used only for error messages). |
required |
user_data_fixed_size
|
bool
|
If True, values have a fixed bit width. |
required |
user_data_size_bits
|
int
|
Fixed value width in bits (when user_data_fixed_size). |
required |
flags
|
int
|
Table flags; bit 0 enables per-entry compression. |
required |
varint_bit_counts
|
bool
|
If True, value byte sizes are encoded as ubit_var. |
required |
Returns:
| Type | Description |
|---|---|
list[StringTableItem]
|
List of StringTableItem updates in parse order. |
Source code in src/gem/string_table.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | |
gem.string_table.handle_create(msg: object, string_tables: StringTables) -> StringTable
¶
Process a CSVCMsg_CreateStringTable message.
Creates a new StringTable, parses its initial items (decompressing the data blob if necessary), and registers it in string_tables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
msg
|
object
|
A |
required |
string_tables
|
StringTables
|
The StringTables container to update. |
required |
Returns:
| Type | Description |
|---|---|
StringTable
|
The newly created StringTable. |
Source code in src/gem/string_table.py
gem.string_table.handle_update(msg: object, string_tables: StringTables) -> StringTable
¶
Process a CSVCMsg_UpdateStringTable message.
Merges updated items into the existing table. Key and value updates are applied independently: a blank key leaves the existing key intact.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
msg
|
object
|
A |
required |
string_tables
|
StringTables
|
The StringTables container to update. |
required |
Returns:
| Type | Description |
|---|---|
StringTable
|
The updated StringTable. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If the referenced table index does not exist. |