diff --git a/libs/pbd/pbd/uuid.h b/libs/pbd/pbd/uuid.h index 16a67436b7..275b72648a 100644 --- a/libs/pbd/pbd/uuid.h +++ b/libs/pbd/pbd/uuid.h @@ -22,29 +22,35 @@ #define __pbd_uuid_h__ #include -#include +#include +#include namespace PBD { -class UUID { +class UUID : public boost::uuids::uuid { public: - UUID () { uuid_generate (id); } - UUID (UUID const & other) { uuid_copy (id, other.id); } - UUID (std::string const & str) { uuid_parse (str.c_str(), id); } - - UUID& operator= (std::string const & str); - std::string to_s () const; - - bool operator== (UUID const & other) const { return !uuid_compare (id, other.id); } - bool operator!= (UUID const & other) const { return uuid_compare (id, other.id); } - bool operator< (UUID const & other) const { return uuid_compare (id, other.id) < 0; } - - operator bool() const { return !uuid_is_null (id); } + UUID () + : boost::uuids::uuid (boost::uuids::random_generator()()) {} + UUID (std::string const & str) + : boost::uuids::uuid (boost::uuids::string_generator()(str)) {} + + explicit UUID (boost::uuids::uuid const& u) + : boost::uuids::uuid(u) + {} - private: - uuid_t id; + operator boost::uuids::uuid() { + return static_cast(*this); + } + + operator boost::uuids::uuid() const { + return static_cast(*this); + } + UUID& operator= (std::string const & str); + std::string to_s () const; + + operator bool() const { return !is_nil(); } }; } // namespace PBD diff --git a/libs/pbd/uuid.cc b/libs/pbd/uuid.cc index 0ffeca23cb..1a988b9820 100644 --- a/libs/pbd/uuid.cc +++ b/libs/pbd/uuid.cc @@ -25,14 +25,13 @@ using namespace PBD; UUID& UUID::operator= (std::string const & str) { - uuid_parse (str.c_str(), id); + boost::uuids::string_generator gen; + *((boost::uuids::uuid*) this) = gen (str); return *this; } std::string UUID::to_s () const { - char buf[37]; - uuid_unparse (id, buf); - return std::string (buf); + return std::string ((const char*) data, size()); } diff --git a/libs/pbd/wscript b/libs/pbd/wscript index 69eafe4285..81d3634620 100644 --- a/libs/pbd/wscript +++ b/libs/pbd/wscript @@ -36,8 +36,6 @@ def configure(conf): conf.check_tool('compiler_cxx') autowaf.check_pkg(conf, 'libxml-2.0', uselib_store='XML') autowaf.check_pkg(conf, 'sigc++-2.0', uselib_store='SIGCPP', atleast_version='2.0') - if sys.platform != 'darwin': - autowaf.check_pkg(conf, 'uuid', uselib_store='UUID') conf.check(function_name='getmntent', header_name='mntent.h', define_name='HAVE_GETMNTENT') conf.check(header_name='execinfo.h', define_name='HAVE_EXECINFO') @@ -50,6 +48,7 @@ def configure(conf): # Boost headers autowaf.check_header(conf, 'boost/shared_ptr.hpp') autowaf.check_header(conf, 'boost/weak_ptr.hpp') + autowaf.check_header(conf, 'boost/uuid/uuid.hpp') def build(bld): # Library @@ -114,7 +113,7 @@ def build(bld): obj.includes = ['.'] obj.name = 'libpbd' obj.target = 'pbd' - obj.uselib = 'GLIBMM SIGCPP XML UUID SNDFILE' + obj.uselib = 'GLIBMM SIGCPP XML SNDFILE' if sys.platform == 'darwin': TaskGen.task_gen.mappings['.mm'] = TaskGen.task_gen.mappings['.cc'] obj.source += 'cocoa_open_uri.mm'