Raven Engine v0.1
A modern 3D Game Engine
Loading...
Searching...
No Matches
Raven::ScriptFieldSerializer Struct Reference

Converts reflected script fields between their in-memory representation and a string form. More...

#include <ScriptFieldSerializer.h>

Static Public Member Functions

static std::string Read (void *instance, const VariableData &member)
 Reads a reflected field from a live script instance into a string.
static void Write (void *instance, const VariableData &member, const std::string &value)
 Writes a string value into a reflected field of a live script instance.

Detailed Description

Converts reflected script fields between their in-memory representation and a string form.

Used by ScriptRuntime to persist inspector-edited field values across hot-reloads and scene serialisation. The string encoding is intentionally simple: scalars use std::to_string / std::stof, vectors are comma-separated component lists (e.g. "1.0,2.0,3.0").

Member Function Documentation

◆ Read()

std::string Raven::ScriptFieldSerializer::Read ( void * instance,
const VariableData & member )
static

Reads a reflected field from a live script instance into a string.

The field is located by applying member.Offset to the instance pointer. Unrecognised TypeCategory values produce an empty string.

Parameters
instanceRaw pointer to the script object (ScriptBase derived).
memberReflection metadata describing the field's type and offset.
Returns
String representation of the field value, or an empty string if the category is unsupported.

◆ Write()

void Raven::ScriptFieldSerializer::Write ( void * instance,
const VariableData & member,
const std::string & value )
static

Writes a string value into a reflected field of a live script instance.

Parsing errors from std::stof / std::stoi are silently swallowed; the field is left unchanged if the conversion throws. Vec2 / Vec3 / Vec4 writes are skipped if the parsed component count is insufficient.

Parameters
instanceRaw pointer to the script object (ScriptBase derived).
memberReflection metadata describing the field's type and offset.
valueString to parse and write into the field.

The documentation for this struct was generated from the following files: