Derive-C
Loading...
Searching...
No Matches
fmt.h
Go to the documentation of this file.
1
2#pragma once
3
5
6#include <stdarg.h>
7#include <stdio.h>
8#include <stdlib.h>
9
10typedef struct {
11 size_t indent;
13
14static dc_debug_fmt dc_debug_fmt_new() { return (dc_debug_fmt){.indent = 0}; }
15
17 for (size_t i = 0; i < fmt.indent; i++) {
18 fprintf(stream, " ");
19 }
20}
21
22static void dc_debug_fmt_print(dc_debug_fmt fmt, FILE* stream, const char* format, ...) {
24
25 va_list args;
26 va_start(args, format);
27 vfprintf(stream, format, args);
28 va_end(args);
29}
30
34 return (dc_debug_fmt){.indent = fmt.indent + 1};
35}
36
40 DC_ASSERT(fmt.indent > 0);
41 return (dc_debug_fmt){.indent = fmt.indent - 1};
42}
dc_debug_fmt dc_debug_fmt_scope_end(dc_debug_fmt fmt)
Definition fmt.h:39
static void dc_debug_fmt_print_indents(dc_debug_fmt fmt, FILE *stream)
Definition fmt.h:16
dc_debug_fmt dc_debug_fmt_scope_begin(dc_debug_fmt fmt)
Definition fmt.h:33
static void dc_debug_fmt_print(dc_debug_fmt fmt, FILE *stream, const char *format,...)
Definition fmt.h:22
static dc_debug_fmt dc_debug_fmt_new()
Definition fmt.h:14
#define DC_ASSERT(expr,...)
Definition panic.h:36
Debug format helpers for debug printin data structures.
Definition fmt.h:10
size_t indent
Definition fmt.h:11
static FILE * stream(SELF *self)
Opens a file for.
Definition template.h:107