20 #include <coil/UUID.h> 24 #ifdef COIL_OS_FREEBSD 25 void error_code(uint32_t status)
27 if (status == uuid_s_ok)
28 std::cout <<
"uuid_s_ok" << std::endl;
29 else if (status == uuid_s_bad_version)
30 std::cout <<
"uuid_s_bad_version" << std::endl;
31 else if (status == uuid_s_invalid_string_uuid)
32 std::cout <<
"uuid_s_invalid_string_uuid" << std::endl;
33 else if (status == uuid_s_no_memory)
34 std::cout <<
"uuid_s_no_memory" << std::endl;
36 std::cout <<
"other error" << std::endl;
39 void uuid_clear(uuid_t& uu)
42 uuid_create_nil(&uu, &status);
44 void uuid_unparse(uuid_t& uu,
char*& uuidstr)
47 uuid_to_string(&uu, &uuidstr, &status);
49 void uuid_generate(uuid_t& out)
52 uuid_create(&out, &status);
59 #ifdef COIL_OS_FREEBSD 66 : m_uuid(uuid), m_uuidstr(0)
75 const char* UUID::to_string()
77 uuid_unparse(m_uuid, m_uuidstr);
82 UUID_Generator::UUID_Generator()
86 UUID_Generator::~UUID_Generator()
90 void UUID_Generator::init()
94 UUID* UUID_Generator::generateUUID(
int n,
int h)
98 return new UUID(uuid);
102 #if defined(COIL_OS_LINUX) || defined(COIL_OS_DARWIN) || defined(COIL_OS_CYGWIN) 104 UUID_Generator::UUID_Generator(){}
106 void UUID_Generator::init(){}
107 UUID* UUID_Generator::generateUUID(
int varsion,
int variant){
111 return new UUID(&uuid);
115 uuid_clear(this->_uuid);
119 strncpy((
char *)this->_uuid, (
char *)(*uuid),
sizeof(this->_uuid));
122 const char* UUID::to_string(){
123 uuid_unparse(this->_uuid, buf);
UUID()
UUID class constructor.
Common Object Interface Layer.