Contents

namespace

SushiAI::Config

Declared in
include/SushiAI/config/model_config.hpp

Contains

Enumerations

enum class Kind

What a Value holds.

NUL

JSON null.

BOOL

true or false.

INT

A whole number.

REAL

A number with a fractional part or an exponent.

STRING

A string.

ARRAY

An ordered list of values.

OBJECT

A set of key/value pairs, in the order the file spelled them.

Variables

constexpr std::int64_t MODEL_VERSION = 1

The model-file version this build reads.

constexpr std::int64_t TRAIN_VERSION = 1

The train-file version this build reads.

constexpr std::int64_t DATA_VERSION = 1

The standalone data-file version this build reads.

Functions

ModelSpec parse_model(const Value &root, std::string_view origin)

Parses a model configuration value into a ModelSpec.

Parameters

root

Parsed configuration value tree.

origin

Context description for diagnostics.

Returns

Parsed model specification.

Exceptions

Error

If schema constraints or version requirements fail.

ModelSpec load_model(const std::filesystem::path &path)

Reads, parses and validates the model file at path.

Parameters

path

The file to read.

Returns

The spec.

Exceptions

Error

If the file cannot be read, is not valid JSON, or is not a valid model document.

template <typename Entry, std::size_t N>
const Entry & find_entry(const std::array< Entry, N > &table, std::string_view type, std::string_view what)

Finds the entry named type, or throws listing what exists.

Parameters

table

Registry constant table.

type

Discriminator string to locate.

what

Diagnostic label describing entry category.

Returns

Reference to matching registry entry.

Exceptions

Error

If type is not found in table.

TrainSpec parse_train(const Value &root, std::string_view origin, const std::filesystem::path &base)

Parses a train document into a TrainSpec.

Parameters

root

Parsed document value tree.

origin

Context description for diagnostics.

base

Directory relative paths resolve against.

Returns

Parsed training specification.

Exceptions

Error

If required keys are missing or values invalid.

TrainSpec load_train(const std::filesystem::path &path)

Reads, parses, and validates the train configuration file.

Parameters

path

Path to train configuration file.

Returns

Parsed training specification.

Exceptions

Error

If the file cannot be read or parsed.

DataSpec parse_data(const Value &root, std::string_view origin)

Turns a parsed data document into a DataSpec.

Parameters

root

The parsed document.

origin

What to call it in a diagnostic, usually a path.

Returns

The spec.

Exceptions

Error

If the version is absent or wrong, or a key is unknown.

DataSpec load_data(const std::filesystem::path &path)

Reads, parses and validates the data file at path.

Parameters

path

The file to read.

Returns

The spec.

Exceptions

Error

If the file cannot be read, is not valid JSON, or is not a valid data document.

std::string_view kind_name(Kind kind) noexcept

A printable name for kind, for a diagnostic.

Parameters

kind

The kind to name.

Returns

A null-terminated literal owned by the library; never null.

void require_version(const Value &root, std::string_view key, std::int64_t expected, std::string_view origin)

Validates document version field against expected version.

Parameters

root

Document root configuration object.

key

Version property key name.

expected

Expected integer version identifier.

origin

Origin context description for diagnostics.

Exceptions

Error

If version property is missing or mismatched.

Value parse_json(std::string_view text, std::string_view origin)

Parses text as a JSON document.

Parameters

text

The document.

origin

What to call it in a diagnostic, usually a path.

Returns

The parsed tree.

Exceptions

Error

If text is not valid JSON; names origin and the parser's own complaint.

Value parse_json_file(const std::filesystem::path &path)

Reads and parses the file at path.

Parameters

path

The file to read.

Returns

The parsed tree.

Exceptions

Error

If the file cannot be read, or is not valid JSON.