Id.h header

#include <ew/core/Id.h>

Namespace ew::core

Id class

class ew::core::Id

A stable, globally-unique identity value that wraps a UUID, so references survive renames and moves and resolve across mounted libraries (DESIGN.md: references resolve by UUID). The phantom Tag parameter makes ids of different kinds (e.g. content object vs taxonomy category) distinct, incompatible types that cannot be assigned or compared to one another. A default-constructed id is null.

Members

ew::core::Id< Tag >::Id()=default

Constructs a null id (identifies nothing).

ew::core::Id< Tag >::Id(QUuid uuid)

Wraps an existing UUID.

bool ew::core::Id< Tag >::isNull() const

Returns true if this id is null.

QString ew::core::Id< Tag >::toString() const

Returns the canonical string form (RFC 4122, without surrounding braces).

QUuid ew::core::Id< Tag >::uuid() const

Returns the underlying UUID.

static Id ew::core::Id< Tag >::generate()

Creates a new random (v4) id.

static Id ew::core::Id< Tag >::fromString(QStringView text)

Parses an id from its canonical string form; returns a null id if invalid.

bool operator==(const Id &lhs, const Id &rhs)

Value equality of two ids of the same kind.

bool operator!=(const Id &lhs, const Id &rhs)

Value inequality of two ids of the same kind.

bool operator<(const Id &lhs, const Id &rhs)

Orders ids (deterministic) so they can key ordered containers and satisfy std::totally_ordered.

bool operator>(const Id &lhs, const Id &rhs)

Greater-than ordering (derived from operator<).

bool operator<=(const Id &lhs, const Id &rhs)

Less-than-or-equal ordering (derived from operator<).

bool operator>=(const Id &lhs, const Id &rhs)

Greater-than-or-equal ordering (derived from operator<).

size_t qHash(const Id &id, size_t seed=0)

Hash support so ids can key Qt hashed containers (QHash/QSet).