Skip to content

Serialize

Documentation for std-library/nodes/components/serialize.ksp

Import

import "_IVLS/std-library/nodes/components/serialize.ksp"

Node: Stl.Serialize

Uses: Init, PreReload, AsyncResponse

Constants

Constant Value Description
serial.GLOBAL_HEADER_SIZE 8 integer
serial.SYSTEM_HEADER_SIZE 8 integer

API

Nodes

Name Description
node Stl.Serialize Serialization coordinator node managing save/load for all registered serial syst...

Defines

Name Description
define SERIAL.GLOBAL_HEADER(#par#) Read a value from the global header section of the serial memory array.
define SERIAL.SYSTEM_HEADER(#_p#, #par#) Read a value from a system header at a given memory position.

Const Blocks

Name Description
const global_header Field offsets within the global header block of the memory array.
const id System ID values indexed by serial system name; populated via literate macro.
const nka_mode NKA file-mode selector constants (DIALOG, DATA_DIR, PATH).
const system_header Field offsets within each per-system header block of the memory array.
const systems Ordered list of registered serial system names, one per STL.SERIALS entry.

Macros

Name Description
Stl.Serialize.FillHeader(#sys#, #w_p#) Writes the system header fields for one serial system into the memory array at ...
Stl.Serialize.ReadFromMemory(#sys#, #r_p#) Deserializes one system's data from the global memory array by matching system I...
Stl.Serialize.SnapCase(#i#, #sys#) Loads or locks a serial system snapshot on pre-reload based on save and lock sta...
Stl.Serialize.WriteToMemory(#sys#, #w_p#) Serializes one system's header and payload into the global memory array at the c...

Functions

Name Description
serial.load_from_data_dir(name) Begin an async load of a named NKA file from the data directory.
serial.load_from_path(path) Begin an async load of the serial memory array from an explicit file path.
serial.load_from_resource() Load the serial memory array from the embedded resource (NKA slot 2).
serial.load_via_dialog() Open a native file-open dialog and begin an async load of the serial memory arra...
serial.read_from_memory() Deserializes all registered serial systems from the global memory array.
serial.save_to_data_dir(name) Serialize all systems to memory and save to a named file in the data directory.
serial.save_to_path(path) Serialize all systems to memory and save to an explicit file path.
serial.save_via_dialog() Serialize all systems to memory and open a native file-save dialog.
serial.write_to_memory() Serializes all registered serial systems into the global memory array.

Stl.Serialize

node Stl.Serialize

Callbacks: Init, PreReload, AsyncResponse

Serialization coordinator node managing save/load for all registered serial systems.


const systems

Ordered list of registered serial system names, one per STL.SERIALS entry.


const id

System ID values indexed by serial system name; populated via literate macro.


const global_header

Field offsets within the global header block of the memory array.


const system_header

Field offsets within each per-system header block of the memory array.


const nka_mode

NKA file-mode selector constants (DIALOG, DATA_DIR, PATH).


define SERIAL.GLOBAL_HEADER(#par#)

Read a value from the global header section of the serial memory array.

Parameter Description
#par# Global header field constant name (e.g. NUM_SYSTEMS).

define SERIAL.SYSTEM_HEADER(#_p#, #par#)

Read a value from a system header at a given memory position.

Parameter Description
#_p# Base memory offset of the system header block.
#par# System header field constant name (e.g. SYSTEM_ID).

Stl.Serialize.SnapCase(#i#, #sys#)

Loads or locks a serial system snapshot on pre-reload based on save and lock state.

Parameter Description
#i# Zero-based index into save_stored and lock_enabled arrays for this system.
#sys# Serial system name used to invoke virtual methods.

Stl.Serialize.FillHeader(#sys#, #w_p#)

Writes the system header fields for one serial system into the memory array at #w_p#.

Parameter Description
#sys# Serial system name used to invoke virtual methods.
#w_p# Memory write pointer variable; points to the start of the system header slot.

Stl.Serialize.WriteToMemory(#sys#, #w_p#)

Serializes one system's header and payload into the global memory array at the current write pointer.

Parameter Description
#sys# Serial system name used to invoke virtual methods.
#w_p# Memory write pointer variable; advanced by SYSTEM_HEADER_SIZE + data length on success.

Stl.Serialize.ReadFromMemory(#sys#, #r_p#)

Deserializes one system's data from the global memory array by matching system ID.

Parameter Description
#sys# Serial system name used to invoke virtual methods.
#r_p# Memory read pointer variable; advanced by SYSTEM_HEADER_SIZE + block length for each scanned block.

serial.save_via_dialog()

Serialize all systems to memory and open a native file-save dialog.


serial.save_to_data_dir(name)

Serialize all systems to memory and save to a named file in the data directory.

Parameter Type Description
name string Filename (without extension) written under data.base_path as .nka.

serial.save_to_path(path)

Serialize all systems to memory and save to an explicit file path.

Parameter Type Description
path string Absolute file path to write the serialized memory array to.

serial.load_via_dialog()

Open a native file-open dialog and begin an async load of the serial memory array.


serial.load_from_resource()

Load the serial memory array from the embedded resource (NKA slot 2).


serial.load_from_data_dir(name)

Begin an async load of a named NKA file from the data directory.

Parameter Type Description
name string Filename (without extension) read from data.base_path as .nka.

serial.load_from_path(path)

Begin an async load of the serial memory array from an explicit file path.

Parameter Type Description
path string Absolute file path to read the serialized memory array from.

serial.write_to_memory()

Serializes all registered serial systems into the global memory array.

Side effects:

Name Type Purpose
transfer integer Loop counter for per-element memory copy (macro local)
length integer Payload length for the current system (macro local)
systems_written integer Count of successfully serialized systems
w_p integer Write pointer; initialized to GLOBAL_HEADER_SIZE

serial.read_from_memory()

Deserializes all registered serial systems from the global memory array.

Side effects:

Name Type Purpose
block_i integer Loop index over global header block count
system integer System ID for the current serial system
system_length integer Expected payload length for the current system
system_check integer System ID read from the current memory block
system_check_length integer Data length read from the current memory block
system_check_version integer Version read from the current memory block
system_check_save_stored integer Save-stored flag read from the current memory block
transfer integer Loop counter for per-element memory copy (macro local)
r_p integer Read pointer; initialized to GLOBAL_HEADER_SIZE

Example

// TODO: Add usage example

See Also