First official checkin.
5 * Created by Jens Alfke on 8/18/09.
6 * Copyright 2009 Jens Alfke. All rights reserved.
7 * BSD-Licensed: See the file "LICENSE.txt" for details.
14 #include <CoreFoundation/CFUUID.h>
21 Blob::Blob (const char *str)
23 length(str ?strlen(str) :0)
27 struct MutableBlob :public Blob {
28 MutableBlob(void *b, size_t len) :Blob(b,len) { }
29 void* mutableBytes() {return (void*)bytes;}
30 void freeBytes() {::free(mutableBytes()); bytes=NULL; length=0;}
32 MutableBlob Blob::copyBytes() const {
33 MutableBlob copy( malloc(length), length);
34 memcpy(copy.mutableBytes(), bytes, length);
43 /** Typical 128-bit universally-unique identifier. */
47 const void *bytes() const {return _bytes;}
48 bool operator== (const UUID&) const;
55 CFUUIDRef u = CFUUIDCreate(NULL);
56 CFUUIDBytes bytes = CFUUIDGetUUIDBytes(u);
57 memcpy(&_bytes, &bytes, sizeof(_bytes));
61 bool UUID::operator== (const UUID& u) const {
62 return memcmp(_bytes, u._bytes, sizeof(_bytes)) == 0;