Update to new Arbutils
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#ifndef CREATURELIB_EFFECTPARAMETER_HPP
|
||||
#define CREATURELIB_EFFECTPARAMETER_HPP
|
||||
#include <Arbutils/ConstString.hpp>
|
||||
#include <Arbutils/Enum.hpp>
|
||||
#include <Arbutils/StringView.hpp>
|
||||
#include <variant>
|
||||
#include "Exceptions/CreatureException.hpp"
|
||||
|
||||
@@ -11,15 +11,14 @@ namespace CreatureLib::Library {
|
||||
class EffectParameter {
|
||||
private:
|
||||
EffectParameterType _type = EffectParameterType::None;
|
||||
std::variant<bool, int64_t, float, ArbUt::CaseInsensitiveConstString> _value;
|
||||
std::variant<bool, int64_t, float, ArbUt::StringView> _value;
|
||||
|
||||
public:
|
||||
inline EffectParameter() : _type(EffectParameterType::None){};
|
||||
inline explicit EffectParameter(bool b) : _type(EffectParameterType::Bool), _value(b){};
|
||||
inline explicit EffectParameter(int64_t i) : _type(EffectParameterType::Int), _value(i){};
|
||||
inline explicit EffectParameter(float f) : _type(EffectParameterType::Float), _value(f){};
|
||||
inline explicit EffectParameter(const ArbUt::CaseInsensitiveConstString& s)
|
||||
: _type(EffectParameterType::String), _value(s){};
|
||||
inline explicit EffectParameter(const ArbUt::StringView& s) : _type(EffectParameterType::String), _value(s){};
|
||||
EffectParameter(const EffectParameter& other) = delete;
|
||||
EffectParameter& operator=(const EffectParameter& other) = delete;
|
||||
|
||||
@@ -54,13 +53,13 @@ namespace CreatureLib::Library {
|
||||
}
|
||||
return std::get<float>(_value);
|
||||
}
|
||||
const ArbUt::CaseInsensitiveConstString& AsString() const {
|
||||
const ArbUt::StringView& AsString() const {
|
||||
if (_type != EffectParameterType::String) {
|
||||
std::stringstream ss;
|
||||
ss << "Cast effect parameter to string, but was " << EffectParameterTypeHelper::ToString(_type);
|
||||
throw CreatureException(ss.str());
|
||||
}
|
||||
return std::get<ArbUt::CaseInsensitiveConstString>(_value);
|
||||
return std::get<ArbUt::StringView>(_value);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user