libpressio 0.93.0
Loading...
Searching...
No Matches
Macros | Functions
pressio_option.h File Reference

A single option value for a compressor. More...

#include <stdbool.h>
#include <stdint.h>
#include "pressio_options.h"
#include "pressio_compressor.h"
Include dependency graph for pressio_option.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define PRESSIO_OPTION
 
#define pressio_option_define_type(name, type)
 

Functions

struct pressio_optionpressio_option_new ()
 
void pressio_option_free (struct pressio_option *options)
 
enum pressio_option_type pressio_option_get_type (struct pressio_option const *option)
 
void pressio_option_set_type (struct pressio_option *option, enum pressio_option_type type)
 
bool pressio_option_has_value (struct pressio_option const *option)
 
enum pressio_options_key_status pressio_option_cast_set (struct pressio_option *lhs, struct pressio_option *rhs, enum pressio_conversion_safety safety)
 
enum pressio_options_key_status pressio_option_as_set (struct pressio_option *lhs, struct pressio_option *rhs)
 
struct pressio_optionpressio_option_new_uinteger8 (uint8_t value)
 
uint8_t pressio_option_get_uinteger8 (struct pressio_option const *option)
 
void pressio_option_set_uinteger8 (struct pressio_option *option, uint8_t value)
 
struct pressio_optionpressio_option_new_integer8 (int8_t value)
 
int8_t pressio_option_get_integer8 (struct pressio_option const *option)
 
void pressio_option_set_integer8 (struct pressio_option *option, int8_t value)
 
struct pressio_optionpressio_option_new_uinteger16 (uint16_t value)
 
uint16_t pressio_option_get_uinteger16 (struct pressio_option const *option)
 
void pressio_option_set_uinteger16 (struct pressio_option *option, uint16_t value)
 
struct pressio_optionpressio_option_new_integer16 (int16_t value)
 
int16_t pressio_option_get_integer16 (struct pressio_option const *option)
 
void pressio_option_set_integer16 (struct pressio_option *option, int16_t value)
 
struct pressio_optionpressio_option_new_uinteger (uint32_t value)
 
uint32_t pressio_option_get_uinteger (struct pressio_option const *option)
 
void pressio_option_set_uinteger (struct pressio_option *option, uint32_t value)
 
struct pressio_optionpressio_option_new_integer (int32_t value)
 
int32_t pressio_option_get_integer (struct pressio_option const *option)
 
void pressio_option_set_integer (struct pressio_option *option, int32_t value)
 
struct pressio_optionpressio_option_new_uinteger64 (uint64_t value)
 
uint64_t pressio_option_get_uinteger64 (struct pressio_option const *option)
 
void pressio_option_set_uinteger64 (struct pressio_option *option, uint64_t value)
 
struct pressio_optionpressio_option_new_integer64 (int64_t value)
 
int64_t pressio_option_get_integer64 (struct pressio_option const *option)
 
void pressio_option_set_integer64 (struct pressio_option *option, int64_t value)
 
struct pressio_optionpressio_option_new_float (float value)
 
float pressio_option_get_float (struct pressio_option const *option)
 
void pressio_option_set_float (struct pressio_option *option, float value)
 
struct pressio_optionpressio_option_new_bool (bool value)
 
bool pressio_option_get_bool (struct pressio_option const *option)
 
void pressio_option_set_bool (struct pressio_option *option, bool value)
 
struct pressio_optionpressio_option_new_double (double value)
 
double pressio_option_get_double (struct pressio_option const *option)
 
void pressio_option_set_double (struct pressio_option *option, double value)
 
struct pressio_optionpressio_option_new_dtype (enum pressio_dtype value)
 
enum pressio_dtype pressio_option_get_dtype (struct pressio_option const *option)
 
void pressio_option_set_dtype (struct pressio_option *option, enum pressio_dtype value)
 
struct pressio_optionpressio_option_new_threadsafety (enum pressio_thread_safety value)
 
enum pressio_thread_safety pressio_option_get_threadsafety (struct pressio_option const *option)
 
void pressio_option_set_threadsafety (struct pressio_option *option, enum pressio_thread_safety value)
 
struct pressio_optionpressio_option_new_string (const char *value)
 
const char * pressio_option_get_string (struct pressio_option const *option)
 
void pressio_option_set_string (struct pressio_option *option, const char *value)
 
struct pressio_optionpressio_option_new_userptr (void *value)
 
void * pressio_option_get_userptr (struct pressio_option const *option)
 
void pressio_option_set_userptr (struct pressio_option *option, void *value)
 
struct pressio_optionpressio_option_new_userptr_managed (void *value, void *metadata, void(*deleter)(void *, void *), void(*copy)(void **, void **, const void *, const void *))
 
void pressio_option_set_userptr_managed (struct pressio_option *option, void *value, void *metadata, void(*deleter)(void *, void *), void(*copy)(void **, void **, const void *, const void *))
 
struct pressio_optionpressio_option_new_strings (const char **values, size_t size)
 
const char ** pressio_option_get_strings (struct pressio_option const *option, size_t *size)
 
void pressio_option_set_strings (struct pressio_option *option, const char **values, size_t size)
 
struct pressio_optionpressio_option_new_data (struct pressio_data *data)
 
struct pressio_datapressio_option_get_data (struct pressio_option const *option)
 
void pressio_option_set_data (struct pressio_option *option, struct pressio_data *value)
 
struct pressio_optionpressio_option_convert_implicit (struct pressio_option const *option, enum pressio_option_type type)
 
struct pressio_optionpressio_option_convert (struct pressio_option const *option, enum pressio_option_type type, enum pressio_conversion_safety safety)
 
char * pressio_option_to_string (struct pressio_option const *option)
 

Detailed Description

A single option value for a compressor.

Macro Definition Documentation

◆ PRESSIO_OPTION

#define PRESSIO_OPTION

hearder guard

◆ pressio_option_define_type

#define pressio_option_define_type (   name,
  type 
)
Value:
\
struct pressio_option* pressio_option_new_##name(type value); \ \
type pressio_option_get_##name(struct pressio_option const* option); \ \
void pressio_option_set_##name(struct pressio_option* option, type value);
Definition: options.h:80
enum pressio_option_type type() const

defines a getter and setter prototype for a pressio option type

Parameters
[in]namethe name to append to the function
[in]typethe type return or accept in the function

Function Documentation

◆ pressio_option_as_set()

enum pressio_options_key_status pressio_option_as_set ( struct pressio_option lhs,
struct pressio_option rhs 
)

Sets pressio_option for the specified key with a generic pressio_options preserving the type of the key in the options structure using an implicit cast if necessary

Parameters
[in]lhsthe option to get an pressio_option for
[in]rhsvalue to assign in the pressio_options structure
Returns
pressio_options_key_set if the lhs is modified, pressio_options_key_exists otherwise

◆ pressio_option_cast_set()

enum pressio_options_key_status pressio_option_cast_set ( struct pressio_option lhs,
struct pressio_option rhs,
enum pressio_conversion_safety  safety 
)

Sets pressio_option for the specified key with a generic pressio_options preserving the type of the key in the options structure using the specified cast if necessary

Parameters
[in]lhsthe option to get an pressio_option for
[in]rhsvalue to assign in the pressio_options structure
[in]safetywhat kind of conversions to allow
Returns
pressio_options_key_set if the lhs is modified, pressio_options_key_exists otherwise

◆ pressio_option_convert()

struct pressio_option * pressio_option_convert ( struct pressio_option const *  option,
enum pressio_option_type  type,
enum pressio_conversion_safety  safety 
)

converts between one type and another

Parameters
[in]optionthe option to convert
[in]typethe type to convert to
[in]safetyhow safe to make perform a conversion
Returns
a new option value of the type specified if possible, otherwise returns NULL.

◆ pressio_option_convert_implicit()

struct pressio_option * pressio_option_convert_implicit ( struct pressio_option const *  option,
enum pressio_option_type  type 
)
Parameters
[in]optionthe option to convert
[in]typethe type to convert to
Returns
a new option value of the type specified if possible, otherwise returns NULL.
See also
pressio_option_convert behaves as if this function was called if with safety=pressio_conversion_implicit

◆ pressio_option_free()

void pressio_option_free ( struct pressio_option options)

frees the memory associated with a returned option

Parameters
[in]optionsthe option to free

◆ pressio_option_get_bool()

bool pressio_option_get_bool ( struct pressio_option const *  option)

Gets the value stored in the pressio_option. Calling this with the improper dtype has undefined behavior

Parameters
[in]optionthe option to retrieve a value from
Returns
the value contained in the option

◆ pressio_option_get_data()

struct pressio_data * pressio_option_get_data ( struct pressio_option const *  option)

Gets the value stored in the pressio_option. Calling this with the improper dtype has undefined behavior

Parameters
[in]optionthe option to retrieve a value from
Returns
a new owning copy of the value contained in the option

◆ pressio_option_get_double()

double pressio_option_get_double ( struct pressio_option const *  option)

Gets the value stored in the pressio_option. Calling this with the improper dtype has undefined behavior

Parameters
[in]optionthe option to retrieve a value from
Returns
the value contained in the option

◆ pressio_option_get_dtype()

enum pressio_dtype pressio_option_get_dtype ( struct pressio_option const *  option)

Gets the value stored in the pressio_option. Calling this with the improper dtype has undefined behavior

Parameters
[in]optionthe option to retrieve a value from
Returns
the value contained in the option

◆ pressio_option_get_float()

float pressio_option_get_float ( struct pressio_option const *  option)

Gets the value stored in the pressio_option. Calling this with the improper dtype has undefined behavior

Parameters
[in]optionthe option to retrieve a value from
Returns
the value contained in the option

◆ pressio_option_get_integer()

int32_t pressio_option_get_integer ( struct pressio_option const *  option)

Gets the value stored in the pressio_option. Calling this with the improper dtype has undefined behavior

Parameters
[in]optionthe option to retrieve a value from
Returns
the value contained in the option

◆ pressio_option_get_integer16()

int16_t pressio_option_get_integer16 ( struct pressio_option const *  option)

Gets the value stored in the pressio_option. Calling this with the improper dtype has undefined behavior

Parameters
[in]optionthe option to retrieve a value from
Returns
the value contained in the option

◆ pressio_option_get_integer64()

int64_t pressio_option_get_integer64 ( struct pressio_option const *  option)

Gets the value stored in the pressio_option. Calling this with the improper dtype has undefined behavior

Parameters
[in]optionthe option to retrieve a value from
Returns
the value contained in the option

◆ pressio_option_get_integer8()

int8_t pressio_option_get_integer8 ( struct pressio_option const *  option)

Gets the value stored in the pressio_option. Calling this with the improper dtype has undefined behavior

Parameters
[in]optionthe option to retrieve a value from
Returns
the value contained in the option

◆ pressio_option_get_string()

const char * pressio_option_get_string ( struct pressio_option const *  option)

Gets the value stored in the pressio_option. Calling this with the improper dtype has undefined behavior

Parameters
[in]optionthe option to retrieve a value from
Returns
the value contained in the option

◆ pressio_option_get_strings()

const char ** pressio_option_get_strings ( struct pressio_option const *  option,
size_t *  size 
)

Gets the value stored in the pressio_option. Calling this with the improper dtype has undefined behavior

Parameters
[in]optionthe option to retrieve a value from
[out]sizethe size of the array returned
Returns
the value contained in the option, the returned value must be freed

◆ pressio_option_get_threadsafety()

enum pressio_thread_safety pressio_option_get_threadsafety ( struct pressio_option const *  option)

Gets the value stored in the pressio_option. Calling this with the improper dtype has undefined behavior

Parameters
[in]optionthe option to retrieve a value from
Returns
the value contained in the option

◆ pressio_option_get_type()

enum pressio_option_type pressio_option_get_type ( struct pressio_option const *  option)

gets the type of the returned pressio_option

Parameters
[in]optionthe option to get the dtype for
Returns
the type the option contains

◆ pressio_option_get_uinteger()

uint32_t pressio_option_get_uinteger ( struct pressio_option const *  option)

Gets the value stored in the pressio_option. Calling this with the improper dtype has undefined behavior

Parameters
[in]optionthe option to retrieve a value from
Returns
the value contained in the option

◆ pressio_option_get_uinteger16()

uint16_t pressio_option_get_uinteger16 ( struct pressio_option const *  option)

Gets the value stored in the pressio_option. Calling this with the improper dtype has undefined behavior

Parameters
[in]optionthe option to retrieve a value from
Returns
the value contained in the option

◆ pressio_option_get_uinteger64()

uint64_t pressio_option_get_uinteger64 ( struct pressio_option const *  option)

Gets the value stored in the pressio_option. Calling this with the improper dtype has undefined behavior

Parameters
[in]optionthe option to retrieve a value from
Returns
the value contained in the option

◆ pressio_option_get_uinteger8()

uint8_t pressio_option_get_uinteger8 ( struct pressio_option const *  option)

Gets the value stored in the pressio_option. Calling this with the improper dtype has undefined behavior

Parameters
[in]optionthe option to retrieve a value from
Returns
the value contained in the option

◆ pressio_option_get_userptr()

void * pressio_option_get_userptr ( struct pressio_option const *  option)

Gets the value stored in the pressio_option. Calling this with the improper dtype has undefined behavior

Parameters
[in]optionthe option to retrieve a value from
Returns
the value contained in the option

◆ pressio_option_has_value()

bool pressio_option_has_value ( struct pressio_option const *  option)

returns true if the option contains a value

Parameters
[in]optionthe option to check for a value
Returns
true if the option contains a value

◆ pressio_option_new()

struct pressio_option * pressio_option_new ( )

creates an empty pressio_option

Returns
a new option structure with dtype pressio_option_unset

◆ pressio_option_new_bool()

struct pressio_option * pressio_option_new_bool ( bool  value)

Creates a new pressio_option containing the specified value

Parameters
[in]valuethe value to use to create the object
Returns
a pointer to a new pressio option set to value passed in

◆ pressio_option_new_data()

struct pressio_option * pressio_option_new_data ( struct pressio_data data)

Creates a new pressio_option containing the specified value

Parameters
[in]datathe value to use to create the object
Returns
a pointer to a new pressio option set to value passed in

◆ pressio_option_new_double()

struct pressio_option * pressio_option_new_double ( double  value)

Creates a new pressio_option containing the specified value

Parameters
[in]valuethe value to use to create the object
Returns
a pointer to a new pressio option set to value passed in

◆ pressio_option_new_dtype()

struct pressio_option * pressio_option_new_dtype ( enum pressio_dtype  value)

Creates a new pressio_option containing the specified value

Parameters
[in]valuethe value to use to create the object
Returns
a pointer to a new pressio option set to value passed in

◆ pressio_option_new_float()

struct pressio_option * pressio_option_new_float ( float  value)

Creates a new pressio_option containing the specified value

Parameters
[in]valuethe value to use to create the object
Returns
a pointer to a new pressio option set to value passed in

◆ pressio_option_new_integer()

struct pressio_option * pressio_option_new_integer ( int32_t  value)

Creates a new pressio_option containing the specified value

Parameters
[in]valuethe value to use to create the object
Returns
a pointer to a new pressio option set to value passed in

◆ pressio_option_new_integer16()

struct pressio_option * pressio_option_new_integer16 ( int16_t  value)

Creates a new pressio_option containing the specified value

Parameters
[in]valuethe value to use to create the object
Returns
a pointer to a new pressio option set to value passed in

◆ pressio_option_new_integer64()

struct pressio_option * pressio_option_new_integer64 ( int64_t  value)

Creates a new pressio_option containing the specified value

Parameters
[in]valuethe value to use to create the object
Returns
a pointer to a new pressio option set to value passed in

◆ pressio_option_new_integer8()

struct pressio_option * pressio_option_new_integer8 ( int8_t  value)

Creates a new pressio_option containing the specified value

Parameters
[in]valuethe value to use to create the object
Returns
a pointer to a new pressio option set to value passed in

◆ pressio_option_new_string()

struct pressio_option * pressio_option_new_string ( const char *  value)

Creates a new pressio_option containing the specified value

Parameters
[in]valuethe value to use to create the object
Returns
a pointer to a new pressio option set to value passed in

◆ pressio_option_new_strings()

struct pressio_option * pressio_option_new_strings ( const char **  values,
size_t  size 
)

Creates a new pressio_option containing the specified value

Parameters
[in]valuesthe value to use to create the object
[in]sizethe length of the array
Returns
a pointer to a new pressio option set to value passed in

◆ pressio_option_new_threadsafety()

struct pressio_option * pressio_option_new_threadsafety ( enum pressio_thread_safety  value)

Creates a new pressio_option containing the specified value

Parameters
[in]valuethe value to use to create the object
Returns
a pointer to a new pressio option set to value passed in

◆ pressio_option_new_uinteger()

struct pressio_option * pressio_option_new_uinteger ( uint32_t  value)

Creates a new pressio_option containing the specified value

Parameters
[in]valuethe value to use to create the object
Returns
a pointer to a new pressio option set to value passed in

◆ pressio_option_new_uinteger16()

struct pressio_option * pressio_option_new_uinteger16 ( uint16_t  value)

Creates a new pressio_option containing the specified value

Parameters
[in]valuethe value to use to create the object
Returns
a pointer to a new pressio option set to value passed in

◆ pressio_option_new_uinteger64()

struct pressio_option * pressio_option_new_uinteger64 ( uint64_t  value)

Creates a new pressio_option containing the specified value

Parameters
[in]valuethe value to use to create the object
Returns
a pointer to a new pressio option set to value passed in

◆ pressio_option_new_uinteger8()

struct pressio_option * pressio_option_new_uinteger8 ( uint8_t  value)

Creates a new pressio_option containing the specified value

Parameters
[in]valuethe value to use to create the object
Returns
a pointer to a new pressio option set to value passed in

◆ pressio_option_new_userptr()

struct pressio_option * pressio_option_new_userptr ( void *  value)

Creates a new pressio_option containing the specified value

Parameters
[in]valuethe value to use to create the object
Returns
a pointer to a new pressio option set to value passed in

◆ pressio_option_new_userptr_managed()

struct pressio_option * pressio_option_new_userptr_managed ( void *  value,
void *  metadata,
void(*)(void *, void *)  deleter,
void(*)(void **, void **, const void *, const void *)  copy 
)

Creates a new pressio_option containing the specified value

Parameters
[in]valuethe value to use to create the object
[in]metadatato use to manage the allocation of value
[in]deleterdeletes the value
[in]copycopies the value
Returns
a pointer to a new pressio option set to value passed in

◆ pressio_option_set_bool()

void pressio_option_set_bool ( struct pressio_option option,
bool  value 
)

Sets the option to an integer value

Parameters
[in]optionthe option to set
[in]valuethe value to set

◆ pressio_option_set_data()

void pressio_option_set_data ( struct pressio_option option,
struct pressio_data value 
)

Sets the option to an integer value

Parameters
[in]optionthe option to set
[in]valuethe value to set

◆ pressio_option_set_double()

void pressio_option_set_double ( struct pressio_option option,
double  value 
)

Sets the option to an integer value

Parameters
[in]optionthe option to set
[in]valuethe value to set

◆ pressio_option_set_dtype()

void pressio_option_set_dtype ( struct pressio_option option,
enum pressio_dtype  value 
)

Sets the option to an integer value

Parameters
[in]optionthe option to set
[in]valuethe value to set

◆ pressio_option_set_float()

void pressio_option_set_float ( struct pressio_option option,
float  value 
)

Sets the option to an integer value

Parameters
[in]optionthe option to set
[in]valuethe value to set

◆ pressio_option_set_integer()

void pressio_option_set_integer ( struct pressio_option option,
int32_t  value 
)

Sets the option to an integer value

Parameters
[in]optionthe option to set
[in]valuethe value to set

◆ pressio_option_set_integer16()

void pressio_option_set_integer16 ( struct pressio_option option,
int16_t  value 
)

Sets the option to an integer value

Parameters
[in]optionthe option to set
[in]valuethe value to set

◆ pressio_option_set_integer64()

void pressio_option_set_integer64 ( struct pressio_option option,
int64_t  value 
)

Sets the option to an integer value

Parameters
[in]optionthe option to set
[in]valuethe value to set

◆ pressio_option_set_integer8()

void pressio_option_set_integer8 ( struct pressio_option option,
int8_t  value 
)

Sets the option to an integer value

Parameters
[in]optionthe option to set
[in]valuethe value to set

◆ pressio_option_set_string()

void pressio_option_set_string ( struct pressio_option option,
const char *  value 
)

Sets the option to an integer value

Parameters
[in]optionthe option to set
[in]valuethe value to set

◆ pressio_option_set_strings()

void pressio_option_set_strings ( struct pressio_option option,
const char **  values,
size_t  size 
)

Sets the option to an integer value

Parameters
[in]optionthe option to set
[in]valuesthe value to set
[in]sizethe size of the array of values

◆ pressio_option_set_threadsafety()

void pressio_option_set_threadsafety ( struct pressio_option option,
enum pressio_thread_safety  value 
)

Sets the option to an integer value

Parameters
[in]optionthe option to set
[in]valuethe value to set

◆ pressio_option_set_type()

void pressio_option_set_type ( struct pressio_option option,
enum pressio_option_type  type 
)

set the type of the passed pressio_option

Parameters
[in]optionthe option to get the dtype for
[in]typethe option to get the dtype for

◆ pressio_option_set_uinteger()

void pressio_option_set_uinteger ( struct pressio_option option,
uint32_t  value 
)

Sets the option to an integer value

Parameters
[in]optionthe option to set
[in]valuethe value to set

◆ pressio_option_set_uinteger16()

void pressio_option_set_uinteger16 ( struct pressio_option option,
uint16_t  value 
)

Sets the option to an integer value

Parameters
[in]optionthe option to set
[in]valuethe value to set

◆ pressio_option_set_uinteger64()

void pressio_option_set_uinteger64 ( struct pressio_option option,
uint64_t  value 
)

Sets the option to an integer value

Parameters
[in]optionthe option to set
[in]valuethe value to set

◆ pressio_option_set_uinteger8()

void pressio_option_set_uinteger8 ( struct pressio_option option,
uint8_t  value 
)

Sets the option to an integer value

Parameters
[in]optionthe option to set
[in]valuethe value to set

◆ pressio_option_set_userptr()

void pressio_option_set_userptr ( struct pressio_option option,
void *  value 
)

Sets the option to an integer value

Parameters
[in]optionthe option to set
[in]valuethe value to set

◆ pressio_option_set_userptr_managed()

void pressio_option_set_userptr_managed ( struct pressio_option option,
void *  value,
void *  metadata,
void(*)(void *, void *)  deleter,
void(*)(void **, void **, const void *, const void *)  copy 
)

Set a pressio_option containing the specified value

Parameters
[in]optionthe option structure to set
[in]valuethe value to use to create the object
[in]metadatato use to manage the allocation of value
[in]deleterdeletes the value
[in]copycopies the value
Returns
a pointer to a new pressio option set to value passed in

◆ pressio_option_to_string()

char * pressio_option_to_string ( struct pressio_option const *  option)

Create a human readable string for the option passed.

The format is unspecified and should NOT be parsed. It may change without warning.

For machine readable formats, please use the accessor methods pressio_options_cast_string()/pressio_options_cast_string() or the equivelent C++ routines.

Parameters
[in]optionthe option to format as a string
Returns
a human readable string designed for debugging output, return nullptr on error. The returned string should be freed.