Fri, 21 Jun 2013 17:52:44 +0300
Only write config options to file that actually deviate from the default. Should've done this earlier on... before 0.1 alpha was tagged
src/config.cpp | file | annotate | diff | comparison | revisions | |
src/config.h | file | annotate | diff | comparison | revisions |
--- a/src/config.cpp Fri Jun 21 17:36:50 2013 +0300 +++ b/src/config.cpp Fri Jun 21 17:52:44 2013 +0300 @@ -148,11 +148,11 @@ fprint (f, "# Configuration file for " APPNAME "\n"); for (config* cfg : g_configPointers) { - if (!cfg) + if (!cfg || cfg->isDefault ()) break; str valstring; - switch (cfg->getType()) { + switch (cfg->getType ()) { case CONFIG_int: valstring = fmt ("%1", static_cast<intconfig*> (cfg)->value); break;
--- a/src/config.h Fri Jun 21 17:36:50 2013 +0300 +++ b/src/config.h Fri Jun 21 17:52:44 2013 +0300 @@ -52,11 +52,12 @@ public: const char* name; - virtual configtype_e getType () { + virtual configtype_e getType () const { return CONFIG_none; } virtual void resetValue () {} + virtual bool isDefault () const { return false; } // ------------------------------------------ static bool load (); @@ -120,14 +121,17 @@ name = _name; \ addConfig (this); \ } \ - operator T () { \ + operator const T& () const { \ return value; \ } \ - configtype_e getType () { \ + configtype_e getType () const { \ return CONFIG_##T; \ } \ virtual void resetValue () { \ value = defval; \ + } \ + virtual bool isDefault () const { \ + return value == defval; \ } // =============================================================================