fix: stabilize runtime follow-up regressions
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
:sig
|
||||
DTree DTree::get_by_path(String path, String delim = "/")
|
||||
DTree DTree::get_by_path(String path, String delim = "/") const
|
||||
|
||||
:params
|
||||
path : slash-delimited path to traverse
|
||||
@@ -11,16 +11,21 @@ return value : the resolved child node, or an empty `DTree` when the path cannot
|
||||
0_Request
|
||||
>types
|
||||
json_decode
|
||||
has
|
||||
to_string
|
||||
|
||||
:content
|
||||
Traverses a nested `DTree` without creating missing keys.
|
||||
Traverses a nested `DTree` without creating missing keys. This is a read accessor: it is `const` and never modifies the tree, unlike `operator[]`, which creates missing entries.
|
||||
|
||||
Empty path segments are ignored, so leading and trailing `/` characters are harmless. If any intermediate node is not a map or a segment is missing, `get_by_path()` returns an empty `DTree`.
|
||||
|
||||
A missing path therefore reads like an empty value — combine it with the `to_*` default arguments to express a fallback in one call:
|
||||
|
||||
## Example
|
||||
|
||||
```cpp
|
||||
context.cfg.get_by_path("theme/options/portal-dark/label").to_string()
|
||||
String label = context.cfg.get_by_path("theme/options/portal-dark/label").to_string("Portal Dark");
|
||||
s64 page_size = context.cfg.get_by_path("app/page_size").to_s64(25);
|
||||
```
|
||||
|
||||
## Related Concepts
|
||||
|
||||
Reference in New Issue
Block a user