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:
Type |
Description |
---|---|
|
A text string. |
|
A boolean value ( |
|
An integer value. |
|
A floating-point number. |
|
A list (array) of values. |
|
A dictionary (key-value pairs). |
|
A JSON object. |
|
A generic pointer. |
Data Type Utilities#
String types:
DTP_IS_STRING(type)
Boolean types:
DTP_IS_BOOLEAN(type)
Integer types:
DTP_IS_INTEGER(type)
Number types:
DTP_IS_NUMBER(type)
(includes integer, real, and boolean)List types:
DTP_IS_LIST(type)
Dictionary types:
DTP_IS_DICT(type)
JSON types:
DTP_IS_JSON(type)
Pointer types:
DTP_IS_POINTER(type)
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.
Flag |
Description |
---|---|
|
Field is not accessible. |
|
Field is read-only. |
|
Field is writable (and readable). |
|
Field is required; it must not be null. |
|
Field is persistent and must be saved/loaded. |
|
Field is volatile and must not be saved/loaded. |
|
Field is a resource, referencing another schema. |
|
Field is a primary key. |
|
Field holds statistical data (metadata). |
|
Field holds resettable statistics, implicitly |
|
Field holds persistent statistics, implicitly |
|
Read access requires authorization ( |
|
Write access requires authorization ( |
|
Execution requires authorization ( |
|
Stats read requires authorization ( |
|
Stats reset requires authorization ( |
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#
Public Attributes: Combine
SDF_RD|SDF_WR|SDF_STATS|SDF_PERSIST|SDF_VOLATIL|SDF_RSTATS|SDF_PSTATS
.Writable Attributes: Combine
SDF_WR|SDF_PERSIST
.
Descriptor Fields (sdata_desc_t
)#
The sdata_desc_t
structure defines a field or schema. Each descriptor specifies the following:
Field |
Type |
Description |
---|---|---|
|
|
The type of the field (e.g., string, boolean). |
|
|
The name of the field. |
|
|
Alternative names (aliases) for the field. |
|
|
Flags defining the field’s properties. |
|
|
The default value of the field. |
|
|
Header text for table columns. |
|
|
Column width for table formatting. |
|
|
A description of the field’s purpose. |
|
|
Custom function for processing JSON data. |
|
|
Pointer to a sub-schema for compound fields. |
|
|
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.