Documentation
¶
Overview ¶
Package datatable reads UE5 DataTable exports — the canonical designer-authored tabular format. Supports both JSON exports (one object per row, keyed by row name) and CSV exports (header row + body).
Callers declare a Go struct matching the DataTable's row schema; the parser unmarshals each row into a typed Table[T]. The optional Watcher reloads on file changes for hot-reload during dev.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrMalformedJSON = errors.New("datatable: malformed JSON export") ErrMalformedCSV = errors.New("datatable: malformed CSV export") ErrMissingRowKey = errors.New("datatable: row missing key column") )
Errors surfaced by the parsers.
Functions ¶
This section is empty.
Types ¶
type Table ¶
Table is a typed view over a DataTable export.
func ParseCSV ¶
ParseCSV decodes the CSV variant of a DataTable export. The first column is the row key; remaining columns map to fields on T by header name (respecting `csv:"FieldName"` tag, then `json:"…"` tag, then exported field name).
func ParseJSON ¶
ParseJSON decodes UE5's JSON DataTable export. UE5 emits an array of objects where each object's `Name` field is the row key (when "Export As: JSON" is used from the editor). To stay compatible with our own export pipeline (§71), the parser also accepts the simpler `{ "RowName": { ...row fields... } }` map shape.
type Watcher ¶
type Watcher[T any] struct { // contains filtered or unexported fields }
Watcher polls a file for modification-time changes and reparses on change. Suited for dev hot-reload, not production: production should rely on §46 kit/content packs (immutable + hashed).
func Watch ¶
func Watch[T any](path string, parser func(io.Reader) (*Table[T], error), interval time.Duration) (*Watcher[T], error)
Watch starts a Watcher on `path`. The file is parsed eagerly; the returned Watcher polls every `interval` for changes (defaults to 500ms when zero). Call Close to stop polling.