-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtree_printer.h
More file actions
36 lines (29 loc) · 809 Bytes
/
Copy pathtree_printer.h
File metadata and controls
36 lines (29 loc) · 809 Bytes
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
#ifndef TREE_PRINTER_H_
#define TREE_PRINTER_H_
#include <stdint.h>
#include <stdio.h>
#define TREE_PRINTER_VTABLE(TSelf) \
void (*printf)(TSelf * self, const char * format, ...); \
void (*start_field)(TSelf * self); \
void (*end_field)(TSelf * self); \
void (*start_child)(TSelf * self); \
void (*end_child)(TSelf * self);
typedef struct tree_printer TreePrinter;
typedef struct file_tree_printer FileTreePrinter;
struct tree_printer {
TREE_PRINTER_VTABLE(TreePrinter)
};
struct file_tree_printer {
union {
TreePrinter as_tree_printer;
struct {
TREE_PRINTER_VTABLE(FileTreePrinter)
};
};
FILE * file;
char * str_endl;
char * str_indent;
int64_t current_level;
};
void init_file_tree_printer(FileTreePrinter * self, FILE * file);
#endif /* end of include guard: TREE_PRINTER_H_ */