Andy Tompkins | 5 Dec 15:58
Favicon

Re: [Review] UUID library (mini-)review starts today, November 23rd

On Tue, 2 Dec 2008 00:00:32 -0500, "Scott McMurray"
<me22.ca+boost <at> gmail.com> said:
> On Mon, Dec 1, 2008 at 21:05, Christian Holmquist
> <c.holmquist <at> gmail.com> wrote:
> >
> > is_null() What does this mean? Ah, ok, from the docs I see it's a
> > magic uuid (all zero) that is_null. Maybe is_zero() would be more
> > clear?
> >
>
> I also prefer using zero in the name.  That said,
> http://www.faqs.org/rfcs/rfc4122.html calls it the "nil" UUID.  But
> .NET calls it Guid.Empty, and python seems to only call it
> uuid.UUID(), so nil may not be any clearer.
>
> Though really, why not just call it operator unspecified_bool_type?
>
> assert(!int() && !shared_ptr<T>() && !uuid());

Fair.  I can add operator unspecified_bool_type.  And, possibility
remove null().

> >
> > static uuid create(uuid const& namespace_uuid, char const* name, int
> > name_length); Can this be a generator instead?
> >
> > std::string name="www.widgets.com"; name_based_generator
> > gen(name.begin(), name.end()); uuid id = gen();
> >
>
> A generator seems logical.  I certainly don't like the char*+length
> version.

Agreed.

> std::string name="www.widgets.com"; 
> sha1_name_based_generator gen(dns_namespace_uuid); 
> uuid id = gen(name); 
> uuid id2 = gen(name.begin(), name.end());
> assert(id == id2)
>
> I'd rather know whether it was v3 or v5 somewhere more obvious than
> the design notes, though.  If I were using v3 (MD5) uuids and switched
> to boost not knowing that v5 (SHA1) uuids exist, I'd likely be very
> confused when my code stops working with my data.

Hmm, I'd be surprised if your code stopped working.  But regardless, 
would it be enough to add a/some member functions to uuid so that one 
could ask what type of uuid it was?  For example:

boost::uuids::uuid u;
// generate a uuid

bool bIsV3 = u.is_v3();
//or
boost::uuids::uuid::version_type v = u.version();

Regards,
Andy Tompkins

Gmane