Index: src/OFUUID.h ================================================================== --- src/OFUUID.h +++ src/OFUUID.h @@ -46,15 +46,30 @@ * * @return An initialized OFUUID */ - (instancetype)init; +/** + * @brief Initializes an already allocated OFUUID with the specified bytes. + * + * @param bytes The bytes to initialize the OFUUID with + * @return An initialized OFUUID + */ +- (instancetype)initWithUUIDBytes: (const unsigned char [_Nonnull 16])bytes; + /** * @brief Compares the UUID to another UUID. * * @param UUID The UUID to compare to * @return The result of the comparison */ - (OFComparisonResult)compare: (OFUUID *)UUID; + +/** + * @brief Gets the bytes of the UUID. + * + * @param bytes An array of 16 bytes into which to write the UUID + */ +- (void)getUUIDBytes: (unsigned char [_Nonnull 16])bytes; @end OF_ASSUME_NONNULL_END Index: src/OFUUID.m ================================================================== --- src/OFUUID.m +++ src/OFUUID.m @@ -42,10 +42,19 @@ _bytes[8] &= ~(1 << 6); _bytes[8] |= (1 << 7); return self; } + +- (instancetype)initWithUUIDBytes: (const unsigned char [16])bytes +{ + self = [super init]; + + memcpy(_bytes, bytes, sizeof(_bytes)); + + return self; +} - (bool)isEqual: (id)object { OFUUID *UUID; @@ -89,10 +98,15 @@ if (comparison > 0) return OFOrderedDescending; else return OFOrderedAscending; } + +- (void)getUUIDBytes: (unsigned char [16])bytes +{ + memcpy(bytes, _bytes, sizeof(_bytes)); +} - (OFString *)UUIDString { return [OFString stringWithFormat: @"%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-"