1{% from "templates/macros.tmpl" import license, source_files_for_generated_file %} 2{{ license() }} 3 4{{source_files_for_generated_file(template_file, input_files)}} 5 6#ifndef {{header_guard}} 7#define {{header_guard}} 8 9#define SETTINGS_GETTERS_AND_SETTERS \ 10 {% for setting in settings %} 11 {{setting.type|to_passing_type}} Get{{setting.name.to_upper_camel_case()}}() const { return {{setting.name.to_class_data_member()}}; } \ 12 void Set{{setting.name.to_upper_camel_case()}}({{setting.type|to_passing_type}} {{setting.name.to_snake_case()}}); \ 13 {% endfor %} 14 void SetFromStrings(const String& name, const String& value); 15// End of SETTINGS_GETTERS_AND_SETTERS. 16 17#define SETTINGS_MEMBER_VARIABLES \ 18 {% for setting in settings if setting.type != 'bool' %} 19 {{setting.type}} {{setting.name.to_class_data_member()}}; \ 20 {% endfor %} 21 {% for setting in settings if setting.type == 'bool' %} 22 bool {{setting.name.to_class_data_member()}} : 1; \ 23 {% endfor %} 24// End of SETTINGS_MEMBER_VARIABLES. 25 26#define SETTINGS_INITIALIZER_LIST \ 27 {% for setting in settings if setting.initial is not none and setting.type != 'bool' %} 28 , {{setting.name.to_class_data_member()}}({{setting.initial}}) \ 29 {% endfor %} 30 {% for setting in settings if setting.initial is not none and setting.type == 'bool' %} 31 , {{setting.name.to_class_data_member()}}({{setting.initial|cpp_bool}}) \ 32 {% endfor %} 33// End of SETTINGS_INITIALIZER_LIST. 34 35#define SETTINGS_SETTER_BODIES \ 36{% for setting in settings %} 37void Settings::Set{{setting.name.to_upper_camel_case()}}({{setting.type|to_passing_type}} {{setting.name.to_snake_case()}}) { \ 38 if ({{setting.name.to_class_data_member()}} == {{setting.name.to_snake_case()}}) \ 39 return; \ 40 {{setting.name.to_class_data_member()}} = {{setting.name.to_snake_case()}}; \ 41 {% if setting.invalidate %} 42 Invalidate(SettingsDelegate::k{{setting.invalidate}}Change); \ 43 {% endif %} 44} \ 45{% endfor %} 46void Settings::SetFromStrings(const String& name, const String& value) { \ 47 {% for setting in settings %} 48 if (name == "{{setting.name}}") { \ 49 Set{{setting.name.to_upper_camel_case()}}( \ 50 {% if setting.type == 'String' %} 51 value \ 52 {% elif setting.type == 'bool' %} 53 value.IsEmpty() || value == "true" \ 54 {% elif setting.type == 'int' %} 55 value.ToInt() \ 56 {% elif setting.type == 'float' %} 57 value.ToFloat() \ 58 {% elif setting.type == 'double' %} 59 value.ToDouble() \ 60 {% else %} 61 static_cast<{{setting.type}}>(value.ToInt()) \ 62 {% endif %} 63 ); \ 64 return; \ 65 } \ 66 {% endfor %} 67} 68// End of SETTINGS_SETTER_BODIES. 69 70#endif // {{header_guard}} 71