24 Nov 17:59
Re: [Review] UUID library (mini-)review starts today, November 23rd
Paul A. Bristow <pbristow <at> hetp.u-net.com>
2008-11-24 16:59:10 GMT
2008-11-24 16:59:10 GMT
> -----Original Message----- > From: boost-bounces <at> lists.boost.org [mailto:boost-bounces <at> lists.boost.org] On > Behalf Of Hartmut Kaiser > Sent: 24 November 2008 00:14 > To: boost <at> lists.boost.org; boost-users <at> lists.boost.org; boost- > announce <at> lists.boost.org > Subject: [boost] [Review] UUID library (mini-)review starts today, November 23rd > > The mini-review of Andy Tompkins UUID library starts today, November 23rd > 2008, and will end on November 30th. > I really hope to see your vote and your participation in the discussions on > the Boost mailing lists! > > The library can be downloaded from the vault here (it's the file > uuid_v13.zip in the topmost directory): http://tinyurl.com/6xx28b > > The initial review of the UUID library ended with a provisional acceptance > (read here: http://article.gmane.org/gmane.comp.lib.boost.user/27774/). Re-reading the docs, I can't see any reasons against acceptance. Nits: I note that the docs uuid.html copyright date is still only 2006. And it does not list/link all the tests. Mis spelling of 'hexidecimal' The external representation of a uuid is a string of hexidecimal digits Note: boost::uuids::uuid::size() always returnes 16. Mispelled 'returnes' Is there a reason why create does not also take a std::string (with default length .size() as parameter?) // Static functions static uuid create(uuid const& namespace_uuid, char const* name, int name_length); I assumed it would exist and was surprised when it didn't. (Should the name_length have a default value? C-string size - 1?) I also believe that a really basic example would be useful. This helps novices. A little demo I knocked up quickly attached. (MSVC 8 Sp1) It reveals that the hated 4996 warnings are triggered (at default MS warning level 3). I think these need to be suppressed with push'n'popping. Also I got a faceful of these at warning level 4. Again they should be suppressed. 1>I:\boost_1_37_0\boost/random/detail/pass_through_engine.hpp(49) : warning C4512: 'boost::random::detail::pass_through_engine<UniformRandomNumberGenerator>' : assignment operator could not be generated 1>H:\uuid\boost/uuid/uuid.hpp(364) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data Should be silenced using a static_cast? c = static_cast<ch>(is.peek()); But overall this seems 'OK to ship'. HTH Paul --- Paul A. Bristow Prizet Farmhouse Kendal, UK LA8 8AB +44 1539 561830, mobile +44 7714330204 pbristow <at> hetp.u-net.com
// Copyright Paul A. Bristow. // Permission to copy, use, modify, sell and // distribute this software is granted provided this copyright notice appears // in all copies. This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // libs/uuid/example/example.cpp -------------------------------// #define _CRT_SECURE_NO_WARNINGS // h:\uuid\boost\uuid\seed_rng.hpp(132) : warning C4996: 'fopen': // This function or variable may be unsafe. Consider using fopen_s instead. // To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. // c:\program files\microsoft visual studio 9.0\vc\include\stdio.h(237) : // see declaration of 'fopen' #define _SCL_SECURE_NO_WARNINGS #include <boost/uuid/uuid.hpp> #include <boost/uuid/seed_rng.hpp> #include <iostream> #include <string> #include <vector> using std::cout; using std::endl; using std::string; using std::vector; using std::copy; using std::ostream_iterator; int main() { using boost::uuids::uuid; using boost::uuids::uuid_generator; using boost::uuids::showbraces; using boost::uuids::noshowbraces; uuid u; // Default constructor makes a null string - boring! cout << u << endl; // 00000000-0000-0000-0000-000000000000 if (u.is_null()) { cout << "uuid is null!" << endl; // uuid is null! } // Create from a std string. string s1("01234567-89ab-cdef-0123-456789abcdef"); uuid us1(s1); cout << us1 << endl; // 01234567-89ab-cdef-0123-456789abcdef // Or a C string. const char* s2 = "{76543210-89ab-cdef-0123-456789abcdef}"; uuid uc1(s2); cout << uc1 << endl; // 76543210-89ab-cdef-0123-456789abcdef // and also show {} braces around string. cout << showbraces << uc1 << endl; // {76543210-89ab-cdef-0123-456789abcdef} cout << uc1 << endl; // {76543210-89ab-cdef-0123-456789abcdef} // Get at the UUID individual bytes. vector<char> v(u.size()); // Always 16. copy(us1.begin(), us1.end(), v.begin()); cout << "Length in bytes is " << v.size() << ", and values are: " << endl; for (int i = 0; i < 16; i++) { cout << int(v[i]) << " "; } // 1 35 69 103 -119 -85 -51 -17 1 35 69 103 -119 -85 -51 -17 cout << endl; // Create uuid from name. uuid dns_namespace_uuid("6ba7b810-9dad-11d1-80b4-00c04fd430c8"); const char* url = "www.boost.org"; uuid uurl = boost::uuids::uuid::create(dns_namespace_uuid, url, 13); cout << uurl << endl; string suurl = uurl.to_string(); cout << suurl << endl; // ccb046db-74eb-53c9-9b6b-3ce5740dd29e // Generate uuid from random number, different every time. uuid_generator ur; // cout << showbraces << ur() << endl; // {f850857f-86cb-4518-ba45-c826aac45a03} cout << ur() << endl; // {b04004aa-c261-4a91-a79f-357d71780d0c} cout << ur() << endl; // {b305b7e1-80ef-4fa9-beed-c26b86a08cbb} // Note showbraces 'sticks' until noshowbraces. cout << noshowbraces << ur() << endl; // b305b7e1-80ef-4fa9-beed-c26b86a08cbb uuid u1 = ur(); uuid u2 = ur(); if (u1 == u2) { cout << "Ooops - UUIDs should be unique!" << endl; } } // int main() /* Output: 1>Autorun "h:\uuid\libs\uuid\Example\Example\Debug\Example.exe" 1>00000000-0000-0000-0000-000000000000 1>uuid is null! 1>01234567-89ab-cdef-0123-456789abcdef 1>76543210-89ab-cdef-0123-456789abcdef 1>{76543210-89ab-cdef-0123-456789abcdef} 1>{76543210-89ab-cdef-0123-456789abcdef} 1>Length in bytes is 16, and values are: 1>1 35 69 103 -119 -85 -51 -17 1 35 69 103 -119 -85 -51 -17 1>{ccb046db-74eb-53c9-9b6b-3ce5740dd29e} 1>ccb046db-74eb-53c9-9b6b-3ce5740dd29e 1>{d0b211fd-6e42-4112-8270-dd470f0ccb08} 1>{6fa9bc27-ee4b-4d52-ac83-0868e94698ab} 1>{9fc020e5-54ea-4e42-b716-7b8c89e5b5f0} 1>b3e3936b-e6f1-4909-915a-8c7a4aba76a6 1>Build Time 0:02 */
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
RSS Feed