From a59904af646960340cb083fc516b84f74314e09e Mon Sep 17 00:00:00 2001 From: reuk Date: Mon, 20 May 2024 14:56:22 +0100 Subject: [PATCH] UUID: Add size() getter to facilitate safer access to bytes --- modules/juce_core/misc/juce_Uuid.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/juce_core/misc/juce_Uuid.h b/modules/juce_core/misc/juce_Uuid.h index a038912142..37d1e51588 100644 --- a/modules/juce_core/misc/juce_Uuid.h +++ b/modules/juce_core/misc/juce_Uuid.h @@ -128,6 +128,9 @@ public: */ const uint8* getRawData() const noexcept { return uuid; } + /** Returns the size in bytes of the raw data making up this UUID. */ + static constexpr size_t size() { return sizeInBytes; } + /** Creates a UUID from a 16-byte array. @see getRawData */ @@ -136,10 +139,10 @@ public: /** Sets this UUID from 16-bytes of raw data. */ Uuid& operator= (const uint8* rawData) noexcept; - private: //============================================================================== - uint8 uuid[16]; + static constexpr size_t sizeInBytes = 16; + uint8 uuid[sizeInBytes]; String getHexRegion (int, int) const; int compare (Uuid) const noexcept;