/* * Copyright (c) 2013-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once #include #include #include #include #include namespace Swift { template class SWIFTEN_API EnumParser { public: EnumParser() { } EnumParser& operator()(T value, const std::string& text) { values[text] = value; return *this; } boost::optional parse(const std::string& value) { typename std::map::const_iterator i = values.find(value); return i == values.end() ? boost::optional() : i->second; } private: std::map values; }; }