cturtle/yaml
include "cturtle/yaml";
Types
yaml
Native object
string
fn string(string path) -> string
int_value
fn int_value(string path) -> int
float_value
fn float_value(string path) -> float
bool_value
fn bool_value(string path) -> bool
has infallible
infallible fn has(string path) -> bool
count infallible
infallible fn count(string path) -> int
close infallible
infallible fn close()
FileFormat
Object
A file format as your code reads it, for checking the optional format
section every cTurtle data file can carry:
format:
version: 1.0.0
See File format versions.
| Field | Type | Writable | Description |
|---|---|---|---|
file | string | yes | Names the file in error messages, for example "models.yaml". |
reads | array<string> | yes | The newest version of each major version your code reads, oldest first. The last one is the current version, which a file without format uses. |
contentVersion | bool | yes | True when a top-level version in the file is the content's own version (a game's or a plugin's) rather than an old format-version key. |
FormatVersion
Object
A file format version: MAJOR.MINOR.PATCH.
| Field | Type | Writable | Description |
|---|---|---|---|
major | int | yes | |
minor | int | yes | |
patch | int | yes |
Interfaces
DataObject
Interface
Functions
yaml_parse
fn yaml_parse(string text) -> yaml
yaml_parse_asset
fn yaml_parse_asset(string text) -> yaml
yaml_decode
fn yaml_decode(string text, DataObject target)
yaml_decode_asset
fn yaml_decode_asset(string text, DataObject target)
json_decode
fn json_decode(string text, DataObject target)
json_decode_asset
fn json_decode_asset(string text, DataObject target)
yaml_decode_defaults
fn yaml_decode_defaults(
string text,
DataObject target,
array<DataObject> defaults)
yaml_decode_asset_defaults
fn yaml_decode_asset_defaults(
string text,
DataObject target,
array<DataObject> defaults)
json_decode_defaults
fn json_decode_defaults(
string text,
DataObject target,
array<DataObject> defaults)
json_decode_asset_defaults
fn json_decode_asset_defaults(
string text,
DataObject target,
array<DataObject> defaults)
yamlFileFormat
fn yamlFileFormat(yaml document, FileFormat format) -> FormatVersion
Checks a YAML document's format against what your code reads and returns
the version the file is written in. A document without format is the
current version. Fails, with a message that names the file and says what
to change, when the version is newer than your code reads or is not a
version like 1.0.0, or when the document still has an old schema or a
top-level version key.
yamlAssetFileFormat
fn yamlAssetFileFormat(string asset, FileFormat format) -> FormatVersion
The same check as yamlFileFormat for a data file registered in the
asset registry, before you decode it with yaml_decode_asset:
yamlAssetFileFormat("engine_exhaust", particleEffectFormat())?;
yaml_decode_asset("engine_exhaust", effect)?;
jsonFileFormat
fn jsonFileFormat(json document, FileFormat format) -> FormatVersion
The same check as yamlFileFormat for a JSON document, whose format
section is written "format": {"version": "1.0.0"}.
fileFormatCheck
fn fileFormatCheck(FileFormat format, string declared) -> FormatVersion
Checks a format version you read yourself: declared is the file's
format.version, or "" when the file has no format.
assetRegistryFormat infallible
infallible fn assetRegistryFormat() -> FileFormat
The asset registry (assets.yaml) format this cTurtle reads.
actorFileFormat infallible
infallible fn actorFileFormat() -> FileFormat
The actor file format this cTurtle reads.
sceneFileFormat infallible
infallible fn sceneFileFormat() -> FileFormat
The scene file format this cTurtle reads.
gameManifestFormat infallible
infallible fn gameManifestFormat() -> FileFormat
The game.json and .ctproject format this cTurtle reads. Their top-level
version is the game's own version.
particleEffectFormat infallible
infallible fn particleEffectFormat() -> FileFormat
The .effect file format this cTurtle reads.