Files
bluelib/object/include/blue/object/uuid.h

53 lines
1.7 KiB
C

#ifndef BLUELIB_UUID_H_
#define BLUELIB_UUID_H_
#include <blue/core/status.h>
#include <blue/object/object.h>
#include <blue/object/type.h>
#define B_UUID(p) ((b_uuid *)(p))
#define B_UUID_NBYTES 16
#define B_UUID_STRING_MAX 37
struct b_string;
struct b_stringstream;
typedef struct b_uuid b_uuid;
typedef struct b_uuid_bytes {
unsigned char uuid_bytes[B_UUID_NBYTES];
} b_uuid_bytes;
BLUE_API b_uuid *b_uuid_create(void);
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 struct b_string *string);
BLUE_API b_uuid *b_uuid_create_from_cstr(const char *s);
static inline b_uuid *b_uuid_retain(b_uuid *uuid)
{
return B_UUID(b_retain(B_OBJECT(uuid)));
}
static inline void b_uuid_release(b_uuid *uuid)
{
b_release(B_OBJECT(uuid));
}
BLUE_API b_status b_uuid_to_string(const b_uuid *uuid, struct b_string *out);
BLUE_API b_status b_uuid_to_cstr(const b_uuid *uuid, char out[B_UUID_STRING_MAX]);
BLUE_API b_status b_uuid_to_stringstream(
const b_uuid *uuid, struct b_stringstream *out);
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);
#endif