The Sequence Toolkit
www.sequence-toolkit.com
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
Functions
stk_options_api.h File Reference
#include "stk_common.h"
Include dependency graph for stk_options_api.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void * stk_find_option (stk_options_t *options, char *name, stk_options_t **last)
 
stk_options_tstk_copy_extend_options (stk_options_t *options, int number_to_extend)
 
stk_ret stk_append_option (stk_options_t *options, char *name, void *data)
 
stk_ret stk_update_option (stk_options_t *options, char *name, void *data, void **old_data)
 
stk_ret stk_free_options (stk_options_t *options)
 
stk_options_tstk_build_options (char *str, int sz)
 
stk_ret stk_free_built_options (stk_options_t *options)
 

Detailed Description

The Option module in the Sequence Toolkit provides APIs to interrogate and manage various options throughout the STK system. Most modules comprise of the ability to be configured through this Option API.

Function Documentation

stk_ret stk_append_option ( stk_options_t options,
char *  name,
void *  data 
)

Append a key value pair to an options array. Note: This function does not extend/realloc the memory - use stk_copy_extend_options() to make space if not allocated large enough then call this.

Parameters
optionsNULL terminated array of options to be searched
nameName of key/value pair to be added
dataData of key/value pair to be added
Returns
STK_SUCCESS if the array was appended
See Also
stk_copy_extend_options()
stk_options_t* stk_build_options ( char *  str,
int  sz 
)

API to build an options table from a string in the following format. <key>

<subscope> <key>

Whitespace indentation is significant

Returns
An allocated options table
See Also
stk_free_built_options()
stk_options_t* stk_copy_extend_options ( stk_options_t options,
int  number_to_extend 
)

Copy an options array and extend it (alloc new) to make room for new options.

Parameters
optionsNULL terminated array of options to be searched. (Passing a NULL pointer allocs new)
number_to_extendNumber of additional options to be added to the array
Returns
A newly allocated options array
void* stk_find_option ( stk_options_t options,
char *  name,
stk_options_t **  last 
)

Find a named option in an array of options

Parameters
optionsNULL terminated array of options to be searched
nameOption name being searched for
lastNULL for a new search, or a pointer address to store last iteration key
Returns
the data value for the named option (or NULL if not present)
stk_ret stk_free_built_options ( stk_options_t options)

Free options created with stk_build_options(). This API does a shallow free of each name/value element Applications must still call stk_free_options(). It cannot recurse in to scopes/sub-options because there is no data indicating the type of value. Applications must call stk_find_options() and call this on every sub-option.

See Also
stk_find_option()
stk_ret stk_free_options ( stk_options_t options)

Free a dynamically allocated options array.

Parameters
optionsThe options array to be freed
Returns
Whether the array was freed
See Also
stk_copy_extend_options()
stk_ret stk_update_option ( stk_options_t options,
char *  name,
void *  data,
void **  old_data 
)

Update an existing key value pair in an options array.

Parameters
optionsNULL terminated array of options to be searched
nameName of key/value pair to be updated
dataNew data of key/value pair
old_dataPointer to store old data value of key/value pair, maybe NULL
Returns
STK_SUCCESS if the array was updated, or !STK_SUCCESS if the option was not found