Import std.core.value
std.core.value
Value: data of any shape, as the data formats have it: Null, a Bool, an integer, a Double, a String, bytes, an Array of Values, or an Object of Values by their keys, in the order they were added. Each format reads its text into one and writes one out. A Value is an object, so a change to an Array's or Object's shows through every reference to it, and Clone() copies one whole. None holds itself, inside it however deep, though one can sit in several places, where a change to it shows in each; ToString, ==, Hash, and Clone go through each place, however deep, without recursing.
std/core/value.fb
Types
ValueKind
enum
Public Enum ValueKind
What a Value holds.
-
Nothing: a null.
-
A Bool.
-
An integer, as an Int64.
-
An integer past an Int64's largest, as a UInt64.
-
A Double.
-
A String.
-
Bytes, as a UInt8[].
-
An Array of Values.
-
An Object, of keys and their Values.
Value
class
Public Class Value Implements Equatable, Hashable, Printable, Cloneable
A value of JSON, MessagePack, TOML, and the other formats, which Load reads types from and Save writes them to: Null, a Bool, an integer, a Double, a String, bytes, an Array, or an Object of keys.
-
Null.
-
A Bool's Value.
-
An integer of any size, which each type has a New of its own for, so none is ambiguous.
-
An integer's Value.
-
An integer's Value.
-
An integer's Value.
-
An integer's Value.
-
An integer's Value.
-
An integer's Value.
-
An integer's Value, which is a UInt when it's too large for an Int64.
-
A Double. A Float converts to one, and a decimal literal is read as one.
-
A String's Value.
-
Bytes, a copy of them.
-
An Array of the Values, in a new array of its own.
-
An Object of the Map's keys and Values, in its order, in a new Map of its own.
-
A new, empty Array, to add to.
-
A new, empty Object.
-
Which of the kinds it is.
-
Whether it's Null.
-
Whether it's a Bool.
-
An INT or UINT, and a number, those or a DOUBLE.
-
Whether it's a number: an integer or a Double.
-
Whether it's a String.
-
Whether it's bytes.
-
Whether it's an Array.
-
Whether it's an Object.
-
How many elements an Array has, entries an Object has, or bytes it holds; 0 for the rest.
-
What it holds as each type, or Null when it holds another kind. An integer is a Double too, the nearest there is, and an Int32 or Int64 when it fits.
-
An integer that fits in an Int, or Null for anything else.
-
An integer that fits in an Int64, or Null for anything else.
-
An integer that fits in a UInt64, or Null for anything else.
-
A number as a Double, or Null for anything else.
-
A String's text, or Null for anything else.
-
The bytes, in a copy, or an Array's elements, in a new array of the Value's own elements: adding to it or taking from it doesn't change the Value, but a change to an element does.
-
An Array's elements, in a new array of the Value's own elements, or Null for anything else.
-
An Object's keys, in order, in a new array; none for the rest.
-
Whether an Object has the
key. -
An Object's Value for the
key, or Null where it has none. -
An Array's Value at the
index, or Null where it has none. -
The Value a path names, like "server.ports[0].name": keys after dots and indices in brackets, each step into what the last gave, or Null where one has nothing. "" is the Value itself. Panics for text that isn't a path, like "a..b" or "a[x]".
-
Gives an Object's
keythevalue, adding the key when it isn't there. Panics on another kind, or for avaluethat is this one or holds it. -
Replaces an Array's element at the
indexwithvalue. Panics on another kind, at an index past the Array's, or for avaluethat is this one or holds it. -
Adds a Value at an Array's end, or at index, moving those from there up. Panics on another kind, and for a value that is this one or holds it, as []= does.
-
Puts
valuein an Array atindex, moving the ones from there on up. Panics on another kind, at an index past its end, and for a value that is this one or holds it. -
Takes the element at
indexout of an Array. Panics on another kind, and at an index that isn't in it. -
Removes an Object's
key, and tells whether it had one. Panics on another kind. -
Copies it, and its elements and entries, whole. A Value held in several places is copied once for each place.
-
Two Values are equal when they're the same kind and hold the same: an Object the same keys with equal Values, in any order. A Double compares as Doubles do, so NaN isn't equal to itself and 0.0 is -0.0.
-
The same for equal Values, an Object's in any order. Each Array or Object on the way down keeps what it's added up so far, and adds what each element or entry comes to.
-
As JSON writes it, on one line: null, true, 42, 1.5, "text" with JSON's escapes, [1, 2], and {"key": 1}; a Double always with a point or an exponent, as 1.0; and, as JSON has no bytes, bytes in hex between angle brackets, as <0a1b>. A Value held in several places is written in each.
Report an issue with this page or with FutureBlitz on GitHub.