diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-03-02 12:55:32 +0000 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-03-02 12:55:32 +0000 |
commit | 5efaa5125fe92a5438b3cc2949f4d720bced5a7a (patch) | |
tree | 87f4da1382fb6179610182ca3e502e5365e66276 /src/defaults.cpp | |
parent | 2e60491ceb0548b0bea93207c13b974d6a6cf5cc (diff) | |
download | mana-5efaa5125fe92a5438b3cc2949f4d720bced5a7a.tar.gz mana-5efaa5125fe92a5438b3cc2949f4d720bced5a7a.tar.bz2 mana-5efaa5125fe92a5438b3cc2949f4d720bced5a7a.tar.xz mana-5efaa5125fe92a5438b3cc2949f4d720bced5a7a.zip |
General code cleanups
* Don't needlessly store or return raw pointers in BeingInfo
* Less copying, more moving
* Less else after return
* Make AddDEF a template instead of a macro
* Removed some unused includes
* Use range-based for loops
Diffstat (limited to 'src/defaults.cpp')
-rw-r--r-- | src/defaults.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/defaults.cpp b/src/defaults.cpp index 8cf79590..1830d394 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -21,45 +21,43 @@ #include "defaults.h" #include "being.h" -#include "graphics.h" #include "client.h" -#include <cstdlib> - -VariableData* createData(int defData) +VariableData *createData(int defData) { return new IntData(defData); } -VariableData* createData(double defData) +VariableData *createData(double defData) { return new FloatData(defData); } -VariableData* createData(float defData) +VariableData *createData(float defData) { return new FloatData(defData); } -VariableData* createData(const std::string &defData) +VariableData *createData(const std::string &defData) { return new StringData(defData); } -VariableData* createData(const char* defData) +VariableData *createData(const char* defData) { return new StringData(defData); } -VariableData* createData(bool defData) +VariableData *createData(bool defData) { return new BoolData(defData); } -#define AddDEF(defaultsData, key, value) \ - defaultsData->insert(std::pair<std::string, VariableData*> \ - (key, createData(value))); - +template<typename T> +void AddDEF(DefaultsData *defaultsData, const char *key, T value) +{ + defaultsData->insert(std::make_pair(key, createData(value))); +} DefaultsData* getConfigDefaults() { @@ -126,7 +124,7 @@ DefaultsData* getConfigDefaults() DefaultsData* getBrandingDefaults() { - auto* brandingData = new DefaultsData; + auto *brandingData = new DefaultsData; // Init config defaults AddDEF(brandingData, "wallpapersPath", ""); AddDEF(brandingData, "wallpaperFile", ""); |