]>
git.proxmox.com Git - ceph.git/blob - ceph/src/include/uuid.h
98ee4b70be1feecab5389e68481a795b08966c8c
5 * Thin C++ wrapper around libuuid.
11 #include <boost/uuid/uuid.hpp>
12 #include <boost/uuid/uuid_generators.hpp>
13 #include <boost/uuid/uuid_io.hpp>
14 #include <boost/random/random_device.hpp>
17 boost::uuids::uuid uuid
;
20 boost::uuids::nil_generator gen
;
24 bool is_zero() const {
28 void generate_random() {
29 boost::random::random_device
rng("/dev/urandom");
30 boost::uuids::basic_random_generator
<boost::random::random_device
> gen(&rng
);
34 bool parse(const char *s
) {
36 boost::uuids::string_generator gen
;
39 } catch (std::runtime_error
& e
) {
43 void print(char *s
) const {
44 memcpy(s
, boost::uuids::to_string(uuid
).c_str(), 37);
47 std::string
to_string() const {
48 return boost::uuids::to_string(uuid
);
52 return (char*)uuid
.data
;
55 void encode(bufferlist
& bl
) const {
56 ::encode_raw(uuid
, bl
);
59 void decode(bufferlist::iterator
& p
) const {
60 ::decode_raw(uuid
, p
);
63 WRITE_CLASS_ENCODER(uuid_d
)
65 inline std::ostream
& operator<<(std::ostream
& out
, const uuid_d
& u
) {
71 inline bool operator==(const uuid_d
& l
, const uuid_d
& r
) {
72 return l
.uuid
== r
.uuid
;
74 inline bool operator!=(const uuid_d
& l
, const uuid_d
& r
) {
75 return l
.uuid
!= r
.uuid
;
77 inline bool operator<(const uuid_d
& l
, const uuid_d
& r
) {
78 return l
.to_string() < r
.to_string();