summaryrefslogtreecommitdiffhomepage
path: root/examples/mapmap.c
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2021-03-13 13:03:29 +0100
committerTyge Løvset <[email protected]>2021-03-13 13:03:29 +0100
commit508d4759db4cc45fe49441dd19e40f38a497fe0f (patch)
tree032888b62a5db3ce677bde9f3f08cf56c587d478 /examples/mapmap.c
parentf9043a0ad319eed6b83c3c25921aff5a1b42c8fc (diff)
downloadSTC-modified-508d4759db4cc45fe49441dd19e40f38a497fe0f.tar.gz
STC-modified-508d4759db4cc45fe49441dd19e40f38a497fe0f.zip
Fixed some doc errors in csmap and cmap. Added some inline funcs to cstr. Added read.c example.
Diffstat (limited to 'examples/mapmap.c')
-rw-r--r--examples/mapmap.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/examples/mapmap.c b/examples/mapmap.c
index e22ac80c..fc6c8a79 100644
--- a/examples/mapmap.c
+++ b/examples/mapmap.c
@@ -3,24 +3,26 @@
#include <stc/cmap.h>
#include <stc/cstr.h>
+// unordered_map<string, unordered_map<string, string>>:
+
using_cmap_str();
using_cmap_strkey(cfg, cmap_str, cmap_str_del, c_no_clone);
int main(void) {
- cmap_cfg config = cmap_cfg_init();
+ cmap_cfg cfg = cmap_cfg_init();
cmap_str init = cmap_str_init();
- cmap_str_emplace(&cmap_cfg_insert(&config, cstr_from("user"), init).ref->second, "name", "Joe");
- cmap_str_emplace(&cmap_cfg_insert(&config, cstr_from("user"), init).ref->second, "groups", "proj1,proj3");
- cmap_str_emplace(&cmap_cfg_insert(&config, cstr_from("group"), init).ref->second, "proj1", "Energy");
- cmap_str_emplace(&cmap_cfg_insert(&config, cstr_from("group"), init).ref->second, "proj2", "Windy");
- cmap_str_emplace(&cmap_cfg_insert(&config, cstr_from("group"), init).ref->second, "proj3", "Oil");
- cmap_str_emplace(&cmap_cfg_insert(&config, cstr_from("admin"), init).ref->second, "employees", "2302");
+ cmap_str_emplace(&cmap_cfg_insert(&cfg, cstr_from("user"), init).ref->second, "name", "Joe");
+ cmap_str_emplace(&cmap_cfg_insert(&cfg, cstr_from("user"), init).ref->second, "groups", "proj1,proj3");
+ cmap_str_emplace(&cmap_cfg_insert(&cfg, cstr_from("group"), init).ref->second, "proj1", "Energy");
+ cmap_str_emplace(&cmap_cfg_insert(&cfg, cstr_from("group"), init).ref->second, "proj2", "Windy");
+ cmap_str_emplace(&cmap_cfg_insert(&cfg, cstr_from("group"), init).ref->second, "proj3", "Oil");
+ cmap_str_emplace(&cmap_cfg_insert(&cfg, cstr_from("admin"), init).ref->second, "employees", "2302");
- cmap_str_emplace_or_assign(&cmap_cfg_insert(&config, cstr_from("group"), init).ref->second, "proj2", "Wind"); // Update
+ cmap_str_emplace_or_assign(&cmap_cfg_insert(&cfg, cstr_from("group"), init).ref->second, "proj2", "Wind"); // Update
- c_foreach (i, cmap_cfg, config)
+ c_foreach (i, cmap_cfg, cfg)
c_foreach (j, cmap_str, i.ref->second)
printf("%s: %s - %s (%u)\n", i.ref->first.str, j.ref->first.str, j.ref->second.str, i.ref->second.bucket_count);
- cmap_cfg_del(&config);
+ cmap_cfg_del(&cfg);
} \ No newline at end of file