Files
wizapp-stdlib/src/uuid/uuid.h

38 lines
886 B
C

// vim:fileencoding=utf-8:foldmethod=marker
#ifndef UUID_H
#define UUID_H
#include "../common/aliases/aliases.h"
#include "../common/platform/platform.h"
#include "../base/strings/str8/str8.h"
#ifdef WAPP_PLATFORM_CPP
BEGIN_C_LINKAGE
#endif // !WAPP_PLATFORM_CPP
#define UUID_BUF_LENGTH 48
#define WAPP_UUID_SPEC WAPP_STR8_SPEC
#define wapp_uuid_varg(WUUID) wapp_str8_varg((WUUID).uuid)
typedef struct wapp_uuid WUUID;
struct wapp_uuid {
Str8 uuid;
};
#define wapp_uuid_gen_uuid4() *(wapp_uuid_init_uuid4(&wapp_uuid_create()))
/* Low level UUID API */
#define wapp_uuid_create() ((WUUID){.uuid = wapp_str8_buf(UUID_BUF_LENGTH)})
// Just returns the same pointer that was passed in with the UUID initialised.
// Fails when passed a NULL pointer.
WUUID *wapp_uuid_init_uuid4(WUUID *uuid);
#ifdef WAPP_PLATFORM_CPP
END_C_LINKAGE
#endif // !WAPP_PLATFORM_CPP
#endif // !UUID_H