载入中...
搜索中...
未找到
ResourceRef.cpp
浏览该文件的文档.
10 return Result<T>::failure(Diagnostic::error(DiagnosticCode::ParseError, message, std::string(path)));
33 return parseFailure<AssetRef>("AssetRef requires an asset:// UUID without query or fragment", uri.format());
46 if (!logical) return parseFailure<DefinitionRef>("definition reference must be namespace:name", text);
57 if (!parsed || parsed->isNil()) return parseFailure<ObjectRef>("object reference must be a non-nil UUID", text);
87const ResourceUri* ResourceRef::uri() const noexcept { return std::get_if<ResourceUri>(&value_); }
89const DefinitionRef* ResourceRef::definition() const noexcept { return std::get_if<DefinitionRef>(&value_); }
Strong asset, definition, object and generic resource references.
static Result< AssetRef > fromId(PersistentId id)
Build an asset reference from a non-nil persistent identity.
Definition ResourceRef.cpp:26
static Result< AssetRef > parse(std::string_view text)
Parse an asset://<canonical UUID> reference.
Definition ResourceRef.cpp:20
static Result< AssetRef > fromUri(const ResourceUri &uri)
Convert an asset://<canonical UUID> ResourceUri to an AssetRef.
Definition ResourceRef.cpp:31
DefinitionRef()=default
Constructs an invalid reference for optional/component storage.
static Result< DefinitionRef > parse(std::string_view text)
Parse a namespace:name logical definition identifier.
Definition ResourceRef.cpp:44
static Result< DefinitionRef > fromId(LogicalId id)
Build a definition reference from a valid LogicalId.
Definition ResourceRef.cpp:50
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
Human-readable, scoped identifier in the form namespace:name.
Definition Identity.h:411
static std::optional< LogicalId > parse(std::string_view text)
Parses a scoped logical name.
Definition Identity.cpp:36
static Result< ObjectRef > parse(std::string_view text)
Parse a canonical UUID text as an object reference.
Definition ResourceRef.cpp:55
static Result< ObjectRef > fromId(PersistentId id)
Build an object reference from a non-nil persistent identity.
Definition ResourceRef.cpp:61
Type-safe union of the reference forms accepted by resource-facing APIs.
Definition ResourceRef.h:148
const AssetRef * asset() const noexcept
Return the AssetRef when active, otherwise null.
Definition ResourceRef.cpp:85
const ObjectRef * object() const noexcept
Return the ObjectRef when active, otherwise null.
Definition ResourceRef.cpp:91
const ResourceUri * uri() const noexcept
Return the ResourceUri when active, otherwise null.
Definition ResourceRef.cpp:87
const DefinitionRef * definition() const noexcept
Return the DefinitionRef when active, otherwise null.
Definition ResourceRef.cpp:89
static Result< ResourceRef > parse(std::string_view text)
Parse a resource URI, specializing asset://UUID as AssetRef.
Definition ResourceRef.cpp:66
static Result< ResourceUri > parse(std::string_view text)
Parse a supported resource URI.
Definition Uri.cpp:168
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
std::string format() const
Formats the ID in lower-case canonical UUID text.
Definition Identity.h:173
static std::optional< Id128 > parse(std::string_view text) noexcept
Parses canonical UUID text.
Definition Identity.h:151
@ ParseError
@ Asset
@ Definition
@ Asset
@ Object