Skip to content

Commit 5d22433

Browse files
oschwaldclaude
andcommitted
Document working with maps and arrays
Add documentation explaining how to access individual entries in maps and arrays: - In the Data Lookup Functions section, explain that multiple keys in the same map are accessed via separate calls with the full lookup path, and that MMDB_get_entry_data_list() is more efficient for retrieving all data from a complex structure. - In the MMDB_entry_data_s section, note that MAP and ARRAY types represent collections and explain how to access their items. Relates to GitHub #255. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 93f6c58 commit 5d22433

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

doc/libmaxminddb.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,10 @@ The `data_size` member is only relevant for `utf8_string` and `bytes` data.
255255
determine its length.
256256

257257
The `type` member can be compared to one of the `MMDB_DATA_TYPE_*` macros.
258+
When `type` is `MMDB_DATA_TYPE_MAP` or `MMDB_DATA_TYPE_ARRAY`, the entry
259+
represents a collection. To access individual items within the collection, use
260+
`MMDB_get_value()` with the appropriate lookup path from the original entry. To
261+
iterate over all items, use `MMDB_get_entry_data_list()`.
258262

259263
### 128-bit Integers
260264

@@ -609,8 +613,12 @@ last element retrieved by `va_arg()` must be `NULL`.
609613
Finally, the `MMDB_aget_value` accepts an array of strings as the lookup
610614
path. The last member of this array must be `NULL`.
611615
612-
If you want to get all of the entry data at once you can call
613-
`MMDB_get_entry_data_list()` instead.
616+
To look up multiple keys within the same map, use the full lookup path for
617+
each key. For example, to get both the `en` and `de` values from the `names`
618+
map, make separate calls with `"names", "en", NULL` and `"names", "de", NULL`.
619+
If you need all of the data from a complex structure rather than specific
620+
values, `MMDB_get_entry_data_list()` is more efficient than making many
621+
individual calls.
614622
615623
For each of the three functions, the return value is a status code as
616624
defined above.

0 commit comments

Comments
 (0)