Buffer
final class Buffer
Buffer in memory.
Buffer
is used to temporarily store data in memory before writing to a
file, or after reading from a file. It follows the
JSON data model, where data is arranged
hierachically in objects (dictionaries) of key-value members, and
arrays of elements. Keys are strings. Values and elements may be strings,
reals, integers, Booleans or nulls. Special provisions are made for
efficient representation of numerical vectors and matrices. The
representation is schemaless and all types variant.
Objects (in the JSON sense) are created using set()
. Arrays (in the
JSON sense) are created using the various push()
member functions. When
push()
is called on a Buffer
it may invoke a type conversion for the
values stored in that Buffer
. Transitively, a scalar Boolean
can be
converted to an Integer
, can be converted to a Real
. Similarly, a
scalar can be converted to a vector of the same basic type. So, for
example, calling push(Real)
on a Buffer
holding an Integer
will
convert it to holding a Real[_]
(Integer
converts to Real
, scalar
converts to vector).
Factory Functions
Name | Description |
---|---|
Buffer | Create a Buffer. |
Buffer | Create a Buffer. |
Member Variables
Name | Description |
---|---|
content:Value? | Contents of the buffer. |
Member Functions
Name | Description |
---|---|
accept | Accept a generator. |
clear | Remove all entries from an object. |
find | Find an entry in an object. |
insert | Insert an entry in an object. |
insert | Insert an entry in an array. |
getBoolean | Get this as a Boolean. |
getInteger | Get this as an integer. |
getReal | Get this as a real. |
getString | Get this as a string. |
getBooleanVector | Get this as a vector of Booleans. |
getIntegerVector | Get this as a vector of integers. |
getRealVector | Get this as a vector of reals. |
getBooleanMatrix | Get this as a matrix of Booleans. |
getIntegerMatrix | Get this as a matrix of integers. |
getRealMatrix | Get this as a matrix of reals. |
getLLT | Get this as a factorized matrix. |
get | Get this as a Boolean. |
get | Get this as an integer. |
get | Get this as a real. |
get | Get this as a string. |
get | Get this as an object. |
get | Get this as a vector of Booleans. |
get | Get this as a vector of integers. |
get | Get this as a vector of reals. |
get | Get this as a matrix of Booleans. |
get | Get this as a matrix of integers. |
get | Get this as a matrix of reals. |
get | Get this as a factorized matrix. |
setNil | Set this as nil. |
set | Set this. |
set | Set this. |
set | Set this. |
set | Set this. |
set | Set this. |
set | Set this. |
set | Set this. |
set | Set this. |
set | Set this. |
set | Set this. |
set | Set this. |
set | Set this. |
set | Set this. |
set | Set this. |
getBoolean | Get an entry in an object as a Boolean. |
getInteger | Get an entry in an object as an integer. |
getReal | Get an entry in an object as a real. |
getString | Get an entry in an object as a string. |
getBooleanVector | Get an entry in an object as a vector of Booleans. |
getIntegerVector | Get an entry in an object as a vector of integers. |
getRealVector | Get an entry in an object as a vector of reals. |
getBooleanMatrix | Get an entry in an object as a matrix of Booleans. |
getIntegerMatrix | Get an entry in an object as a matrix of integers. |
getRealMatrix | Get an entry in an object as a matrix of reals. |
getLLT | Get an entry in an object as a factorized matrix. |
get | Get an entry in an object as a Boolean. |
get | Get an entry in an object as an integer. |
get | Get an entry in an object as a real. |
get | Get an entry in an object as a string. |
get | Get an entry in an object as an object. |
get | Get an entry in an object as a vector of Booleans. |
get | Get an entry in an object as a vector of integers. |
get | Get an entry in an object as a vector of reals. |
get | Get an entry in an object as a matrix of Booleans. |
get | Get an entry in an object as a matrix of integers. |
get | Get an entry in an object as a matrix of reals. |
get | Get an entry in an object as a factorized matrix. |
setNil | Set entry in an object as nil. |
set | Set an entry in an object. |
set | Set an entry in an object. |
set | Set an entry in an object. |
set | Set an entry in an object. |
set | Set an entry in an object. |
set | Set an entry in an object. |
set | Set an entry in an object. |
set | Set an entry in an object. |
set | Set an entry in an object. |
set | Set an entry in an object. |
set | Set an entry in an object. |
set | Set an entry in an object. |
set | Set an entry in an object. |
set | Set an entry in an object. |
size | Get the size of the buffer. |
size | Get the size of an entry. |
walk | Iterate through the elements of an array. |
walk | Iterate through the elements of an array entry. |
pushNil | Push a nil element onto the end of an array. |
push | Push an element onto the end of an array. |
push | Push an element onto the end of an array. |
push | Push an element onto the end of an array. |
push | Push an element onto the end of an array. |
push | Push an element onto the end of an array. |
push | Push an element onto the end of an array. |
push | Push an element onto the end of an array. |
push | Push an element onto the end of an array. |
Factory Function Details
function Buffer<Type>(root:Type) -> Buffer
Create a Buffer.
- root: Root value.
function Buffer() -> Buffer
Create a Buffer.
Member Function Details
accept
function accept(writer:Writer)
Accept a generator.
clear
function clear()
Remove all entries from an object.
find
function find(key:String) -> Buffer?
Find an entry in an object.
get
function get(value:Boolean?) -> Boolean?
Get this as a Boolean.
- value: Unused, but necessary for overload resolution.
Return: An optional with a value if this is of a compatible type.
function get(value:Integer?) -> Integer?
Get this as an integer.
- value: Unused, but necessary for overload resolution.
Return: An optional with a value if this is of a compatible type.
function get(value:Real?) -> Real?
Get this as a real.
- value: Unused, but necessary for overload resolution.
Return: An optional with a value if this is of a compatible type.
function get(value:String?) -> String?
Get this as a string.
- value: Unused, but necessary for overload resolution.
Return: An optional with a value if this is of a compatible type.
function get(value:Object?) -> Object?
Get this as an object.
- value: The object.
Return: The object.
function get(value:Boolean[_]?) -> Boolean[_]?
Get this as a vector of Booleans.
- value: Unused, but necessary for overload resolution.
Return: An optional with a value if this is an array with all elements of a compatible type.
function get(value:Integer[_]?) -> Integer[_]?
Get this as a vector of integers.
- value: Unused, but necessary for overload resolution.
Return: An optional with a value if this is an array with all elements of a compatible type.
function get(value:Real[_]?) -> Real[_]?
Get this as a vector of reals.
- value: Unused, but necessary for overload resolution.
Return: An optional with a value if this is an array with all elements of a compatible type.
function get(value:Boolean[_,_]?) -> Boolean[_,_]?
Get this as a matrix of Booleans.
- value: Unused, but necessary for overload resolution.
Return: An optional with a value if this is an array where all elements are themselves arrays of the same length and compatible type.
function get(value:Integer[_,_]?) -> Integer[_,_]?
Get this as a matrix of integers.
- value: Unused, but necessary for overload resolution.
Return: An optional with a value if this is an array where all elements are themselves arrays of the same length and compatible type.
function get(value:Real[_,_]?) -> Real[_,_]?
Get this as a matrix of reals.
- value: Unused, but necessary for overload resolution.
Return: An optional with a value if this is an array where all elements are themselves arrays of the same length and compatible type.
function get(value:LLT?) -> LLT?
Get this as a factorized matrix.
- value: Unused, but necessary for overload resolution.
Return: An optional with a value if this is an array where all elements are themselves arrays of the same length and compatible type.
function get(key:String, value:Boolean?) -> Boolean?
Get an entry in an object as a Boolean.
- key: Key of the entry.
- value: Unused, but necessary for overload resolution.
Return: An optional with a value if the given entry exists and is of a compatible type.
function get(key:String, value:Integer?) -> Integer?
Get an entry in an object as an integer.
- key: Key of the entry.
- value: Unused, but necessary for overload resolution.
Return: An optional with a value if the given entry exists and is of a compatible type.
function get(key:String, value:Real?) -> Real?
Get an entry in an object as a real.
- key: Key of the entry.
- value: Unused, but necessary for overload resolution.
Return: An optional with a value if the given entry exists and is of a compatible type.
function get(key:String, value:String?) -> String?
Get an entry in an object as a string.
- key: Key of the entry.
- value: Unused, but necessary for overload resolution.
Return: An optional with a value if the given entry exists and is of a compatible type.
function get(key:String, value:Object?) -> Object?
Get an entry in an object as an object.
- key: Key of the entry.
- value: The object.
Return: The object.
function get(key:String, value:Boolean[_]?) -> Boolean[_]?
Get an entry in an object as a vector of Booleans.
- key: Key of the entry.
- value: Unused, but necessary for overload resolution.
Return: An optional with a value if this is an array with all elements of a compatible type.
function get(key:String, value:Integer[_]?) -> Integer[_]?
Get an entry in an object as a vector of integers.
- key: Key of the entry.
- value: Unused, but necessary for overload resolution.
Return: An optional with a value if this is an array with all elements of a compatible type.
function get(key:String, value:Real[_]?) -> Real[_]?
Get an entry in an object as a vector of reals.
- key: Key of the entry.
- value: Unused, but necessary for overload resolution.
Return: An optional with a value if this is an array with all elements of a compatible type.
function get(key:String, value:Boolean[_,_]?) -> Boolean[_,_]?
Get an entry in an object as a matrix of Booleans.
- key: Key of the entry.
- value: Unused, but necessary for overload resolution.
Return: An optional with a value if this is an array where all elements are themselves arrays of the same length and compatible type.
function get(key:String, value:Integer[_,_]?) -> Integer[_,_]?
Get an entry in an object as a matrix of integers.
- key: Key of the entry.
- value: Unused, but necessary for overload resolution.
Return: An optional with a value if this is an array where all elements are themselves arrays of the same length and compatible type.
function get(key:String, value:Real[_,_]?) -> Real[_,_]?
Get an entry in an object as a matrix of reals.
- key: Key of the entry.
- value: Unused, but necessary for overload resolution.
Return: An optional with a value if this is an array where all elements are themselves arrays of the same length and compatible type.
function get(key:String, value:LLT?) -> LLT?
Get an entry in an object as a factorized matrix.
- key: Key of the entry.
- value: Unused, but necessary for overload resolution.
Return: An optional with a value if this is an array where all elements are themselves arrays of the same length and compatible type.
getBoolean
function getBoolean() -> Boolean?
Get this as a Boolean.
Return: An optional with a value if this is of a compatible type.
function getBoolean(key:String) -> Boolean?
Get an entry in an object as a Boolean.
- key: Key of the entry.
Return: An optional with a value if the given entry exists and is of a compatible type.
getBooleanMatrix
function getBooleanMatrix() -> Boolean[_,_]?
Get this as a matrix of Booleans.
Return: An optional with a value if this is an array where all elements are themselves arrays of the same length and compatible type.
function getBooleanMatrix(key:String) -> Boolean[_,_]?
Get an entry in an object as a matrix of Booleans.
- key: Key of the entry.
Return: An optional with a value if this is an array where all elements are themselves arrays of the same length and compatible type.
getBooleanVector
function getBooleanVector() -> Boolean[_]?
Get this as a vector of Booleans.
Return: An optional with a value if this is an array with all elements of a compatible type.
function getBooleanVector(key:String) -> Boolean[_]?
Get an entry in an object as a vector of Booleans.
- key: Key of the entry.
Return: An optional with a value if this is an array with all elements of a compatible type.
getInteger
function getInteger() -> Integer?
Get this as an integer.
Return: An optional with a value if this is of a compatible type.
function getInteger(key:String) -> Integer?
Get an entry in an object as an integer.
- key: Key of the entry.
Return: An optional with a value if the given entry exists and is of a compatible type.
getIntegerMatrix
function getIntegerMatrix() -> Integer[_,_]?
Get this as a matrix of integers.
Return: An optional with a value if this is an array where all elements are themselves arrays of the same length and compatible type.
function getIntegerMatrix(key:String) -> Integer[_,_]?
Get an entry in an object as a matrix of integers.
- key: Key of the entry.
Return: An optional with a value if this is an array where all elements are themselves arrays of the same length and compatible type.
getIntegerVector
function getIntegerVector() -> Integer[_]?
Get this as a vector of integers.
Return: An optional with a value if this is an array with all elements of a compatible type.
function getIntegerVector(key:String) -> Integer[_]?
Get an entry in an object as a vector of integers.
- key: Key of the entry.
Return: An optional with a value if this is an array with all elements of a compatible type.
getLLT
function getLLT() -> LLT?
Get this as a factorized matrix.
Return: An optional with a value if this is an array where all elements are themselves arrays of the same length and compatible type.
function getLLT(key:String) -> LLT?
Get an entry in an object as a factorized matrix.
- key: Key of the entry.
Return: An optional with a value if this is an array where all elements are themselves arrays of the same length and compatible type.
getReal
function getReal() -> Real?
Get this as a real.
Return: An optional with a value if this is of a compatible type.
function getReal(key:String) -> Real?
Get an entry in an object as a real.
- key: Key of the entry.
Return: An optional with a value if the given entry exists and is of a compatible type.
getRealMatrix
function getRealMatrix() -> Real[_,_]?
Get this as a matrix of reals.
Return: An optional with a value if this is an array where all elements are themselves arrays of the same length and compatible type.
function getRealMatrix(key:String) -> Real[_,_]?
Get an entry in an object as a matrix of reals.
- key: Key of the entry.
Return: An optional with a value if this is an array where all elements are themselves arrays of the same length and compatible type.
getRealVector
function getRealVector() -> Real[_]?
Get this as a vector of reals.
Return: An optional with a value if this is an array with all elements of a compatible type.
function getRealVector(key:String) -> Real[_]?
Get an entry in an object as a vector of reals.
- key: Key of the entry.
Return: An optional with a value if this is an array with all elements of a compatible type.
getString
function getString() -> String?
Get this as a string.
Return: An optional with a value if this is of a compatible type.
function getString(key:String) -> String?
Get an entry in an object as a string.
- key: Key of the entry.
Return: An optional with a value if the given entry exists and is of a compatible type.
insert
function insert(key:String, value:Buffer)
Insert an entry in an object.
function insert(value:Buffer)
Insert an entry in an array.
push
function push(value:Boolean)
Push an element onto the end of an array.
function push(value:Integer)
Push an element onto the end of an array.
function push(value:Real)
Push an element onto the end of an array.
function push(value:String)
Push an element onto the end of an array.
function push(value:Object)
Push an element onto the end of an array.
function push(value:Boolean[_])
Push an element onto the end of an array.
function push(value:Integer[_])
Push an element onto the end of an array.
function push(value:Real[_])
Push an element onto the end of an array.
pushNil
function pushNil()
Push a nil element onto the end of an array.
set
function set(value:Boolean)
Set this.
function set(value:Integer)
Set this.
function set(value:Real)
Set this.
function set(value:String)
Set this.
function set(value:Object)
Set this.
function set(value:Boolean[_])
Set this.
function set(value:Integer[_])
Set this.
function set(value:Real[_])
Set this.
function set(value:String[_])
Set this.
function set(value:Object[_])
Set this.
function set(value:Boolean[_,_])
Set this.
function set(value:Integer[_,_])
Set this.
function set(value:Real[_,_])
Set this.
function set(value:LLT)
Set this.
function set(key:String, value:Boolean)
Set an entry in an object.
- key: Key of the entry.
- value: Value of the entry.
function set(key:String, value:Integer)
Set an entry in an object.
- key: Key of the entry.
- value: Value of the entry.
function set(key:String, value:Real)
Set an entry in an object.
- key: Key of the entry.
- value: Value of the entry.
function set(key:String, value:String)
Set an entry in an object.
- key: Key of the entry.
- value: Value of the entry.
function set(key:String, value:Object)
Set an entry in an object.
- key: Key of the entry.
- value: Value of the entry.
function set(key:String, value:Boolean[_])
Set an entry in an object.
- key: Key of the entry.
- value: Value of the entry.
function set(key:String, value:Integer[_])
Set an entry in an object.
- key: Key of the entry.
- value: Value of the entry.
function set(key:String, value:Real[_])
Set an entry in an object.
- key: Key of the entry.
- value: Value of the entry.
function set(key:String, value:String[_])
Set an entry in an object.
- key: Key of the entry.
- value: Value of the entry.
function set(key:String, value:Object[_])
Set an entry in an object.
- key: Key of the entry.
- value: Value of the entry.
function set(key:String, value:Boolean[_,_])
Set an entry in an object.
- key: Key of the entry.
- value: Value of the entry.
function set(key:String, value:Integer[_,_])
Set an entry in an object.
- key: Key of the entry.
- value: Value of the entry.
function set(key:String, value:Real[_,_])
Set an entry in an object.
- key: Key of the entry.
- value: Value of the entry.
function set(key:String, value:LLT)
Set an entry in an object.
- key: Key of the entry.
- value: Value of the entry.
setNil
function setNil()
Set this as nil.
function setNil(key:String)
Set entry in an object as nil.
- key: Key of the entry.
size
function size() -> Integer
Get the size of the buffer. For an uninitialized buffer this is zero, for an array it is the array length, for anything else it is one.
function size(key:String) -> Integer
Get the size of an entry. For an uninitialized buffer this is zero, for an array it is the array length, for anything else it is one.
- key: Key of the entry.
walk
function walk() -> Iterator<Buffer>
Iterate through the elements of an array.
function walk(key:String) -> Iterator<Buffer>
Iterate through the elements of an array entry.
- key: Key of the entry.