| 9 | #include <iostream> |
| 10 | |
| 11 | Config::Config() { |
| 12 | // Default configuration |
| 13 | node["column_limit"] = 80; |
| 14 | node["indent_width"] = 4; |
| 15 | node["use_tab"] = false; |
| 16 | node["tab_width"] = 4; |
| 17 | node["continuation_indent_width"] = 4; |
| 18 | node["spaces_before_call"] = 1; |
| 19 | |
| 20 | node["keep_simple_control_block_one_line"] = true; |
| 21 | node["keep_simple_function_one_line"] = true; |
| 22 | |
| 23 | node["align_args"] = true; |
| 24 | node["break_after_functioncall_lp"] = false; |
| 25 | node["break_before_functioncall_rp"] = false; |
| 26 | node["spaces_inside_functioncall_parens"] = false; |
| 27 | node["spaces_inside_functiondef_parens"] = false; |
| 28 | |
| 29 | node["align_parameter"] = true; |
| 30 | node["chop_down_parameter"] = false; |
| 31 | node["break_after_functiondef_lp"] = false; |
| 32 | node["break_before_functiondef_rp"] = false; |
| 33 | |
| 34 | node["align_table_field"] = true; |
| 35 | node["break_after_table_lb"] = true; |
| 36 | node["break_before_table_rb"] = true; |
| 37 | node["chop_down_table"] = false; |
| 38 | node["chop_down_kv_table"] = true; |
| 39 | node["table_sep"] = ","; |
| 40 | node["extra_sep_at_table_end"] = false; |
| 41 | node["column_table_limit"] = node["column_limit"]; |
| 42 | node["spaces_inside_table_braces"] = false; |
| 43 | |
| 44 | node["break_after_operator"] = true; |
| 45 | |
| 46 | node["double_quote_to_single_quote"] = false; |
| 47 | node["single_quote_to_double_quote"] = false; |
| 48 | |
| 49 | node["spaces_around_equals_in_field"] = true; |
| 50 | node["line_breaks_after_function_body"] = 1; |
| 51 | |
| 52 | node["line_separator"] = "input"; |
| 53 | |
| 54 | // Validators |
| 55 | // validate integer without 0s as configuration value |
| 56 | auto validate_integer = [](const std::string& key, std::any elem) { |
| 57 | int value = std::any_cast<int>(elem); |
| 58 | if (value > 0) { |
| 59 | return value; |
| 60 | } |
| 61 | std::cerr << "[ERROR] Processing " << key << " failed" << std::endl; |
| 62 | throw std::domain_error( |
| 63 | "[ERROR] Configuration value is out of range. Must be a positive integer greater than 0."); |
| 64 | }; |
| 65 | |
| 66 | // validate integer with 0s as configuration value |
| 67 | auto validate_integer_zero = [](const std::string& key, std::any elem) { |
| 68 | int value = std::any_cast<int>(elem); |
nothing calls this directly
no outgoing calls
no test coverage detected