22 enum class Kind { Null, Int, Float, Bool, String, Array,
Object };
44 bool isNull()
const {
return kind_ == Kind::Null; }
45 bool isInt()
const {
return kind_ == Kind::Int; }
46 bool isFloat()
const {
return kind_ == Kind::Float; }
47 bool isBool()
const {
return kind_ == Kind::Bool; }
48 bool isString()
const {
return kind_ == Kind::String; }
49 bool isObject()
const {
return kind_ == Kind::Object; }
50 bool isArray()
const {
return kind_ == Kind::Array; }
53 int64_t
asInt()
const {
return i_; }
59 const std::string&
asString()
const {
return s_; }
72 const StateValue* find(
const std::string& key)
const;
75 std::vector<std::string> keys()
const;
81 const StateValue* get(
const std::string& dottedPath)
const;
82 StateValue* get(
const std::string& dottedPath);
90 bool setPath(
const std::string& dottedPath,
StateValue v);
97 bool mergeDefaults(
const StateValue& defaults);
105 Kind kind_ = Kind::Null;
110 std::vector<StateValue> arr_;
111 std::vector<std::pair<std::string, StateValue>> obj_;
#define EVENGINE_API
宿主(eve / libmain)导出宏;插件从进程导入同一批符号。
Object is the base class for all game objects. It provides reference counting and dirty flag for upda...
JSON-compatible state value tree used by state hot reload.
static StateValue object()
Empty object.
Kind kind() const
The kind of the stored value.
bool operator!=(const StateValue &o) const
static StateValue array()
Empty array.
int64_t asInt() const
Integer payload; only valid when kind() == Kind::Int.
bool asBool() const
Boolean payload; only valid when kind() == Kind::Bool.
size_t arraySize() const
Element count; only valid on arrays.
double asDouble() const
Floating-point payload; only valid when kind() == Kind::Float.
const std::string & asString() const
String payload; only valid when kind() == Kind::String.
const StateValue & at(size_t index) const
static StateValue null()
Null value.
StateValue()=default
Null value.
StateValue & at(size_t index)
Indexed element (bounds-checked); only valid on arrays.