/* * Copyright (C) 2017-2019 Christopher J. Howard * * This file is part of Antkeeper Source Code. * * Antkeeper Source Code is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Antkeeper Source Code is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Antkeeper Source Code. If not, see . */ #include "parameter-dict.hpp" #include void ParameterDict::unset(const std::string& name) { auto it = parameters.find(name); if (it != parameters.end()) { parameters.erase(it); } } template <> std::string ParameterDict::toString(const std::string& value) { return value; } template <> std::string ParameterDict::toString(const bool& value) { return std::to_string(static_cast(value)); } template <> std::string ParameterDict::toString(const char& value) { return std::to_string(static_cast(value)); } template <> std::string ParameterDict::toString(const unsigned char& value) { return std::to_string(static_cast(value)); } template <> std::string ParameterDict::toString(const int& value) { return std::to_string(value); } template <> std::string ParameterDict::toString(const unsigned int& value) { return std::to_string(value); } template <> std::string ParameterDict::toString(const long& value) { return std::to_string(value); } template <> std::string ParameterDict::toString(const unsigned long& value) { return std::to_string(value); } template <> std::string ParameterDict::toString(const float& value) { return std::to_string(value); } template <> std::string ParameterDict::toString(const double& value) { return std::to_string(value); } template<> std::string ParameterDict::fromString(const std::string& string) { return string; } template<> bool ParameterDict::fromString(const std::string& string) { return static_cast(std::stoi(string)); } template<> char ParameterDict::fromString(const std::string& string) { return static_cast(std::stoi(string)); } template<> unsigned char ParameterDict::fromString(const std::string& string) { return static_cast(std::stoi(string)); } template<> int ParameterDict::fromString(const std::string& string) { return std::stoi(string); } template<> unsigned int ParameterDict::fromString(const std::string& string) { return static_cast(std::stoul(string)); } template<> long ParameterDict::fromString(const std::string& string) { return std::stol(string); } template<> unsigned long ParameterDict::fromString(const std::string& string) { return std::stoul(string); } template<> float ParameterDict::fromString(const std::string& string) { return std::stof(string); } template<> double ParameterDict::fromString(const std::string& string) { return std::stod(string); } std::vector ParameterDict::tokenize(const std::string& string) { std::istringstream stream(string); std::string token; std::vector tokens; const char delimeter = ' '; while (std::getline(stream, token, delimeter)) { tokens.push_back(token); } return tokens; }