diff options
author | Martin Sustrik <sustrik@250bpm.com> | 2010-02-24 13:02:29 +0100 |
---|---|---|
committer | Martin Sustrik <sustrik@250bpm.com> | 2010-02-24 13:02:29 +0100 |
commit | 476ebde6280a428e2dd8fee7c70670aa449831c9 (patch) | |
tree | 4b2016241a614d232f95a2800c22f8d43beaf568 /src/uuid.hpp | |
parent | cc5c30f5dc2d6490c0199709ceb2d86e3cc3895d (diff) |
use binary UUIDs instead of string representation to save some bytes
Diffstat (limited to 'src/uuid.hpp')
-rw-r--r-- | src/uuid.hpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/uuid.hpp b/src/uuid.hpp index 03bb69d..dfaef01 100644 --- a/src/uuid.hpp +++ b/src/uuid.hpp @@ -52,20 +52,32 @@ namespace zmq // free the allocated memory. const char *to_string (); + // The length of binary representation of UUID. + enum { uuid_blob_len = 16 }; + + const unsigned char *to_blob (); + private: + // Converts one byte from hexa representation to binary. + unsigned char convert_byte (const char *hexa_); + + // Converts string representation of UUID into standardised BLOB. + // The function is endianness agnostic. + void create_blob (); + #if defined ZMQ_HAVE_WINDOWS #ifdef ZMQ_HAVE_MINGW32 typedef unsigned char* RPC_CSTR; #endif ::UUID uuid; - RPC_CSTR uuid_str; + RPC_CSTR string_buf; #elif defined ZMQ_HAVE_FREEBSD || defined ZMQ_HAVE_NETBSD ::uuid_t uuid; - char *uuid_str; + char *string_buf; #elif defined ZMQ_HAVE_LINUX || defined ZMQ_HAVE_SOLARIS || defined ZMQ_HAVE_OSX ::uuid_t uuid; - char uuid_buf [uuid_string_len + 1]; + char string_buf [uuid_string_len + 1]; #else // RFC 4122 UUID's fields uint32_t time_low; @@ -75,8 +87,10 @@ namespace zmq uint8_t clock_seq_low; uint8_t node [6]; - char uuid_buf [uuid_string_len + 1]; + char string_buf [uuid_string_len + 1]; #endif + + unsigned char blob_buf [uuid_blob_len]; }; } |