UCE Docs / DValue::get_or_create

Signature

DValue* DValue::get_or_create(String s)

Parameters

s : child key to create or return
return value : pointer to the child node

Ensures the value is map-shaped and returns the named child. If the key does not exist, an empty child is created. Creating a non-numeric key on a list-shaped value clears list mode.

Example

DValue config;
config.get_or_create("host")->set("localhost");
print(config.has("host") ? config["host"].to_string() : "missing", "\n");
Output
localhost