Added utility functions to check type of script values.
This commit is contained in:
parent
161fdb6c93
commit
c31dbbd093
@ -85,6 +85,48 @@ public:
|
||||
|
||||
std::partial_ordering operator<=>(const ScriptValue& other) const = default;
|
||||
|
||||
[[nodiscard]]
|
||||
bool isUndefined() const noexcept
|
||||
{
|
||||
return std::holds_alternative<UndefinedValue>(base_);
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
bool isBool() const noexcept
|
||||
{
|
||||
return std::holds_alternative<bool>(base_);
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
bool isInteger() const noexcept
|
||||
{
|
||||
return std::holds_alternative<script_int_t>(base_);
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
bool isFloat() const noexcept
|
||||
{
|
||||
return std::holds_alternative<script_float_t>(base_);
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
bool isString() const noexcept
|
||||
{
|
||||
return std::holds_alternative<std::string>(base_);
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
bool isArray() const noexcept
|
||||
{
|
||||
return std::holds_alternative<array_t>(base_);
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
bool isMap() const noexcept
|
||||
{
|
||||
return std::holds_alternative<map_t>(base_);
|
||||
}
|
||||
|
||||
template<typename TFunction>
|
||||
auto visit(TFunction&& function) const
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user