Generic storage

This module provides generic storage for various types of data. The data is stored in a table, with the name as the key and the value as the data. The value can be one of the following types: int, int4, int3, int2, uint, uint64, float, float4, float3, float2, string, array<int4>, array<float>, array<float2>, array<float3>, array<float4>, or array<string>.

To use this module, include the following line in your project file:

require engine.serializer.generic_storage // or require engine.core

To access the data, use the set and get functions. For example:

var data : GenericStorage
set(set(data, "int_val", 42), "float_val", 3.14)
<...>
get_or(data, "int_val", 0) // returns 42
var float_val : float
get(data, "float_val", float_val) // returns true and sets float_val to 3.14

Type aliases

variant GenericStorageData

Represents a variant type for storing various types of data.

Variants:
  • i4 : int4 - The int4 value

  • f4 : float4 - The float4 value

  • str : string - The string value

  • _i4 : array<int4> - The array of int4 values

  • _f1 : array<float> - The array of float values

  • _f2 : array<float2> - The array of float2 values

  • _f3 : array<float3> - The array of float3 values

  • _f4 : array<float4> - The array of float4 values

  • _str : array<string> - The array of string values

Structures

GenericStorage

Represents a generic storage for storing various types of data.

Fields:

Functions

clear(req: GenericStorage)

Clears the generic storage by deleting all the stored data.

Arguments:
set(req: GenericStorage; name: string; val: float): GenericStorage&

Sets a float value in the generic storage with the specified name.

Arguments:
  • req : GenericStorage - the generic storage

  • name : string - the name of the value

  • val : float - the float value to set

Returns:
set(req: GenericStorage; name: string; val: int): GenericStorage&

Sets an int value in the generic storage with the specified name.

Arguments:
  • req : GenericStorage - the generic storage

  • name : string - the name of the value

  • val : int - the int value to set

Returns:
set(req: GenericStorage; name: string; val: int64): GenericStorage&

Sets an int64 value in the generic storage with the specified name.

Arguments:
  • req : GenericStorage - the generic storage

  • name : string - the name of the value

  • val : int64 - the int64 value to set

Returns:
set(req: GenericStorage; name: string; val: uint): GenericStorage&

Sets a uint value in the generic storage with the specified name.

Arguments:
  • req : GenericStorage - the generic storage

  • name : string - the name of the value

  • val : uint - the uint value to set

Returns:
set(req: GenericStorage; name: string; val: uint64): GenericStorage&

Sets a uint64 value in the generic storage with the specified name.

Arguments:
  • req : GenericStorage - the generic storage

  • name : string - the name of the value

  • val : uint64 - the uint64 value to set

Returns:
set(req: GenericStorage; name: string; val: string): GenericStorage&

Sets a string value in the generic storage with the specified name.

Arguments:
  • req : GenericStorage - the generic storage

  • name : string - the name of the value

  • val : string - the string value to set

Returns:
set(req: GenericStorage; name: string; val: float4): GenericStorage&

Sets a float4 value in the generic storage with the specified name.

Arguments:
  • req : GenericStorage - the generic storage

  • name : string - the name of the value

  • val : float4 - the float4 value to set

Returns:
set(req: GenericStorage; name: string; val: int4): GenericStorage&

Sets an int4 value in the generic storage with the specified name.

Arguments:
  • req : GenericStorage - the generic storage

  • name : string - the name of the value

  • val : int4 - the int4 value to set

Returns:
set(req: GenericStorage; name: string; val: float3): GenericStorage&

Sets a float3 value in the generic storage with the specified name.

Arguments:
  • req : GenericStorage - the generic storage

  • name : string - the name of the value

  • val : float3 - the float3 value to set

Returns:
set(req: GenericStorage; name: string; val: int3): GenericStorage&

Sets an int3 value in the generic storage with the specified name.

Arguments:
  • req : GenericStorage - the generic storage

  • name : string - the name of the value

  • val : int3 - the int3 value to set

Returns:
set(req: GenericStorage; name: string; val: float2): GenericStorage&

Sets a float2 value in the generic storage with the specified name.

Arguments:
  • req : GenericStorage - the generic storage

  • name : string - the name of the value

  • val : float2 - the float2 value to set

Returns:
set(req: GenericStorage; name: string; val: int2): GenericStorage&

Sets an int2 value in the generic storage with the specified name.

Arguments:
  • req : GenericStorage - the generic storage

  • name : string - the name of the value

  • val : int2 - the int2 value to set

Returns:
set(req: GenericStorage; name: string; val: bool): GenericStorage&

Sets a bool value in the generic storage with the specified name.

Arguments:
  • req : GenericStorage - the generic storage

  • name : string - the name of the value

  • val : bool - the bool value to set

Returns:
set(req: GenericStorage; name: string; val: array<float>): GenericStorage&

Sets an array of float values in the generic storage with the specified name.

Arguments:
  • req : GenericStorage - the generic storage

  • name : string - the name of the value

  • val : array<float> - the array of float values to set

Returns:
set(req: GenericStorage; name: string; val: array<float2>): GenericStorage&

Sets an array of float2 values in the generic storage with the specified name.

Arguments:
  • req : GenericStorage - the generic storage

  • name : string - the name of the value

  • val : array<float2> - the array of float2 values to set

Returns:
set(req: GenericStorage; name: string; val: array<float3>): GenericStorage&

Sets an array of float3 values in the generic storage with the specified name.

Arguments:
  • req : GenericStorage - the generic storage

  • name : string - the name of the value

  • val : array<float3> - the array of float3 values to set

Returns:
set(req: GenericStorage; name: string; val: array<float4>): GenericStorage&

Sets an array of float4 values in the generic storage with the specified name.

Arguments:
  • req : GenericStorage - the generic storage

  • name : string - the name of the value

  • val : array<float4> - the array of float4 values to set

Returns:
set(req: GenericStorage; name: string; val: array<int4>): GenericStorage&

Sets an array of int4 values in the generic storage with the specified name.

Arguments:
  • req : GenericStorage - the generic storage

  • name : string - the name of the value

  • val : array<int4> - the array of int4 values to set

Returns:
set(req: GenericStorage; name: string; val: array<string>): GenericStorage&

Sets an array of string values in the generic storage with the specified name.

Arguments:
  • req : GenericStorage - the generic storage

  • name : string - the name of the value

  • val : array<string> - the array of string values to set

Returns:
empty(req: GenericStorage|GenericStorage#): bool

Checks if the generic storage is empty.

Arguments:
Returns:
  • bool - true if the generic storage is empty, false otherwise

keys(req: GenericStorage|GenericStorage#): iterator<string const&>

Returns an iterator over the keys in the generic storage.

Arguments:
Returns:
  • iterator<string&> - an iterator over the keys in the generic storage

has(req: GenericStorage|GenericStorage#; name: string): bool

Checks if the generic storage has a value with the specified name.

Arguments:
Returns:
  • bool - true if the generic storage has a value with the specified name, false otherwise

get_or(req: GenericStorage|GenericStorage#; name: string; def_val: auto(T)): T

Gets the value with the specified name from the generic storage. If the value does not exist, returns the default value.

Arguments:
  • req : option< GenericStorage | GenericStorage #> - the generic storage

  • name : string - the name of the value

  • def_val : auto(T) - the default value to return if the value does not exist

Returns:
  • T - the value from the generic storage or the default value

get(req: GenericStorage|GenericStorage#; name: string; val: float&): bool

Gets a float value from the generic storage with the specified name.

Arguments:
  • req : option< GenericStorage | GenericStorage #> - the generic storage

  • name : string - the name of the value

  • val : float& - the variable to store the value

Returns:
  • bool - true if the value exists and is successfully retrieved, false otherwise

get(req: GenericStorage|GenericStorage#; name: string; val: int&): bool

Gets an int value from the generic storage with the specified name.

Arguments:
  • req : option< GenericStorage | GenericStorage #> - the generic storage

  • name : string - the name of the value

  • val : int& - the variable to store the value

Returns:
  • bool - true if the value exists and is successfully retrieved, false otherwise

get(req: GenericStorage|GenericStorage#; name: string; val: int64&): bool

Gets an int64 value from the generic storage with the specified name.

Arguments:
  • req : option< GenericStorage | GenericStorage #> - the generic storage

  • name : string - the name of the value

  • val : int64& - the variable to store the value

Returns:
  • bool - true if the value exists and is successfully retrieved, false otherwise

get(req: GenericStorage|GenericStorage#; name: string; val: uint&): bool

Gets a uint value from the generic storage with the specified name.

Arguments:
  • req : option< GenericStorage | GenericStorage #> - the generic storage

  • name : string - the name of the value

  • val : uint& - the variable to store the value

Returns:
  • bool - true if the value exists and is successfully retrieved, false otherwise

get(req: GenericStorage|GenericStorage#; name: string; val: uint64&): bool

Gets a uint64 value from the generic storage with the specified name.

Arguments:
  • req : option< GenericStorage | GenericStorage #> - the generic storage

  • name : string - the name of the value

  • val : uint64& - the variable to store the value

Returns:
  • bool - true if the value exists and is successfully retrieved, false otherwise

get(req: GenericStorage|GenericStorage#; name: string; val: string&): bool

Gets a string value from the generic storage with the specified name.

Arguments:
  • req : option< GenericStorage | GenericStorage #> - the generic storage

  • name : string - the name of the value

  • val : string& - the variable to store the value

Returns:
  • bool - true if the value exists and is successfully retrieved, false otherwise

get(req: GenericStorage|GenericStorage#; name: string; val: float4&): bool

Gets a float4 value from the generic storage with the specified name.

Arguments:
  • req : option< GenericStorage | GenericStorage #> - the generic storage

  • name : string - the name of the value

  • val : float4& - the variable to store the value

Returns:
  • bool - true if the value exists and is successfully retrieved, false otherwise

get(req: GenericStorage|GenericStorage#; name: string; val: int4&): bool

Gets an int4 value from the generic storage with the specified name.

Arguments:
  • req : option< GenericStorage | GenericStorage #> - the generic storage

  • name : string - the name of the value

  • val : int4& - the variable to store the value

Returns:
  • bool - true if the value exists and is successfully retrieved, false otherwise

get(req: GenericStorage|GenericStorage#; name: string; val: float3&): bool

Gets a float3 value from the generic storage with the specified name.

Arguments:
  • req : option< GenericStorage | GenericStorage #> - the generic storage

  • name : string - the name of the value

  • val : float3& - the variable to store the value

Returns:
  • bool - true if the value exists and is successfully retrieved, false otherwise

get(req: GenericStorage|GenericStorage#; name: string; val: int3&): bool

Gets an int3 value from the generic storage with the specified name.

Arguments:
  • req : option< GenericStorage | GenericStorage #> - the generic storage

  • name : string - the name of the value

  • val : int3& - the variable to store the value

Returns:
  • bool - true if the value exists and is successfully retrieved, false otherwise

get(req: GenericStorage|GenericStorage#; name: string; val: float2&): bool

Gets a float2 value from the generic storage with the specified name.

Arguments:
  • req : option< GenericStorage | GenericStorage #> - the generic storage

  • name : string - the name of the value

  • val : float2& - the variable to store the value

Returns:
  • bool - true if the value exists and is successfully retrieved, false otherwise

get(req: GenericStorage|GenericStorage#; name: string; val: int2&): bool

Gets an int2 value from the generic storage with the specified name.

Arguments:
  • req : option< GenericStorage | GenericStorage #> - the generic storage

  • name : string - the name of the value

  • val : int2& - the variable to store the value

Returns:
  • bool - true if the value exists and is successfully retrieved, false otherwise

get(req: GenericStorage|GenericStorage#; name: string; val: bool&): bool

Gets a bool value from the generic storage with the specified name.

Arguments:
  • req : option< GenericStorage | GenericStorage #> - the generic storage

  • name : string - the name of the value

  • val : bool& - the variable to store the value

Returns:
  • bool - true if the value exists and is successfully retrieved, false otherwise

get(req: GenericStorage|GenericStorage#; name: string; val: array<float>): bool

Gets an array of float values from the generic storage with the specified name.

Arguments:
  • req : option< GenericStorage | GenericStorage #> - the generic storage

  • name : string - the name of the value

  • val : array<float>& - the variable to store the array of float values

Returns:
  • bool - true if the value exists and is successfully retrieved, false otherwise

get(req: GenericStorage|GenericStorage#; name: string; val: array<float2>): bool

Gets an array of float2 values from the generic storage with the specified name.

Arguments:
  • req : option< GenericStorage | GenericStorage #> - the generic storage

  • name : string - the name of the value

  • val : array<float2>& - the variable to store the array of float2 values

Returns:
  • bool - true if the value exists and is successfully retrieved, false otherwise

get(req: GenericStorage|GenericStorage#; name: string; val: array<float3>): bool

Gets an array of float3 values from the generic storage with the specified name.

Arguments:
  • req : option< GenericStorage | GenericStorage #> - the generic storage

  • name : string - the name of the value

  • val : array<float3>& - the variable to store the array of float3 values

Returns:
  • bool - true if the value exists and is successfully retrieved, false otherwise

get(req: GenericStorage|GenericStorage#; name: string; val: array<float4>): bool

Gets an array of float4 values from the generic storage with the specified name.

Arguments:
  • req : option< GenericStorage | GenericStorage #> - the generic storage

  • name : string - the name of the value

  • val : array<float4>& - the variable to store the array of float4 values

Returns:
  • bool - true if the value exists and is successfully retrieved, false otherwise

get(req: GenericStorage|GenericStorage#; name: string; val: array<int4>): bool

Gets an array of int4 values from the generic storage with the specified name.

Arguments:
  • req : option< GenericStorage | GenericStorage #> - the generic storage

  • name : string - the name of the value

  • val : array<int4>& - the variable to store the array of int4 values

Returns:
  • bool - true if the value exists and is successfully retrieved, false otherwise

get(req: GenericStorage|GenericStorage#; name: string; val: array<string>): bool

Gets an array of string values from the generic storage with the specified name.

Arguments:
  • req : option< GenericStorage | GenericStorage #> - the generic storage

  • name : string - the name of the value

  • val : array<string>& - the variable to store the array of string values

Returns:
  • bool - true if the value exists and is successfully retrieved, false otherwise

to_string(req: GenericStorage|GenericStorage#): string

Converts the GenericStorage object to a string representation.

Arguments:
Returns:
  • string - the string representation of the GenericStorage object

to_string(req: GenericStorage|GenericStorage#; cb: block<(res:string#):void>): bool

Converts the GenericStorage object to a string representation and calls the provided block with the result.

Arguments:
Returns:
  • bool - true if the conversion is successful, false otherwise

GenericStorage(str: string|string#): GenericStorage

Constructs a GenericStorage object from a string representation.

Arguments:
  • str : option<string|string#> - the string representation of the GenericStorage object

Returns: