summaryrefslogtreecommitdiff
path: root/kit/print.h
blob: 5a64a20b9e6e3f76c417171db3d40148dbc3f693 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef KIT_PRINT_H
#define KIT_PRINT_H

#include "string_builder.h"

#ifdef __cplusplus
extern "C" {
#endif

enum {
  KIT_PRINT_ALIGN_RIGHT = 1,
  KIT_PRINT_UNSIGNED    = (1 << 1),
  KIT_PRINT_BIN         = (1 << 2),
  KIT_PRINT_OCT         = (1 << 3),
  KIT_PRINT_DEC         = (1 << 4),
  KIT_PRINT_HEX         = (1 << 5),
  KIT_PRINT_PRECISE     = (1 << 6),
  KIT_PRINT_UTF8        = (1 << 7),
};

s32 kit_print_int(kit_str_builder_t *s, i64 value, i64 width, c8 fill,
                  u32 flags);

s32 kit_print_float(kit_str_builder_t *s, f64 value, i64 width,
                    c8 fill, u32 flags);

s32 kit_print_esc(kit_str_builder_t *s, kit_str_t value,
                  c8 escape_char, kit_str_t special_symbols,
                  u32 flags);

#ifdef __cplusplus
}
#endif

#define PRINT_ALIGN_RIGHT KIT_PRINT_ALIGN_RIGHT
#define PRINT_UNSIGNED KIT_PRINT_UNSIGNED
#define PRINT_BIN KIT_PRINT_BIN
#define PRINT_OCT KIT_PRINT_OCT
#define PRINT_DEC KIT_PRINT_DEC
#define PRINT_HEX KIT_PRINT_HEX
#define PRINT_PRECISE KIT_PRINT_PRECISE
#define PRINT_UTF8 KIT_PRINT_UTF8
#define print_int kit_print_int
#define print_float kit_print_float
#define print_esckit_print_esc

#endif