fix: stabilize runtime follow-up regressions
This commit is contained in:
1 parent
7f757654b6
commit
20db669589
37 files changed
+906
-144
No files matched your search
@@ -1,5 +1,9 @@
|
||||
:sig
|
||||
u64 DTree::to_u64()
|
||||
u64 DTree::to_u64(u64 default_value = 0) const
|
||||
|
||||
:params
|
||||
default_value : returned when the value is missing or cannot be parsed as a number
|
||||
return value : the value as an unsigned 64-bit integer, or `default_value`
|
||||
|
||||
:see
|
||||
>types
|
||||
@@ -7,11 +11,32 @@ u64 DTree::to_u64()
|
||||
json_decode
|
||||
int_val
|
||||
to_bool
|
||||
to_s64
|
||||
to_f64
|
||||
|
||||
:content
|
||||
Reads a `DTree` value as an unsigned integer.
|
||||
Reads a `DTree` value as an unsigned integer. This is a read accessor: it is `const`, never creates or modifies nodes, and dereferences internal references automatically.
|
||||
|
||||
String values are parsed numerically. Boolean values become `1` or `0`. Negative values clamp to `0`.
|
||||
String values are trimmed and parsed permissively, like `to_s64()`. Boolean values become `1` or `0`. Negative values clamp to `0`, and results above the `u64` range clamp to the maximum.
|
||||
|
||||
`default_value` is returned when:
|
||||
|
||||
- the node is unset or holds an empty string
|
||||
- the string does not parse as a number
|
||||
- the node is map-shaped with more than one entry, or an unresolvable reference
|
||||
|
||||
A map-shaped node with exactly one entry unwraps to that entry's value before converting. Note that a *present* negative value clamps to `0` rather than returning the default — the default signals "missing or unparseable", not "out of range".
|
||||
|
||||
## Example
|
||||
|
||||
```cpp
|
||||
u64 limit = context.get["limit"].to_u64(50);
|
||||
u64 owner_id = row.get_by_path("owner/id").to_u64();
|
||||
```
|
||||
|
||||
Use this for counts, identifiers, limits, timestamps, and other non-negative numeric values stored inside a `DTree`.
|
||||
|
||||
## Related Concepts
|
||||
|
||||
- PHP: `intval()` with a fallback
|
||||
- JavaScript: `parseInt(x) || fallback` (within unsigned range)
|
||||
Reference in new issue
Block a user