From b2b67372ad6c8b975fb451451860f0956b410249 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sat, 21 Dec 2013 14:48:25 +0100 Subject: [PATCH] Inline serialize() and deserialize() for ConfigOptionEnum --- xs/src/Config.hpp | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/xs/src/Config.hpp b/xs/src/Config.hpp index a59bcf405..f53682d43 100644 --- a/xs/src/Config.hpp +++ b/xs/src/Config.hpp @@ -266,26 +266,24 @@ class ConfigOptionEnum : public ConfigOption operator T() const { return this->value; }; - std::string serialize(); - void deserialize(std::string str); + std::string serialize() { + typename std::map enum_keys_map = ConfigOptionEnum::get_enum_values(); + for (typename std::map::iterator it = enum_keys_map.begin(); it != enum_keys_map.end(); ++it) { + if (it->second == this->value) return it->first; + } + return ""; + }; + + void deserialize(std::string str) { + typename std::map enum_keys_map = ConfigOptionEnum::get_enum_values(); + assert(enum_keys_map.count(str) > 0); + this->value = enum_keys_map[str]; + }; + static std::map get_enum_values(); }; -template -std::string ConfigOptionEnum::serialize() { - typename std::map enum_keys_map = ConfigOptionEnum::get_enum_values(); - for (typename std::map::iterator it = enum_keys_map.begin(); it != enum_keys_map.end(); ++it) { - if (it->second == this->value) return it->first; - } - return ""; -}; -template -void ConfigOptionEnum::deserialize(std::string str) { - typename std::map enum_keys_map = ConfigOptionEnum::get_enum_values(); - assert(enum_keys_map.count(str) > 0); - this->value = enum_keys_map[str]; -}; enum GCodeFlavor { gcfRepRap, gcfTeacup, gcfMakerWare, gcfSailfish, gcfMach3, gcfNoExtrusion,