Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2021-09-23 18:55:43 +0300
committerSybren A. Stüvel <sybren@blender.org>2021-09-23 18:58:20 +0300
commitbd63944a739b4dcd49e8a65294ffb1b8a0a7b20b (patch)
tree583d81aa9a9257ef96e69b20d18e760f42ffa839 /source/blender/blenlib/intern/uuid.cc
parent942fc9f467c104150a474eb61a82957b5c9715f7 (diff)
UUID: place C++ code in correct namespace
Put the `bUUID` class in the `blender` namespace, instead of the `blender::bke` namespace. As a result, some C++ code now correctly uses the C++ class, where previously it would use the C struct and use implicit casting where necessary. As a result, support for initializer lists had to be explicitly coded and in another place an explicit `::bUUID` was necessary to avoid ambiguity.
Diffstat (limited to 'source/blender/blenlib/intern/uuid.cc')
-rw-r--r--source/blender/blenlib/intern/uuid.cc22
1 files changed, 19 insertions, 3 deletions
diff --git a/source/blender/blenlib/intern/uuid.cc b/source/blender/blenlib/intern/uuid.cc
index c1f7f8dfecd..cdb430c046a 100644
--- a/source/blender/blenlib/intern/uuid.cc
+++ b/source/blender/blenlib/intern/uuid.cc
@@ -18,6 +18,7 @@
* \ingroup bli
*/
+#include "BLI_assert.h"
#include "BLI_uuid.h"
#include <cstdio>
@@ -139,7 +140,22 @@ std::ostream &operator<<(std::ostream &stream, bUUID uuid)
return stream;
}
-namespace blender::bke {
+namespace blender {
+
+bUUID::bUUID(const std::initializer_list<uint> field_values)
+{
+ BLI_assert_msg(field_values.size() == 11, "bUUID requires 5 regular fields + 6 `node` values");
+
+ auto field_iter = field_values.begin();
+
+ this->time_low = static_cast<uint32_t>(*field_iter++);
+ this->time_mid = static_cast<uint16_t>(*field_iter++);
+ this->time_hi_and_version = static_cast<uint16_t>(*field_iter++);
+ this->clock_seq_hi_and_reserved = static_cast<uint8_t>(*field_iter++);
+ this->clock_seq_low = static_cast<uint8_t>(*field_iter++);
+
+ std::copy(field_iter, field_values.end(), this->node);
+}
bUUID::bUUID(const std::string &string_formatted_uuid)
{
@@ -163,9 +179,9 @@ uint64_t bUUID::hash() const
return uuid_as_int64[0] ^ uuid_as_int64[1];
}
-bool operator==(bUUID uuid1, bUUID uuid2)
+bool operator==(const bUUID uuid1, const bUUID uuid2)
{
return BLI_uuid_equal(uuid1, uuid2);
}
-} // namespace blender::bke
+} // namespace blender