Files
fx/ds/include/blue/ds/uuid.h

51 lines
1.6 KiB
C

#ifndef BLUE_DS_UUID_H_
#define BLUE_DS_UUID_H_
#include <blue/core/macros.h>
#include <blue/core/status.h>
#include <blue/ds/string.h>
#define B_UUID_NBYTES 16
#define B_UUID_STRING_MAX 37
B_DECLS_BEGIN;
#define B_TYPE_UUID (b_uuid_get_type())
B_DECLARE_TYPE(b_uuid);
B_TYPE_CLASS_DECLARATION_BEGIN(b_uuid)
B_TYPE_CLASS_DECLARATION_END(b_uuid)
typedef union b_uuid_bytes {
uint8_t uuid_bytes[B_UUID_NBYTES];
uint16_t uuid_words[B_UUID_NBYTES / 2];
uint32_t uuid_dwords[B_UUID_NBYTES / 4];
uint64_t uuid_qwords[B_UUID_NBYTES / 8];
} b_uuid_bytes;
BLUE_API b_type b_uuid_get_type(void);
B_TYPE_DEFAULT_CONSTRUCTOR(b_uuid, B_TYPE_UUID);
BLUE_API b_uuid *b_uuid_create_from_bytes(
unsigned char u00, unsigned char u01, unsigned char u02,
unsigned char u03, unsigned char u04, unsigned char u05,
unsigned char u06, unsigned char u07, unsigned char u08,
unsigned char u09, unsigned char u10, unsigned char u11, unsigned char u12,
unsigned char u13, unsigned char u14, unsigned char u15);
BLUE_API b_uuid *b_uuid_create_from_bytev(const unsigned char bytes[B_UUID_NBYTES]);
BLUE_API b_uuid *b_uuid_create_from_uuid_bytes(const b_uuid_bytes *bytes);
BLUE_API b_uuid *b_uuid_create_from_string(const b_string *string);
BLUE_API b_uuid *b_uuid_create_from_cstr(const char *s);
BLUE_API b_status b_uuid_to_cstr(const b_uuid *uuid, char out[B_UUID_STRING_MAX]);
BLUE_API void b_uuid_get_bytes(
const b_uuid *uuid, unsigned char bytes[B_UUID_NBYTES]);
BLUE_API void b_uuid_get_uuid_bytes(const b_uuid *uuid, b_uuid_bytes *bytes);
BLUE_API b_uuid_bytes *b_uuid_ptr(b_uuid *uuid);
B_DECLS_END;
#endif