Derive-C
Loading...
Searching...
No Matches
fmt.h File Reference
#include <derive-c/core/panic.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>

Go to the source code of this file.

Data Structures

struct  dc_debug_fmt
 Debug format helpers for debug printin data structures. More...

Functions

static dc_debug_fmt dc_debug_fmt_new ()
static void dc_debug_fmt_print_indents (dc_debug_fmt fmt, FILE *stream)
static void dc_debug_fmt_print (dc_debug_fmt fmt, FILE *stream, const char *format,...)
dc_debug_fmt dc_debug_fmt_scope_begin (dc_debug_fmt fmt)
dc_debug_fmt dc_debug_fmt_scope_end (dc_debug_fmt fmt)

Function Documentation

◆ dc_debug_fmt_new()

dc_debug_fmt dc_debug_fmt_new ( )
static
Examples
complex/employees.c, container/arena/basic.c, container/map/decomposed.c, container/vector/dynamic.c, container/vector/static.c, and utils/option.c.

Definition at line 14 of file fmt.h.

14{ return (dc_debug_fmt){.indent = 0}; }
Debug format helpers for debug printin data structures.
Definition fmt.h:10

◆ dc_debug_fmt_print()

void dc_debug_fmt_print ( dc_debug_fmt fmt,
FILE * stream,
const char * format,
... )
static
Examples
complex/employees.c, container/vector/dynamic.c, and utils/option.c.

Definition at line 22 of file fmt.h.

22 {
24
25 va_list args;
26 va_start(args, format);
27 vfprintf(stream, format, args);
28 va_end(args);
29}
static void dc_debug_fmt_print_indents(dc_debug_fmt fmt, FILE *stream)
Definition fmt.h:16
static FILE * stream(SELF *self)
Opens a file for.
Definition template.h:107

◆ dc_debug_fmt_print_indents()

void dc_debug_fmt_print_indents ( dc_debug_fmt fmt,
FILE * stream )
static

Definition at line 16 of file fmt.h.

16 {
17 for (size_t i = 0; i < fmt.indent; i++) {
18 fprintf(stream, " ");
19 }
20}
size_t indent
Definition fmt.h:11

◆ dc_debug_fmt_scope_begin()

dc_debug_fmt dc_debug_fmt_scope_begin ( dc_debug_fmt fmt)

Starts a scope { ... }

  • Does not prepend with the indent
Examples
complex/employees.c, container/vector/dynamic.c, and utils/option.c.

Definition at line 33 of file fmt.h.

33 {
34 return (dc_debug_fmt){.indent = fmt.indent + 1};
35}

◆ dc_debug_fmt_scope_end()

dc_debug_fmt dc_debug_fmt_scope_end ( dc_debug_fmt fmt)

Ends a scope { ... }

  • prepends with the fmt specified indent
Examples
complex/employees.c, container/vector/dynamic.c, and utils/option.c.

Definition at line 39 of file fmt.h.

39 {
40 DC_ASSERT(fmt.indent > 0);
41 return (dc_debug_fmt){.indent = fmt.indent - 1};
42}
#define DC_ASSERT(expr,...)
Definition panic.h:36