59 lines
1.6 KiB
C++
59 lines
1.6 KiB
C++
/* Copyright 2020, Michele Santullo
|
|
* This file is part of orotool.
|
|
*
|
|
* Orotool 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.
|
|
*
|
|
* Orotool 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 Orotool. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include "shops.hpp"
|
|
#include <stdexcept>
|
|
|
|
namespace oro {
|
|
|
|
ShopTypeWrapper::ShopTypeWrapper (int val) {
|
|
*this = val;
|
|
}
|
|
|
|
ShopTypeWrapper::ShopTypeWrapper (const std::string& str) {
|
|
*this = str;
|
|
}
|
|
|
|
ShopTypeWrapper::ShopTypeWrapper (std::string_view str) {
|
|
*this = str;
|
|
}
|
|
|
|
ShopTypeWrapper& ShopTypeWrapper::operator= (int val) {
|
|
if (static_cast<int>(ShopType::Vending) == val)
|
|
value = ShopType::Vending;
|
|
else if (static_cast<int>(ShopType::Buying) == val)
|
|
value = ShopType::Buying;
|
|
else
|
|
value = ShopType::Unknown;
|
|
return *this;
|
|
}
|
|
|
|
ShopTypeWrapper& ShopTypeWrapper::operator= (const std::string& str) {
|
|
return this->operator=(std::string_view(str));
|
|
}
|
|
|
|
ShopTypeWrapper& ShopTypeWrapper::operator= (std::string_view str) {
|
|
if ("V" == str)
|
|
value = ShopType::Vending;
|
|
else if ("B" == str)
|
|
value = ShopType::Buying;
|
|
else
|
|
throw std::runtime_error("Unknown shop type '" + std::string(str) + "'");
|
|
return *this;
|
|
}
|
|
|
|
} //namespace oro
|