Examples for using the optional type.
Examples for using the optional type.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
};
.x = self->x,
.y = self->y,
.description = strdup(self->description),
};
}
fprintf(
stream,
"complex_data@%p {\n", self);
}
#define ITEM struct complex_data
#define ITEM_DELETE complex_data_delete
#define ITEM_CLONE complex_data_clone
#define ITEM_DEBUG complex_data_debug
#define NAME complex_data_option
complex_data_option opt = complex_data_option_empty();
DC_ASSERT(!complex_data_option_is_present(&opt));
DC_ASSERT(!complex_data_option_get_const(&opt));
bool was_present_1 = complex_data_option_replace(
&opt, (
struct complex_data){.x = 42, .y = 3.14, .description = strdup(
"A complex data")});
DC_ASSERT(complex_data_option_is_present(&opt));
bool was_present_2 = complex_data_option_replace(
&opt,
(
struct complex_data){.x = 100, .y = 2.71, .description = strdup(
"Another complex data")});
complex_data_option_delete(&opt);
}
static void free(SELF *self, void *ptr)
dc_debug_fmt dc_debug_fmt_scope_end(dc_debug_fmt fmt)
dc_debug_fmt dc_debug_fmt_scope_begin(dc_debug_fmt fmt)
static void dc_debug_fmt_print(dc_debug_fmt fmt, FILE *stream, const char *format,...)
static dc_debug_fmt dc_debug_fmt_new()
void complex_data_debug(struct complex_data const *self, dc_debug_fmt fmt, FILE *stream)
void complex_data_delete(struct complex_data *self)
struct complex_data complex_data_clone(struct complex_data const *self)
#define DC_ASSERT(expr,...)
Debug format helpers for debug printin data structures.
static FILE * stream(SELF *self)
Opens a file for.