#include "param_str.h"
#include "param_internal.h"
#include "utils_common.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
Go to the source code of this file.
|
| static enum yac_param_type | yac_param_str_get_type (const struct yac_param *param) |
| |
| static int | yac_param_str_is_default (const struct yac_param *param) |
| | Check if the string parameter is at its default value.
|
| |
| static const char * | yac_param_str_get_name (const struct yac_param *param) |
| |
| static int | yac_param_str_set_scalar (struct yac_param *param, const char *value_str) |
| |
| static int | yac_param_str_get_scalar (const struct yac_param *param, char *buf, size_t buflen) |
| |
| static int | yac_param_str_get_scalar_kind (const struct yac_param *param, enum yac_param_scalar_kind *scalar_kind) |
| |
| static void | yac_param_str_delete (struct yac_param *param) |
| |
| struct yac_param * | yac_param_str_new (const char *name, char **value_ptr, const char *default_value, int allow_NULL, int allow_empty, size_t max_str_len, int has_default, int is_defined) |
| | Create a string parameter.
|
| |
◆ yac_param_str_delete()
| static void yac_param_str_delete |
( |
struct yac_param * | param | ) |
|
|
static |
◆ yac_param_str_get_name()
| static const char * yac_param_str_get_name |
( |
const struct yac_param * | param | ) |
|
|
static |
◆ yac_param_str_get_scalar()
| static int yac_param_str_get_scalar |
( |
const struct yac_param * | param, |
|
|
char * | buf, |
|
|
size_t | buflen ) |
|
static |
◆ yac_param_str_get_scalar_kind()
◆ yac_param_str_get_type()
◆ yac_param_str_is_default()
| static int yac_param_str_is_default |
( |
const struct yac_param * | param | ) |
|
|
static |
Check if the string parameter is at its default value.
This function compares the current value (*value_ptr) to the default_value.
- If allow_NULL is true, both *value_ptr and default_value may be NULL.
- If both are NULL, returns nonzero (at default).
- If only one is NULL, returns zero (not at default).
- If both are non-NULL, compares the strings with strcmp.
- Parameters
-
| param | Parameter handle (must be a string parameter) |
- Return values
-
| Nonzero | if at default |
| Zero | otherwise |
Definition at line 43 of file param_str.c.
◆ yac_param_str_new()
| struct yac_param * yac_param_str_new |
( |
const char * | name, |
|
|
char ** | value_ptr, |
|
|
const char * | default_value, |
|
|
int | allow_NULL, |
|
|
int | allow_empty, |
|
|
size_t | max_str_len, |
|
|
int | has_default, |
|
|
int | is_defined ) |
Create a string parameter.
- Parameters
-
| name | Name of the parameter |
| value_ptr | Pointer to the string value |
| default_value | Default string value (copied internally, ignored if has_default is false) |
| allow_NULL | Allow NULL value_ptr (1 = allow, 0 = error) |
| allow_empty | Allow empty string (value[0] == '\0') |
| max_str_len | Maximum allowed string length (excluding null terminator) |
| has_default | If true, parameter has a default value; if false, value is undefined until set |
| is_defined | If true, initial value is considered defined (can be NULL or empty depending on allow_NULL and allow_empty); if false, initial value is considered undefined and user must set it before getting |
- Returns
- Pointer to new parameter handle
Definition at line 176 of file param_str.c.
◆ yac_param_str_set_scalar()
| static int yac_param_str_set_scalar |
( |
struct yac_param * | param, |
|
|
const char * | value_str ) |
|
static |
◆ yac_param_str_vtable
Initial value:= {
.get_sub_count = NULL,
.get_sub_by_name = NULL,
.get_sub_by_index = NULL,
.append = NULL,
.set_scalar_int = NULL,
.set_scalar_dble = NULL,
.get_scalar_int = NULL,
.get_scalar_dble = NULL
}
static int yac_param_str_get_scalar(const struct yac_param *param, char *buf, size_t buflen)
static const char * yac_param_str_get_name(const struct yac_param *param)
static int yac_param_str_get_scalar_kind(const struct yac_param *param, enum yac_param_scalar_kind *scalar_kind)
static int yac_param_str_set_scalar(struct yac_param *param, const char *value_str)
static int yac_param_str_is_default(const struct yac_param *param)
Check if the string parameter is at its default value.
static enum yac_param_type yac_param_str_get_type(const struct yac_param *param)
static void yac_param_str_delete(struct yac_param *param)
Definition at line 158 of file param_str.c.