|
cu
|
Datatype for wrapping pointer in a safer way. More...
#include <stdbool.h>Go to the source code of this file.
Data Structures | |
| struct | option_t |
| option_t wraps a pointer und does checks whether it is null. More... | |
Functions | |
| option_t | option (void *data) |
| Create a new option_t for given pointer. More... | |
| void * | unwrap (option_t *self) |
| Unwrap the option_t and retrieve the underlying pointer. More... | |
| void * | expect (option_t *self, const char *msg) |
| Unwraps the option_t and retrieve the underlying pointer. More... | |
| void * | unwrap_or (option_t *self, void *default_val) |
| Unwraps the option_t and retrieve the underlying pointer. More... | |
| bool | is_some (option_t *self) |
| Check if the underlying data contains a valid pointer. More... | |
| bool | is_none (option_t *self) |
| Check if the underlying data is a invalid pointer. More... | |
Datatype for wrapping pointer in a safer way.
| void* expect | ( | option_t * | self, |
| const char * | msg | ||
| ) |
Unwraps the option_t and retrieve the underlying pointer.
In case of an error see unwrap(), the passed error msg is printed and abort is called.
| self | reference to the option |
| msg | message to print to stderr |
| bool is_none | ( | option_t * | self | ) |
| bool is_some | ( | option_t * | self | ) |
| option_t option | ( | void * | data | ) |
| void* unwrap | ( | option_t * | self | ) |
| void* unwrap_or | ( | option_t * | self, |
| void * | default_val | ||
| ) |