载入中...
搜索中...
未找到
Identity.h
浏览该文件的文档.
67[[nodiscard]] EVENGINE_API std::optional<UuidBytes> parseUuidText(std::string_view text) noexcept;
73[[nodiscard]] EVENGINE_API UuidBytes childUuidBytes(const UuidBytes& parent, std::string_view role) noexcept;
223 friend constexpr auto operator<=>(const Id128& lhs, const Id128& rhs) noexcept { return lhs.bytes_ <=> rhs.bytes_; }
323 explicit UuidIdAdapter(const char* value) : UuidIdAdapter(std::string_view(value ? value : "")) {}
371 [[nodiscard]] std::string canonicalFormat() const { return detail::formatUuidBytes(state_.uuid); }
377 [[nodiscard]] bool isNil() const noexcept { return state_.spelling.empty() || Uuid(state_.uuid).isNil(); }
430 [[nodiscard]] static std::optional<LogicalId> fromParts(std::string_view namespaceName, std::string_view name);
Human-readable, scoped identifier in the form namespace:name.
Definition Identity.h:411
const std::string & format() const noexcept
Returns the canonical namespace:name representation.
Definition Identity.h:436
bool isValid() const noexcept
Returns whether this value contains a valid namespace and name.
Definition Identity.h:433
UUID-backed identifier adapter for legacy textual boundaries.
Definition Identity.h:314
bool isNil() const noexcept
True when the value is an empty or UUID nil identity.
Definition Identity.h:377
UuidIdAdapter(const char *value)
Constructs from a legacy spelling or canonical UUID text.
Definition Identity.h:323
friend bool operator==(const UuidIdAdapter &lhs, const UuidIdAdapter &rhs) noexcept
Operator ==.
Definition Identity.h:389
static UuidIdAdapter fromUuid(Uuid value)
Builds an adapter from an explicit canonical UUID.
Definition Identity.h:343
bool isCanonicalUuid() const noexcept
True when the input was canonical UUID text rather than legacy text.
Definition Identity.h:380
UuidIdAdapter(std::string value)
Constructs from a legacy spelling or canonical UUID text.
Definition Identity.h:326
const std::string & value() const noexcept
Returns the exact legacy or canonical compatibility spelling.
Definition Identity.h:362
friend auto operator<=>(const UuidIdAdapter &lhs, const UuidIdAdapter &rhs) noexcept
Orders adapter values by their canonical UUID projection.
Definition Identity.h:394
std::string canonicalFormat() const
Returns the canonical UUID projection as lower-case UUID text.
Definition Identity.h:371
bool empty() const noexcept
True when no compatibility spelling has been assigned.
Definition Identity.h:374
UuidIdAdapter(std::string_view value)
Constructs from a legacy spelling or canonical UUID text.
Definition Identity.h:329
std::uint64_t hash() const noexcept
Stable hash of the canonical UUID projection.
Definition Identity.h:383
static std::optional< UuidIdAdapter > parse(std::string_view value)
Parses canonical UUID text or a non-empty legacy spelling.
Definition Identity.h:336
const std::string & format() const noexcept
Returns the compatibility spelling; use canonicalFormat at persistence boundaries.
Definition Identity.h:365
static UuidIdAdapter fromLegacy(std::string value)
Builds an adapter while explicitly retaining a legacy spelling.
Definition Identity.h:352
UuidIdAdapter()=default
Constructs an empty compatibility identifier.
std::string format() const
Formats the ID in lower-case canonical UUID text.
Definition Identity.h:173
friend constexpr bool operator==(const Id128 &, const Id128 &) noexcept=default
Operator ==.
static std::optional< Id128 > fromBytes(std::span< const std::uint8_t > bytes) noexcept
Constructs an ID from exactly 16 bytes.
Definition Identity.h:161
constexpr bool isNil() const noexcept
Returns whether this value is the all-zero nil ID.
Definition Identity.h:176
static std::optional< Id128 > parse(std::string_view text) noexcept
Parses canonical UUID text.
Definition Identity.h:151
friend constexpr auto operator<=>(const Id128 &lhs, const Id128 &rhs) noexcept
Orders UUID bytes in network order for ordered containers.
Definition Identity.h:223
Id128 child(std::string_view role) const noexcept
Derives a deterministic child UUID for a hierarchical identity.
Definition Identity.h:192
static constexpr Id128 fromUuid(const Id128< OtherTag > &value) noexcept
Re-tags an existing UUID at an explicit domain boundary.
Definition Identity.h:136
constexpr std::uint64_t hash() const noexcept
Returns a stable non-cryptographic hash for hash tables.
Definition Identity.h:210
constexpr Bytes bytes() const noexcept
Returns the UUID bytes in network order.
Definition Identity.h:202
Tag-free state of a compatibility-aware UUID identity adapter.
Definition Identity.h:87
void assign(std::string_view text)
Assigns from canonical UUID text or from a legacy spelling.
Definition Identity.cpp:187
static UuidBytes projectLegacy(std::string_view text) noexcept
Builds the deterministic UUID projection of a legacy spelling.
Definition Identity.cpp:200
std::array< std::uint8_t, 16 > UuidBytes
Byte representation shared by every tagged 128-bit identity.
Definition Identity.h:54
std::string formatUuidBytes(const UuidBytes &bytes)
Formats UUID bytes as lower-case canonical 8-4-4-4-12 text.
Definition Identity.cpp:160
UuidBytes childUuidBytes(const UuidBytes &parent, std::string_view role) noexcept
Derives a deterministic child UUID from a parent and a role.
Definition Identity.cpp:172
std::optional< UuidBytes > parseUuidText(std::string_view text) noexcept
Parses canonical UUID text without knowing the domain tag.
Definition Identity.cpp:134
std::function< std::chrono::system_clock::time_point()> UuidClock
Clock callback used by the injectable UUIDv7 generator.
Definition Identity.h:469
std::function< bool(std::span< std::uint8_t > bytes)> UuidEntropySource
Entropy callback used by UUIDv7 generation.
Definition Identity.h:466
std::optional< PersistentId > generateUuidV7(std::chrono::system_clock::time_point timestamp, const UuidEntropySource &entropy)
Constructs a UUIDv7 without owning a clock or generator object.
Definition Identity.cpp:89
Definition Container.h:602