13#include <initializer_list>
33 using Array = std::vector<Value>;
34 using Object = std::map<std::string, Value>;
35 using Storage = std::variant<std::monostate, bool, std::int64_t, double, std::string, Array, Object>;
38 enum class Type : std::uint8_t {
94 Type type() const noexcept {
return static_cast<Type>(storage_.index()); }
98 bool isNull() const noexcept {
return type() == Type::Null; }
100 bool isBool() const noexcept {
return type() == Type::Bool; }
134 [[nodiscard]]
static Value array(std::initializer_list<Value>
values);
146 std::int64_t asInt()
const;
148 double asDouble()
const;
152 const std::string& asString()
const;
157 std::size_t arraySize()
const;
173 Value* find(
const std::string&
key)
noexcept;
183 const Value* find(
const std::string&
key)
const noexcept;
185 std::vector<std::string> keys()
const;
188 bool isNumeric() const noexcept {
return isInt64() || isDouble(); }
190 std::string typeName()
const;
192 std::string toString()
const;
210 return std::get_if<T>(&storage_);
224 return std::get_if<T>(&storage_);
234 [[nodiscard]]
static Result<Value> fromJson(std::string_view json);
246 bool operator==(
const Value&)
const;
256#if defined(_WIN32) && defined(EVENGINE_MODULE_DLL) && !defined(EVENGINE_EXPORTS_FOUNDATION)
257extern template class __declspec(dllimport) std::vector<eve::Value>;
258extern template class __declspec(dllimport) std::map<std::string, eve::Value>;
260extern template class std::vector<eve::Value>;
261extern template class std::map<std::string, eve::Value>;
266#if defined(_WIN32) && defined(EVENGINE_MODULE_DLL) && !defined(EVENGINE_EXPORTS_FOUNDATION)
267extern template __declspec(dllimport) std::monostate* eve::Value::getIf<std::monostate>() noexcept;
268extern template __declspec(dllimport) const
std::monostate*
eve::Value::getIf<
std::monostate>() const noexcept;
269extern template __declspec(dllimport)
bool*
eve::Value::getIf<
bool>() noexcept;
270extern template __declspec(dllimport) const
bool*
eve::Value::getIf<
bool>() const noexcept;
271extern template __declspec(dllimport)
std::int64_t*
eve::Value::getIf<
std::int64_t>() noexcept;
272extern template __declspec(dllimport) const
std::int64_t*
eve::Value::getIf<
std::int64_t>() const noexcept;
273extern template __declspec(dllimport)
double*
eve::Value::getIf<
double>() noexcept;
274extern template __declspec(dllimport) const
double*
eve::Value::getIf<
double>() const noexcept;
275extern template __declspec(dllimport)
std::
string*
eve::Value::getIf<
std::
string>() noexcept;
276extern template __declspec(dllimport) const
std::
string*
eve::Value::getIf<
std::
string>() const noexcept;
277extern template __declspec(dllimport)
eve::Value::Array*
eve::Value::getIf<
eve::Value::Array>() noexcept;
278extern template __declspec(dllimport) const
eve::Value::Array*
eve::Value::getIf<
eve::Value::Array>() const noexcept;
279extern template __declspec(dllimport)
eve::Value::Object*
eve::Value::getIf<
eve::Value::Object>() noexcept;
280extern template __declspec(dllimport) const
eve::Value::Object*
eve::Value::getIf<
eve::Value::Object>() const noexcept;
#define EVENGINE_API_FOUNDATION
每个链接组(link group)各自的导出宏。
std::set< std::string > values
Move-only, checked operation results for the common layer.
std::map< std::string, std::span< const std::uint8_t > > members
Move-only operation result carrying either a value or Status.
The canonical owning dynamic value used by data-facing protocols.
bool isInt64() const noexcept
Return true when this value is an Int64.
static Value null()
Compatibility factory for a null value.
const Storage & storage() const noexcept
Return the immutable variant storage for visitors.
Type kind() const noexcept
Compatibility spelling for the former dialogue data tree.
std::map< std::string, Value > Object
bool isNumeric() const noexcept
Return whether this value is an integer or finite number.
bool isArray() const noexcept
Return true when this value is an array.
static Value number(double value)
Compatibility factory for a Double value.
bool isString() const noexcept
Return true when this value is a string.
static Value string(std::string value)
Compatibility factory for a string value.
Type
Runtime kind of the owned value.
Value() noexcept
Construct a null value.
std::vector< Value > Array
Storage & storage() noexcept
Return mutable variant storage for owning edits.
static Value integer(std::int64_t value)
Compatibility factory for an Int64 value.
std::variant< std::monostate, bool, std::int64_t, double, std::string, Array, Object > Storage
bool isNull() const noexcept
Return true when this value is null.
static Value boolean(bool value)
Compatibility factory for a boolean value.
const T * getIf() const noexcept
Return a typed pointer, or nullptr when the kind differs.
bool isBool() const noexcept
Return true when this value is a boolean.
bool isObject() const noexcept
Return true when this value is an object.
bool isDouble() const noexcept
Return true when this value is a Double.
T * getIf() noexcept
Return a mutable typed pointer, or nullptr when the kind differs.
Build metadata (engine git commit, build time, third-party version).
enum EVENGINE_API_FOUNDATION Float
OT_FLOAT.
enum EVENGINE_API_FOUNDATION Bool
OT_BOOL.
enum EVENGINE_API_FOUNDATION Integer
OT_INTEGER.
enum EVENGINE_API_FOUNDATION String
OT_STRING.