YAC 3.21.0
Yet Another Coupler
Loading...
Searching...
No Matches
param_str.c File Reference
#include "param_str.h"
#include "param_internal.h"
#include "utils_common.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
Include dependency graph for param_str.c:

Go to the source code of this file.

Data Structures

struct  yac_param_str
 

Functions

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.
 

Variables

static const struct yac_param_vtable yac_param_str_vtable
 

Function Documentation

◆ yac_param_str_delete()

static void yac_param_str_delete ( struct yac_param * param)
static

Definition at line 148 of file param_str.c.

◆ yac_param_str_get_name()

static const char * yac_param_str_get_name ( const struct yac_param * param)
static

Definition at line 56 of file param_str.c.

◆ yac_param_str_get_scalar()

static int yac_param_str_get_scalar ( const struct yac_param * param,
char * buf,
size_t buflen )
static

Definition at line 102 of file param_str.c.

◆ yac_param_str_get_scalar_kind()

static int yac_param_str_get_scalar_kind ( const struct yac_param * param,
enum yac_param_scalar_kind * scalar_kind )
static

Definition at line 140 of file param_str.c.

◆ yac_param_str_get_type()

static enum yac_param_type yac_param_str_get_type ( const struct yac_param * param)
static

Definition at line 25 of file param_str.c.

◆ 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
paramParameter handle (must be a string parameter)
Return values
Nonzeroif at default
Zerootherwise

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
nameName of the parameter
value_ptrPointer to the string value
default_valueDefault string value (copied internally, ignored if has_default is false)
allow_NULLAllow NULL value_ptr (1 = allow, 0 = error)
allow_emptyAllow empty string (value[0] == '\0')
max_str_lenMaximum allowed string length (excluding null terminator)
has_defaultIf true, parameter has a default value; if false, value is undefined until set
is_definedIf 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.

Here is the caller graph for this function:

◆ yac_param_str_set_scalar()

static int yac_param_str_set_scalar ( struct yac_param * param,
const char * value_str )
static

Definition at line 63 of file param_str.c.

Variable Documentation

◆ yac_param_str_vtable

const struct yac_param_vtable yac_param_str_vtable
static
Initial value:
= {
.is_default = yac_param_str_is_default,
.get_sub_count = NULL,
.get_sub_by_name = NULL,
.get_sub_by_index = NULL,
.append = NULL,
.set_scalar = yac_param_str_set_scalar,
.get_scalar = yac_param_str_get_scalar,
.get_scalar_kind = yac_param_str_get_scalar_kind,
.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)
Definition param_str.c:102
static const char * yac_param_str_get_name(const struct yac_param *param)
Definition param_str.c:56
static int yac_param_str_get_scalar_kind(const struct yac_param *param, enum yac_param_scalar_kind *scalar_kind)
Definition param_str.c:140
static int yac_param_str_set_scalar(struct yac_param *param, const char *value_str)
Definition param_str.c:63
static int yac_param_str_is_default(const struct yac_param *param)
Check if the string parameter is at its default value.
Definition param_str.c:43
static enum yac_param_type yac_param_str_get_type(const struct yac_param *param)
Definition param_str.c:25
static void yac_param_str_delete(struct yac_param *param)
Definition param_str.c:148

Definition at line 158 of file param_str.c.