Skip to content
FutureBlitz

    Install

    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.

    std/core/value.fb, line 22

    • NULL enum member #

      Nothing: a null.

    • BOOL enum member #

      A Bool.

    • INT enum member #

      An integer, as an Int64.

    • UINT enum member #

      An integer past an Int64's largest, as a UInt64.

    • DOUBLE enum member #

      A Double.

    • STRING enum member #

      A String.

    • BYTES enum member #

      Bytes, as a UInt8[].

    • ARRAY enum member #

      An Array of Values.

    • OBJECT enum member #

      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.

    std/core/value.fb, line 46

    • Public New() constructor #

      Null.

    • Public New(value: Bool) constructor #

      A Bool's Value.

    • Public New(value: Int8) constructor #

      An integer of any size, which each type has a New of its own for, so none is ambiguous.

    • Public New(value: Int16) constructor #

      An integer's Value.

    • Public New(value: Int32) constructor #

      An integer's Value.

    • Public New(value: Int64) constructor #

      An integer's Value.

    • Public New(value: UInt8) constructor #

      An integer's Value.

    • Public New(value: UInt16) constructor #

      An integer's Value.

    • Public New(value: UInt32) constructor #

      An integer's Value.

    • Public New(value: UInt64) constructor #

      An integer's Value, which is a UInt when it's too large for an Int64.

    • Public New(value: Double) constructor #

      A Double. A Float converts to one, and a decimal literal is read as one.

    • Public New(value: String) constructor #

      A String's Value.

    • Public New(bytes: UInt8[]) constructor #

      Bytes, a copy of them.

    • Public New(elements: Value[]) constructor #

      An Array of the Values, in a new array of its own.

    • Public New(entries: Map<String, Value>) constructor #

      An Object of the Map's keys and Values, in its order, in a new Map of its own.

    • Public Static Method Array(): Value static method #

      A new, empty Array, to add to.

    • Public Static Method Object(): Value static method #

      A new, empty Object.

    • Public Property Kind: ValueKind property #

      Which of the kinds it is.

    • Public Property IsNull: Bool property #

      Whether it's Null.

    • Public Property IsBool: Bool property #

      Whether it's a Bool.

    • Public Property IsInteger: Bool property #

      An INT or UINT, and a number, those or a DOUBLE.

    • Public Property IsNumber: Bool property #

      Whether it's a number: an integer or a Double.

    • Public Property IsString: Bool property #

      Whether it's a String.

    • Public Property IsBytes: Bool property #

      Whether it's bytes.

    • Public Property IsArray: Bool property #

      Whether it's an Array.

    • Public Property IsObject: Bool property #

      Whether it's an Object.

    • Public Property Count: Int property #

      How many elements an Array has, entries an Object has, or bytes it holds; 0 for the rest.

    • Public Method AsBool(): Bool? method #

      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.

    • Public Method AsInt(): Int? method #

      An integer that fits in an Int, or Null for anything else.

    • Public Method AsInt64(): Int64? method #

      An integer that fits in an Int64, or Null for anything else.

    • Public Method AsUInt64(): UInt64? method #

      An integer that fits in a UInt64, or Null for anything else.

    • Public Method AsDouble(): Double? method #

      A number as a Double, or Null for anything else.

    • Public Method AsString(): String? method #

      A String's text, or Null for anything else.

    • Public Method AsBytes(): UInt8[]? method #

      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.

    • Public Method AsArray(): Value[]? method #

      An Array's elements, in a new array of the Value's own elements, or Null for anything else.

    • Public Method Keys(): String[] method #

      An Object's keys, in order, in a new array; none for the rest.

    • Public Method Contains(key: String): Bool method #

      Whether an Object has the key.

    • Operator [](key: String): Value? operator #

      An Object's Value for the key, or Null where it has none.

    • Operator [](index: Int): Value? operator #

      An Array's Value at the index, or Null where it has none.

    • @PanicsAtCaller Public Method Path(path: String): Value? method #

      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]".

    • @PanicsAtCaller Operator []=(key: String, value: Value) operator #

      Gives an Object's key the value, adding the key when it isn't there. Panics on another kind, or for a value that is this one or holds it.

    • @PanicsAtCaller Operator []=(index: Int, value: Value) operator #

      Replaces an Array's element at the index with value. Panics on another kind, at an index past the Array's, or for a value that is this one or holds it.

    • @PanicsAtCaller Public Method Add(value: Value) method #

      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.

    • @PanicsAtCaller Public Method Insert(index: Int, value: Value) method #

      Puts value in an Array at index, 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.

    • @PanicsAtCaller Public Method RemoveAt(index: Int) method #

      Takes the element at index out of an Array. Panics on another kind, and at an index that isn't in it.

    • @PanicsAtCaller Public Method Remove(key: String): Bool method #

      Removes an Object's key, and tells whether it had one. Panics on another kind.

    • Public Method Clone(): Value method #

      Copies it, and its elements and entries, whole. A Value held in several places is copied once for each place.

    • Operator ==(a: Value, b: Value): Bool operator #

      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.

    • Public Method Hash(): UInt64 method #

      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.

    • Public Method ToString(): String method #

      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.