载入中...
搜索中...
未找到

The canonical owning dynamic value used by data-facing protocols. 更多...

#include <Value.h>

Public 类型

enum class  Type : std::uint8_t {
  Null = 0 , Bool , Int64 , Double ,
  String , Array , Object , Integer = Int64 ,
  Number = Double , Int = Int64 , Float = Double
}
 Runtime kind of the owned value. 更多...
 
using Array = std::vector< Value >
 
using Object = std::map< std::string, Value >
 
using Storage = std::variant< std::monostate, bool, std::int64_t, double, std::string, Array, Object >
 
using Kind = Type
 Compatibility spelling for code that used StateValue::Kind.
 

Public 成员函数

 Value ()=default
 Construct a null value.
 
 Value (std::nullptr_t)
 Construct a null value from nullptr.
 
 Value (bool value)
 Construct a boolean value.
 
 Value (std::int64_t value)
 Construct an Int64 value without narrowing.
 
 Value (int value)
 Construct an integer value using the canonical Int64 type.
 
 Value (double value)
 Construct a Double value; non-finite values serialize as errors.
 
 Value (float value)
 Construct a Double value from a float.
 
 Value (const char *value)
 Construct a string value, copying the supplied text.
 
 Value (std::string value)
 Construct a string value by taking the supplied text.
 
 Value (Array value)
 Construct an array value by taking its elements.
 
 Value (Object value)
 Construct an object value by taking its members.
 
Type type () const noexcept
 Return the active value kind.
 
Type kind () const noexcept
 Compatibility spelling for the former dialogue data tree.
 
bool isNull () const noexcept
 Return true when this value is null.
 
bool isBool () const noexcept
 Return true when this value is a boolean.
 
bool isInt64 () const noexcept
 Return true when this value is an Int64.
 
bool isDouble () const noexcept
 Return true when this value is a Double.
 
bool isString () const noexcept
 Return true when this value is a string.
 
bool isArray () const noexcept
 Return true when this value is an array.
 
bool isObject () const noexcept
 Return true when this value is an object.
 
std::int64_t asInt () const
 Return the Int64 payload; the caller must have checked the kind.
 
double asDouble () const
 Return the Double payload; the caller must have checked the kind.
 
bool asBool () const
 Return the boolean payload; the caller must have checked the kind.
 
const std::string & asString () const
 Return the string payload; the caller must have checked the kind.
 
void pushBack (Value value)
 Append an element to an array value.
 
std::size_t arraySize () const
 Return the number of array elements.
 
Value & at (std::size_t index)
 Return a bounds-checked array element.
 
const Value & at (std::size_t index) const
 Return a bounds-checked immutable array element.
 
void set (const std::string &key, Value value)
 Insert or replace an object member.
 
Value * find (const std::string &key) noexcept
 Return an object member, or nullptr when absent.
 
const Value * find (const std::string &key) const noexcept
 Return an immutable object member, or nullptr when absent.
 
std::vector< std::string > keys () const
 Return object member names in deterministic order.
 
bool isNumeric () const noexcept
 Return whether this value is an integer or finite number.
 
std::string typeName () const
 Return the compatibility type name used by dialogue scripts.
 
std::string toString () const
 Render a scalar using the former dialogue formatting rules.
 
const Storage & storage () const noexcept
 Return the immutable variant storage for visitors.
 
Storage & storage () noexcept
 Return mutable variant storage for owning edits.
 
template<class T >
const T * getIf () const noexcept
 Return a typed pointer, or nullptr when the kind differs.
 
template<class T >
T * getIf () noexcept
 Return a mutable typed pointer, or nullptr when the kind differs.
 
Result< std::string > toJson () const
 Serialize this value as deterministic compact JSON.
 
bool operator== (const Value &) const =default
 Compare two values recursively, including their numeric kinds.
 

静态 Public 成员函数

static Value null ()
 Compatibility factory for a null value.
 
static Value integer (std::int64_t value)
 Compatibility factory for an Int64 value.
 
static Value number (double value)
 Compatibility factory for a Double value.
 
static Value boolean (bool value)
 Compatibility factory for a boolean value.
 
static Value string (std::string value)
 Compatibility factory for a string value.
 
static Value array (Array value)
 Compatibility factory for an array value.
 
static Value object (Object value)
 Compatibility factory for an object value.
 
static Result< Value > fromJson (std::string_view json)
 Parse one strict JSON value into an owning Value.
 

详细描述

The canonical owning dynamic value used by data-facing protocols.

A Value owns all recursively contained storage. Object members use std::map, so key traversal and compact JSON serialization are deterministic. Native pointers, ECS handles, renderer objects and other domain-specific values are intentionally not part of this protocol.

在文件 Value.h 第 31 行定义.

成员类型定义说明

◆ Array

using eve::Value::Array = std::vector<Value>

在文件 Value.h 第 33 行定义.

◆ Kind

Compatibility spelling for code that used StateValue::Kind.

在文件 Value.h 第 57 行定义.

◆ Object

using eve::Value::Object = std::map<std::string, Value>

在文件 Value.h 第 34 行定义.

◆ Storage

using eve::Value::Storage = std::variant<std::monostate, bool, std::int64_t, double, std::string, Array, Object>

在文件 Value.h 第 35 行定义.

成员枚举类型说明

◆ Type

enum class eve::Value::Type : std::uint8_t
strong

Runtime kind of the owned value.

枚举值
Null 
Bool 
Int64 
Double 
String 
Array 
Object 
Integer 

Compatibility spelling for Int64.

Number 

Compatibility spelling for Double.

Int 

Compatibility spelling used by the former dialogue value.

Float 

Compatibility spelling used by the former dialogue value.

在文件 Value.h 第 38 行定义.

构造及析构函数说明

◆ Value() [1/11]

eve::Value::Value ( )
default

Construct a null value.

◆ Value() [2/11]

eve::Value::Value ( std::nullptr_t  )
inline

Construct a null value from nullptr.

在文件 Value.h 第 62 行定义.

◆ Value() [3/11]

eve::Value::Value ( bool  value)
inline

Construct a boolean value.

在文件 Value.h 第 64 行定义.

◆ Value() [4/11]

eve::Value::Value ( std::int64_t  value)
inline

Construct an Int64 value without narrowing.

在文件 Value.h 第 66 行定义.

◆ Value() [5/11]

eve::Value::Value ( int  value)
inline

Construct an integer value using the canonical Int64 type.

在文件 Value.h 第 68 行定义.

◆ Value() [6/11]

eve::Value::Value ( double  value)
inline

Construct a Double value; non-finite values serialize as errors.

在文件 Value.h 第 70 行定义.

◆ Value() [7/11]

eve::Value::Value ( float  value)
inline

Construct a Double value from a float.

在文件 Value.h 第 72 行定义.

◆ Value() [8/11]

eve::Value::Value ( const char *  value)
inline

Construct a string value, copying the supplied text.

在文件 Value.h 第 74 行定义.

引用了 string.

◆ Value() [9/11]

eve::Value::Value ( std::string  value)
inline

Construct a string value by taking the supplied text.

在文件 Value.h 第 76 行定义.

◆ Value() [10/11]

eve::Value::Value ( Array  value)
inline

Construct an array value by taking its elements.

在文件 Value.h 第 78 行定义.

◆ Value() [11/11]

eve::Value::Value ( Object  value)
inline

Construct an object value by taking its members.

在文件 Value.h 第 80 行定义.

成员函数说明

◆ array()

static Value eve::Value::array ( Array  value)
inlinestatic

Compatibility factory for an array value.

在文件 Value.h 第 112 行定义.

引用了 value.

被这些函数引用 arraySize(), at(), at(), pushBack(), eve::graphics::snapshotVegetationDetails() , 以及 eve::dialogue::toCanonicalValue().

◆ arraySize()

◆ asBool()

bool eve::Value::asBool ( ) const

Return the boolean payload; the caller must have checked the kind.

在文件 Value.cpp 第 81 行定义.

引用了 EV_ASSERT , 以及 value.

被这些函数引用 eve::statepatch::StatePatchStateAdapter::hasTag(), eve::asset_procgen::EvpackInstanceSetLoader::load(), eve::rpg::GameState::restoreSnapshotJson(), eve::dnut::SequenceRuntime::restoreState() , 以及 toString().

◆ asDouble()

double eve::Value::asDouble ( ) const

Return the Double payload; the caller must have checked the kind.

在文件 Value.cpp 第 75 行定义.

引用了 EV_ASSERT , 以及 value.

被这些函数引用 eve::action::ActionTimeline::fromValue(), eve::hexmap::hexTerrainBakeFromValue(), eve::asset_procgen::EvpackTerrainMaterialLoader::load() , 以及 toString().

◆ asInt()

◆ asString()

◆ at() [1/2]

◆ at() [2/2]

const Value & eve::Value::at ( std::size_t  index) const

Return a bounds-checked immutable array element.

在文件 Value.cpp 第 112 行定义.

引用了 array(), at(), EV_ASSERT , 以及 index.

◆ boolean()

static Value eve::Value::boolean ( bool  value)
inlinestatic

Compatibility factory for a boolean value.

在文件 Value.h 第 108 行定义.

引用了 value.

被这些函数引用 eve::dnut::SequenceRuntime::captureState(), eve::dialogue::encodeSequenceStateMutations() , 以及 eve::dialogue::toCanonicalValue().

◆ find() [1/2]

const Value * eve::Value::find ( const std::string &  key) const
noexcept

Return an immutable object member, or nullptr when absent.

返回
Borrowed const pointer into this Value; nullptr when not an object or key is absent. @ownership Borrowed; this Value owns the returned member. @nullable Yes. @lifetime Valid until this Value is destroyed, moved, or structurally mutated. @thread Affine to this Value; no synchronization. @reentrancy Does not invoke callbacks.

在文件 Value.cpp 第 131 行定义.

引用了 key.

◆ find() [2/2]

◆ fromJson()

Result< Value > eve::Value::fromJson ( std::string_view  json)
static

Parse one strict JSON value into an owning Value.

参数
jsonUTF-8 JSON text; duplicate object keys are rejected.
返回
The parsed value, or a ParseError diagnostic.
备注
JSON numbers without a fraction or exponent must fit Int64; fractional and exponent forms become finite Double values.

在文件 Value.cpp 第 57 行定义.

引用了 error, eve::Diagnostic::error(), eve::Result< T >::failure(), input, eve::json::Document::parse(), eve::ParseError, eve::json::Document::root() , 以及 eve::json::Document::valid().

被这些函数引用 eve::procgen::ModuleAssemblyPlan::applyConfigJson(), eve::editor::ActionTimelineTarget::applyDomainOperation(), eve::physics::Destruction::assetFromJson(), eve::rpg::RpgStorySession::begin(), eve::asset_import::bindUnityRenderers(), eve::rts::RTS::castScriptAbility(), eve::rpg::Party::checkpointJson(), eve::weapon::compileSpellFragmentsJson(), eve::settlement::SettlementRuleSet::configureJson(), eve::asset::cookCanonicalImageRgba8(), eve::asset::cookCanonicalPcgGraph(), eve::asset::cookCanonicalVolumeTextureRgba8(), eve::asset::cookEvaToEvpack(), eve::dev::executePlayJson(), eve::editor::exposeActionTimelineScriptBindings(), eve::daynight::exposeSkyScriptBindings(), eve::graphics::WaterStyleConfig::fromJson(), eve::physics::ClothModel::fromJson(), eve::stylize::AttackVfxSkin::fromJson(), eve::stylize::AttackVfxRecipe::fromJson(), eve::stylize::MeshVfxAsset::fromJson(), eve::editor::ActionTimelineWidget::inspectSelection(), eve::rts::RTSContentLoader::load(), eve::editor::ActionTimelineTarget::loadSnapshot(), eve::rpg::makeStatusTickSettlementRequest(), eve::schema::SchemaRegistry::migrateJson(), eve::asset_import::gltf::parseDocument(), eve::asset::parseEvaManifest(), eve::parseSnapshotEnvelope(), eve::vehicle::parseVehicleDefinition(), eve::inventory::InventorySaveSession::prepareRestoreSnapshotJson(), eve::asset_import::prepareShaderImport(), eve::asset_import::prepareUnityMaterial(), eve::asset_import::prepareUnityNativeMesh(), eve::asset_import::prepareUnityNativeTexture(), eve::asset_import::prepareUnrealM4Import(), eve::rts::RTS::queueScriptResearch(), eve::rts::RTS::queueScriptUnit(), eve::vehicle::Vehicle::registerVehiclesFromJson(), eve::weapon::Weapon::registerWeaponsFromJson(), eve::climbing::ClimbingRuntime::reloadProfileJson(), eve::emergence::RuleEngine::replaceCatalogueJson(), eve::tactics::Tactics::replayJson(), eve::orders::CommandQueue::restore(), eve::production::WorkQueue::restore(), eve::definitions::DefinitionRegistry::restoreJson(), eve::policyregistry::PolicyRegistry::restoreJson(), eve::procgen::GtsTerrainExportSettings::restoreJson(), eve::procgen::GtsTerrainMeshSettings::restoreJson(), eve::procgen::GtsTerrainLodSet::restoreJson(), eve::procgen::TerrainBiomePreset::restoreJson(), eve::procgen::TerrainGenerationSession::restoreJson(), eve::ui::PcgPhotoModeValues::restoreJson(), eve::emergence::FactStore::restoreJson(), eve::emergence::RuleEngine::restoreJson(), eve::scene::LocationProfile::restoreJson(), eve::climbing::ClimbingRuntime::restoreJson(), eve::rpg::GameState::restoreSnapshotJson(), eve::rpg::Tracker::restoreSnapshotJson(), eve::rts::RTS::sellScriptBuilding(), eve::dialogue::ConversationDocument::setField(), eve::effects::EffectPayload::setJson(), eve::orders::OrderPayload::setJson(), eve::climbing::ClimbingRuntime::setProfileJson(), eve::authority::Store::snapshot(), eve::definitions::DefinitionRegistry::snapshot(), eve::game_event::GameEventLog::snapshot(), eve::policyregistry::PolicyRegistry::snapshot(), eve::production::WorkQueue::snapshot(), eve::statepatch::Store::snapshot(), eve::transaction::Ledger::snapshot(), eve::emergence::RuleEngine::snapshotJson(), eve::rpg::RPGSaveSession::snapshotJson(), eve::rts::RTS::startScriptConstruction() , 以及 eve::map::validateMapObjects().

◆ getIf() [1/2]

template<class T >
const T * eve::Value::getIf ( ) const
inlinenoexcept

Return a typed pointer, or nullptr when the kind differs.

返回
Borrowed const pointer into this Value's variant storage. @ownership Borrowed; this Value owns the storage. @nullable Yes when T is not the active type. @lifetime Valid until this Value is destroyed, moved, or assigned a different kind. @thread Affine to this Value; no synchronization. @reentrancy Does not invoke callbacks.

在文件 Value.h 第 180 行定义.

被这些函数引用 eve::dev::PlayTraceBuffer::append(), eve::weapon::compileSpellFragments(), eve::asset::cookCanonicalPcgGraph(), eve::climbing::decodeClimbingActionDefinition(), eve::climbing::decodeClimbingAnchorGraphDefinition(), eve::climbing::decodeClimbingProfileDefinition(), eve::production::WorkQueue::enqueue(), eve::physics::ClothModel::fromValue(), eve::physics::GeometryCollectionAsset::fromValue(), eve::physics::GeometryCollectionInstanceSnapshot::fromValue(), eve::action::ActionTimeline::fromValue(), eve::animation::DynamicBoneConfig::fromValue(), eve::asset_procgen::EvpackPointGraphLoader::load(), eve::asset_procgen::EvpackInstanceSetLoader::load(), eve::asset_procgen::EvpackTerrainMaterialLoader::load(), eve::asset_scene::EvpackSceneTemplateLoader::load(), eve::rts::RTSContentLoader::load(), eve::asset::parseEvaManifest(), eve::asset_import::prepareGltfImport(), eve::asset_import::prepareUnrealM4Import(), eve::vehicle::Vehicle::registerVehiclesFromJson(), eve::asset_import::gltf::resolveBuffers(), eve::physics::World::restore(), eve::physics::World3D::restore(), eve::climbing::ClimbingRuntime::restore(), eve::orders::CommandQueue::restore(), eve::definitions::DefinitionRegistry::restoreJson(), eve::policyregistry::PolicyRegistry::restoreJson(), eve::definition::restoreRuntimeInstance(), eve::graphics::GraphicsArtifactProvider::restoreState(), eve::physics::PhysicsArtifactProvider::restoreState() , 以及 eve::map::validateMapObjects().

◆ getIf() [2/2]

template<class T >
T * eve::Value::getIf ( )
inlinenoexcept

Return a mutable typed pointer, or nullptr when the kind differs.

返回
Borrowed mutable pointer into this Value's variant storage. @ownership Borrowed; this Value owns the storage. @nullable Yes when T is not the active type. @lifetime Valid until this Value is destroyed, moved, or assigned a different kind. @thread Affine to this Value; no synchronization. @reentrancy Does not invoke callbacks.

在文件 Value.h 第 194 行定义.

◆ integer()

static Value eve::Value::integer ( std::int64_t  value)
inlinestatic

Compatibility factory for an Int64 value.

在文件 Value.h 第 104 行定义.

引用了 value.

被这些函数引用 eve::dnut::SequenceRuntime::captureState() , 以及 eve::dialogue::toCanonicalValue().

◆ isArray()

◆ isBool()

bool eve::Value::isBool ( ) const
inlinenoexcept

◆ isDouble()

bool eve::Value::isDouble ( ) const
inlinenoexcept

Return true when this value is a Double.

在文件 Value.h 第 93 行定义.

引用了 type.

被这些函数引用 eve::action::ActionTimeline::fromValue(), eve::hexmap::hexTerrainBakeFromValue(), eve::asset_procgen::EvpackTerrainMaterialLoader::load() , 以及 toString().

◆ isInt64()

◆ isNull()

bool eve::Value::isNull ( ) const
inlinenoexcept

Return true when this value is null.

在文件 Value.h 第 87 行定义.

引用了 type.

被这些函数引用 eve::physics::ClothModel::fromValue() , 以及 eve::climbing::ClimbingRuntime::restore().

◆ isNumeric()

bool eve::Value::isNumeric ( ) const
inlinenoexcept

Return whether this value is an integer or finite number.

在文件 Value.h 第 159 行定义.

被这些函数引用 eve::hexmap::hexTerrainBakeFromValue() , 以及 eve::inventory::InventorySaveSession::prepareRestoreSnapshotJson().

◆ isObject()

◆ isString()

◆ keys()

std::vector< std::string > eve::Value::keys ( ) const

Return object member names in deterministic order.

在文件 Value.cpp 第 138 行定义.

引用了 key, object , 以及 value.

被这些函数引用 eve::dialogue::lintConversationWorkspace(), eve::rpg::GameState::restoreSnapshotJson() , 以及 eve::dnut::SequenceRuntime::start().

◆ kind()

Type eve::Value::kind ( ) const
inlinenoexcept

Compatibility spelling for the former dialogue data tree.

在文件 Value.h 第 85 行定义.

引用了 type.

被这些函数引用 eve::rpg::encodeSkillCondition().

◆ null()

static Value eve::Value::null ( )
inlinestatic

Compatibility factory for a null value.

在文件 Value.h 第 102 行定义.

被这些函数引用 eve::dialogue::toCanonicalValue().

◆ number()

static Value eve::Value::number ( double  value)
inlinestatic

Compatibility factory for a Double value.

在文件 Value.h 第 106 行定义.

引用了 value.

被这些函数引用 eve::dialogue::toCanonicalValue().

◆ object()

◆ operator==()

bool eve::Value::operator== ( const Value &  ) const
default

Compare two values recursively, including their numeric kinds.

◆ pushBack()

void eve::Value::pushBack ( Value  value)

Append an element to an array value.

在文件 Value.cpp 第 94 行定义.

引用了 array(), EV_ASSERT , 以及 value.

◆ set()

◆ storage() [1/2]

const Storage & eve::Value::storage ( ) const
inlinenoexcept

Return the immutable variant storage for visitors.

在文件 Value.h 第 166 行定义.

◆ storage() [2/2]

Storage & eve::Value::storage ( )
inlinenoexcept

Return mutable variant storage for owning edits.

在文件 Value.h 第 168 行定义.

◆ string()

◆ toJson()

Result< std::string > eve::Value::toJson ( ) const

Serialize this value as deterministic compact JSON.

返回
JSON text, or a SerializationError for NaN or infinity.
备注
Object keys are emitted in lexicographic order. Non-finite Double values are intentionally rejected rather than silently converted to null.

在文件 Value.cpp 第 67 行定义.

引用了 eve::json::stringify().

被这些函数引用 eve::statepatch::StatePatchStateAdapter::apply(), eve::rpg::Party::checkpointJson(), eve::rpg::RPGActor::checkpointJson(), eve::asset::cookCanonicalPcgGraph(), eve::asset::cookCanonicalVolumeTextureRgba8(), eve::editor::exposeActionTimelineScriptBindings(), eve::schema::SchemaRegistry::generateBindingContract(), eve::dialogue::ConversationDocument::getField(), eve::editor::ActionTimelineWidget::inspectSelection(), eve::schema::SchemaRegistry::migrate(), eve::rpg::RpgStorySession::Impl::persistProgress(), eve::asset_import::prepareGltfImport(), eve::asset_import::prepareImageImport(), eve::asset_import::prepareLegacyAnimationImport(), eve::asset_import::prepareUnityNativeMesh(), eve::asset_import::prepareUnityNativeVolumeTexture(), eve::asset_import::prepareUnityVegetationMaterial(), eve::asset::serializeEvaManifest(), eve::scene::LocationProfile::serializeJson(), eve::orders::CommandQueue::snapshot(), eve::definitions::DefinitionRegistry::snapshotJson(), eve::emergence::FactStore::snapshotJson(), eve::emergence::RuleEngine::snapshotJson(), eve::inventory::InventorySaveSession::snapshotJson(), eve::policyregistry::PolicyRegistry::snapshotJson(), eve::procgen::TerrainSpawnPlan::snapshotJson(), eve::rpg::GameState::snapshotJson(), eve::rpg::Tracker::snapshotJson(), eve::effects::EffectPayload::toJson(), eve::orders::OrderPayload::toJson(), eve::physics::ClothModel::toJson(), eve::stylize::AttackVfxSkin::toJson(), eve::stylize::AttackVfxRecipe::toJson() , 以及 eve::stylize::MeshVfxAsset::toJson().

◆ toString()

std::string eve::Value::toString ( ) const

Render a scalar using the former dialogue formatting rules.

在文件 Value.cpp 第 163 行定义.

引用了 asBool(), asDouble(), asInt(), asString(), buffer, isBool(), isDouble(), isInt64() , 以及 isString().

◆ type()

Type eve::Value::type ( ) const
inlinenoexcept

Return the active value kind.

在文件 Value.h 第 83 行定义.

被这些函数引用 typeName().

◆ typeName()

std::string eve::Value::typeName ( ) const

Return the compatibility type name used by dialogue scripts.

在文件 Value.cpp 第 150 行定义.

引用了 Array, Bool, Double, Int64, Null, Object, String , 以及 type().

被这些函数引用 eve::dialogue::Dialogue::getVarType().


该类的文档由以下文件生成: