|
YAC 3.18.0
Yet Another Coupler
|
Public interface for YAC parameters. More...
#include <stddef.h>

Go to the source code of this file.
Enumerations | |
| enum | yac_param_type { YAC_PARAM_TYPE_INVALID = 0 , YAC_PARAM_TYPE_EMPTY , YAC_PARAM_TYPE_SCALAR , YAC_PARAM_TYPE_STRUCT , YAC_PARAM_TYPE_LIST } |
| Parameter type for generic configuration interface. More... | |
Functions | |
| enum yac_param_type | yac_param_get_type (const struct yac_param *param) |
| Get the type of a parameter. | |
| int | yac_param_is_default (const struct yac_param *param) |
| Check whether a parameter is at its default value. | |
| const char * | yac_param_get_name (const struct yac_param *param) |
| Get the name of the current parameter. | |
| int | yac_param_get_sub_count (const struct yac_param *param, size_t *count) |
| Get the number of subparameters. | |
| int | yac_param_get_sub_by_name (struct yac_param *param, const char *name, struct yac_param **sub_param) |
| Get a handle to a subparameter by name. | |
| int | yac_param_get_sub_by_index (struct yac_param *param, size_t idx, struct yac_param **sub_param) |
| Get a handle to a subparameter by index. | |
| int | yac_param_append (struct yac_param *param, struct yac_param **sub_param) |
| Append a new default subparameter to a list parameter and return a handle to it. | |
| int | yac_param_set_scalar (struct yac_param *param, const char *value_str) |
| Set the value of a scalar parameter from a string. | |
| int | yac_param_get_scalar (const struct yac_param *param, char *buf, size_t buflen) |
| Get the value of a scalar parameter as a string. | |
| int | yac_param_set_scalar_int (struct yac_param *param, int value) |
| Set the value of a scalar parameter as an int. | |
| int | yac_param_set_scalar_dble (struct yac_param *param, double value) |
| Set the value of a scalar parameter as a double. | |
| int | yac_param_get_scalar_int (const struct yac_param *param, int *value) |
| Get the value of a scalar parameter as an int. | |
| int | yac_param_get_scalar_dble (const struct yac_param *param, double *value) |
| Get the value of a scalar parameter as a double. | |
| const char * | yac_param_get_last_error (void) |
| Retrieve the last error message for the calling thread. | |
| void | yac_param_delete (struct yac_param *param) |
| enum yac_param_type |
Parameter type for generic configuration interface.
Append a new default subparameter to a list parameter and return a handle to it.
For list parameters, appends a new subparameter generated by the default_factory function provided at list construction. Returns a handle to the new subparameter via the output pointer.
| param | Parameter handle (must be a list) | |
| [out] | sub_param | Pointer to output handle for the new subparameter |
Definition at line 107 of file param.c.


| void yac_param_delete | ( | struct yac_param * | param | ) |
| const char * yac_param_get_last_error | ( | void | ) |
Retrieve the last error message for the calling thread.
If a parameter API function returns an error, this function returns a pointer to a thread-local buffer containing a human-readable error message. The pointer is valid until the next API call in the same thread.
Definition at line 301 of file param.c.


| const char * yac_param_get_name | ( | const struct yac_param * | param | ) |
Get the name of the current parameter.
Returns the name of the parameter referenced by the handle. For root or unnamed parameters, returns NULL. The returned pointer is valid until the next API call in the same thread.
| param | Parameter handle |
Definition at line 50 of file param.c.

| int yac_param_get_scalar | ( | const struct yac_param * | param, |
| char * | buf, | ||
| size_t | buflen ) |
Get the value of a scalar parameter as a string.
The value is converted to a string representation and written to the output buffer. The output buffer must be large enough to hold the value and a null terminator. On error, returns nonzero and sets an error message.
| param | Parameter handle | |
| [out] | buf | Output buffer for string value |
| buflen | Size of output buffer |
Definition at line 128 of file param.c.

| int yac_param_get_scalar_dble | ( | const struct yac_param * | param, |
| double * | value ) |
Get the value of a scalar parameter as a double.
Only works if the parameter supports double retrieval. On error or if not supported, returns nonzero and sets an error message.
| param | Parameter handle | |
| [out] | value | Pointer to output double value |
Definition at line 166 of file param.c.

| int yac_param_get_scalar_int | ( | const struct yac_param * | param, |
| int * | value ) |
Get the value of a scalar parameter as an int.
Only works if the parameter supports integer retrieval. On error or if not supported, returns nonzero and sets an error message.
| param | Parameter handle | |
| [out] | value | Pointer to output integer value |
Definition at line 157 of file param.c.

| int yac_param_get_sub_by_index | ( | struct yac_param * | param, |
| size_t | idx, | ||
| struct yac_param ** | sub_param ) |
Get a handle to a subparameter by index.
For struct and list parameters, returns a handle to the i'th subparameter (0 <= idx < sub_count) via the output pointer. For oneof parameters, returns a handle to the active subparameter, if idx=0.
Note: The returned sub_param handle is managed internally and must NOT be freed or deleted by the caller.
| param | Parameter handle | |
| idx | Subparameter index | |
| [out] | sub_param | Pointer to output handle |
Definition at line 92 of file param.c.


| int yac_param_get_sub_by_name | ( | struct yac_param * | param, |
| const char * | name, | ||
| struct yac_param ** | sub_param ) |
Get a handle to a subparameter by name.
For struct parameters, returns a handle to the subparameter with the given name via the output pointer. For list parameters, returns a handle to the subparameter with the given name. For oneof parameters, returns a handle to the subparameter with the given name, if it is the active one; otherwise returns an error.
Note: The returned sub_param handle is managed internally and must NOT be freed or deleted by the caller.
| param | Parameter handle | |
| name | Subparameter name | |
| [out] | sub_param | Pointer to output handle |
Definition at line 75 of file param.c.


| int yac_param_get_sub_count | ( | const struct yac_param * | param, |
| size_t * | count ) |
Get the number of subparameters.
For struct parameters, sets count to the number of named subparameters. For list parameters, sets count to the current number of elements in the list. For oneof parameters, sets count to one. For scalar or empty parameters, sets count to 0 and sets an error message.
| param | Parameter handle | |
| [out] | count | Pointer to output count |
Definition at line 60 of file param.c.


| enum yac_param_type yac_param_get_type | ( | const struct yac_param * | param | ) |
Get the type of a parameter.
Returns the type of the parameter referenced by the handle. This can be used to determine if the parameter is a scalar, struct, list, or empty.
| param | Parameter handle |
Definition at line 24 of file param.c.


| int yac_param_is_default | ( | const struct yac_param * | param | ) |
Check whether a parameter is at its default value.
Returns 1 if the parameter is currently set to its default value, 0 if not. On error (e.g., invalid handle), returns -1 and sets an error message.
| param | Parameter handle |
Definition at line 37 of file param.c.


| int yac_param_set_scalar | ( | struct yac_param * | param, |
| const char * | value_str ) |
Set the value of a scalar parameter from a string.
The value string is parsed and converted to the parameter's type internally. For example, "42" for an integer, "3.14" for a double, or "foo" for a string. On error (e.g., invalid format), returns nonzero and sets an error message.
| param | Parameter handle |
| value_str | String representation of the value |
Definition at line 118 of file param.c.

| int yac_param_set_scalar_dble | ( | struct yac_param * | param, |
| double | value ) |
Set the value of a scalar parameter as a double.
Only works if the parameter supports double assignment. On error or if not supported, returns nonzero and sets an error message.
| param | Parameter handle |
| value | Double value to set |
Definition at line 148 of file param.c.

| int yac_param_set_scalar_int | ( | struct yac_param * | param, |
| int | value ) |
Set the value of a scalar parameter as an int.
Only works if the parameter supports integer assignment. On error or if not supported, returns nonzero and sets an error message.
| param | Parameter handle |
| value | Integer value to set |
Definition at line 139 of file param.c.
