diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2021-09-20 13:15:37 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2021-09-20 13:15:37 +0300 |
commit | 029d042e8518c53dffe2471d113d5daf4acf97d3 (patch) | |
tree | ed88fba74f93666ad35708a5a0ec829cc3a0dd59 /source/blender/blenlib/intern | |
parent | 07b482c2ffdf88c6930b621bb0b18c3a5d0c0130 (diff) |
UUID: add nil value for UUIDs
Add `BLI_uuid_nil()` that returns the nil UUID (used to indicate "not
set") and `BLI_uuid_is_nil(uuid)` to do an equality test with the nil
value.
Diffstat (limited to 'source/blender/blenlib/intern')
-rw-r--r-- | source/blender/blenlib/intern/uuid.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/uuid.cc b/source/blender/blenlib/intern/uuid.cc index 5d4f7e1a520..f5edb356acc 100644 --- a/source/blender/blenlib/intern/uuid.cc +++ b/source/blender/blenlib/intern/uuid.cc @@ -78,6 +78,17 @@ UUID BLI_uuid_generate_random() return uuid; } +UUID BLI_uuid_nil(void) +{ + const UUID nil = {0, 0, 0, 0, 0, 0}; + return nil; +} + +bool BLI_uuid_is_nil(UUID uuid) +{ + return BLI_uuid_equal(BLI_uuid_nil(), uuid); +} + bool BLI_uuid_equal(const UUID uuid1, const UUID uuid2) { return std::memcmp(&uuid1, &uuid2, sizeof(uuid1)) == 0; |