|
14 | 14 |
|
15 | 15 | namespace sqltoaster {
|
16 | 16 |
|
| 17 | +typedef enum output_format { |
| 18 | + OUTPUT_FORMAT_DEFAULT, |
| 19 | + OUTPUT_FORMAT_YAML |
| 20 | +} output_format_t; |
| 21 | + |
17 | 22 | const long LIST_ITEM_OFF = 0;
|
18 | 23 | const long LIST_ITEM_ON = 1;
|
19 | 24 |
|
20 |
| -const long OUTPUT_FORMAT_DEFAULT = 1; |
21 |
| -const long OUTPUT_FORMAT_YAML = 2; |
22 |
| - |
23 |
| -const int OUTPUT_FORMAT_XALLOC_INDEX = 0; |
24 |
| -const int INDENT_LEVEL_XALLOC_INDEX = 1; |
| 25 | +const int INDENT_LEVEL_XALLOC_INDEX = 0; |
25 | 26 | // Informs the printer whether the current item to be printed is a list item
|
26 |
| -const int LIST_ITEM_XALLOC_INDEX = 2; |
| 27 | +const int LIST_ITEM_XALLOC_INDEX = 1; |
27 | 28 |
|
28 | 29 | typedef struct printer {
|
29 |
| - int iomanip_indexes[3]; |
| 30 | + int iomanip_indexes[2]; |
30 | 31 | sqltoast::parse_result_t& res;
|
31 |
| - printer(sqltoast::parse_result_t& res, std::ostream& out) : res(res) |
| 32 | + output_format_t output_format; |
| 33 | + printer( |
| 34 | + sqltoast::parse_result_t& res, |
| 35 | + std::ostream& out) : |
| 36 | + res(res), |
| 37 | + output_format(OUTPUT_FORMAT_DEFAULT) |
32 | 38 | {
|
33 |
| - iomanip_indexes[OUTPUT_FORMAT_XALLOC_INDEX] = std::ios_base::xalloc(); |
34 | 39 | iomanip_indexes[INDENT_LEVEL_XALLOC_INDEX] = std::ios_base::xalloc();
|
35 | 40 | iomanip_indexes[LIST_ITEM_XALLOC_INDEX] = std::ios_base::xalloc();
|
36 | 41 | int idx_indent = iomanip_indexes[INDENT_LEVEL_XALLOC_INDEX];
|
37 | 42 | out.iword(idx_indent) = 0;
|
38 | 43 | int idx_list_item = iomanip_indexes[LIST_ITEM_XALLOC_INDEX];
|
39 | 44 | out.iword(idx_list_item) = LIST_ITEM_OFF;
|
40 | 45 | }
|
41 |
| - inline void set_yaml(std::ostream& out) { |
42 |
| - int idx_format = iomanip_indexes[OUTPUT_FORMAT_XALLOC_INDEX]; |
43 |
| - out.iword(idx_format) = OUTPUT_FORMAT_YAML; |
44 |
| - } |
45 |
| - inline bool use_yaml(std::ostream& out) const { |
46 |
| - return (out.iword(iomanip_indexes[OUTPUT_FORMAT_XALLOC_INDEX]) == OUTPUT_FORMAT_YAML); |
47 |
| - } |
48 | 46 | inline void indent_push(std::ostream& out) {
|
49 | 47 | int idx_indent = iomanip_indexes[INDENT_LEVEL_XALLOC_INDEX];
|
50 | 48 | long cur_indent = out.iword(idx_indent);
|
|
0 commit comments