Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

SData

Structured Data (SData) is a mechanism to define and manage structured fields, attributes, and commands in a hierarchical and schema-driven manner. It is used to define the attributes of objects, command parameters, and database-like records in a highly structured and reusable way.


Core Concepts

SData Fields

SData fields are descriptors that define individual fields or attributes. These fields include information about their type, name, default value, description, flags, and other properties.

SData Tables

SData tables are arrays of field descriptors (sdata_desc_t) that define structured data. These tables allow hierarchical definitions, enabling the creation of complex schemas.


Data Types (data_type_t)

The data_type_t enumeration defines the types of data that SData fields can represent:

TypeDescription
DTP_STRINGA text string.
DTP_BOOLEANA boolean value (TRUE or FALSE).
DTP_INTEGERAn integer value.
DTP_REALA floating-point number.
DTP_LISTA list (array) of values.
DTP_DICTA dictionary (key-value pairs).
DTP_JSONA JSON object.
DTP_POINTERA generic pointer.

Data Type Utilities


Field Flags (sdata_flag_t)

The sdata_flag_t enumeration defines the properties and characteristics of each field. Flags are bitwise-combinable to give fields multiple properties.

FlagDescription
SDF_NOTACCESSField is not accessible.
SDF_RDField is read-only.
SDF_WRField is writable (and readable).
SDF_REQUIREDField is required; it must not be null.
SDF_PERSISTField is persistent and must be saved/loaded.
SDF_VOLATILField is volatile and must not be saved/loaded.
SDF_RESOURCEField is a resource, referencing another schema.
SDF_PKEYField is a primary key.
SDF_STATSField holds statistical data (metadata).
SDF_RSTATSField holds resettable statistics, implicitly SDF_STATS.
SDF_PSTATSField holds persistent statistics, implicitly SDF_STATS.
SDF_AUTHZ_RRead access requires authorization (__read_attribute__).
SDF_AUTHZ_WWrite access requires authorization (__write_attribute__).
SDF_AUTHZ_XExecution requires authorization (__execute_command__).
SDF_AUTHZ_SStats read requires authorization (__read_stats__).
SDF_AUTHZ_RSStats reset requires authorization (__reset_stats__).

SDF_NOTACCESS

Field is not accessible.

SDF_RD

Field is read-only.

SDF_WR

Field is writable (and readable).

SDF_REQUIRED

Field is required; it must not be null.

SDF_PERSIST

Field is persistent and must be saved/loaded.

SDF_VOLATIL

Field is volatile and must not be saved/loaded.

SDF_RESOURCE

Field is a resource, referencing another schema.

SDF_PKEY

Field is a primary key.

SDF_STATS

Field holds statistical data (metadata).

SDF_RSTATS

Field holds resettable statistics, implicitly `SDF_STATS`.

SDF_PSTATS

Field holds persistent statistics, implicitly `SDF_STATS`.

SDF_AUTHZ_R

Read access requires authorization (`__read_attribute__`).

SDF_AUTHZ_W

Write access requires authorization (`__write_attribute__`).

SDF_AUTHZ_X

Execution requires authorization (`__execute_command__`).

SDF_AUTHZ_S

Stats read requires authorization (`__read_stats__`).

SDF_AUTHZ_RS

Stats reset requires authorization (`__reset_stats__`).

Common Flag Combinations


Descriptor Fields (sdata_desc_t)

The sdata_desc_t structure defines a field or schema. Each descriptor specifies the following:

FieldTypeDescription
typedata_type_tThe type of the field (e.g., string, boolean).
nameconst char *The name of the field.
aliasconst char **Alternative names (aliases) for the field.
flagsdata_flag_tFlags defining the field’s properties.
default_valueconst char *The default value of the field.
headerconst char *Header text for table columns.
fillspaceintColumn width for table formatting.
descriptionconst char *A description of the field’s purpose.
json_fnjson_function_fnCustom function for processing JSON data.
schemaconst sdata_desc_t *Pointer to a sub-schema for compound fields.
authpthconst char *Authorization path for accessing or modifying the field.

Application

Attributes

SData tables define attributes by listing fields with their types, default values, and flags. These fields form the basis of object definitions, enabling schema-based validation and management.

Commands

SData tables can define commands with associated parameters, schemas, and descriptions. Commands extend the functionality of objects, providing structured inputs and outputs.

Nested Schemas

Fields in SData can reference other schemas, enabling hierarchical definitions. This allows for the creation of complex, nested structures while maintaining clarity and reusability.