Qpid C++ Messaging API  1.39.0
Uuid.h
1 #ifndef QPID_TYPES_UUID_H
2 #define QPID_TYPES_UUID_H
3 
4 /*
5  *
6  * Licensed to the Apache Software Foundation (ASF) under one
7  * or more contributor license agreements. See the NOTICE file
8  * distributed with this work for additional information
9  * regarding copyright ownership. The ASF licenses this file
10  * to you under the Apache License, Version 2.0 (the
11  * "License"); you may not use this file except in compliance
12  * with the License. You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing,
17  * software distributed under the License is distributed on an
18  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19  * KIND, either express or implied. See the License for the
20  * specific language governing permissions and limitations
21  * under the License.
22  *
23  */
24 
25 #include "qpid/types/ImportExport.h"
26 #include <iosfwd>
27 #include <string>
28 
29 namespace qpid {
30 namespace types {
31 
32 class QPID_TYPES_CLASS_EXTERN Uuid
33 {
34  public:
35  QPID_TYPES_EXTERN static const size_t SIZE;
40  QPID_TYPES_EXTERN Uuid(bool unique=false);
41  QPID_TYPES_EXTERN Uuid(const Uuid&);
42  QPID_TYPES_EXTERN Uuid& operator=(const Uuid&);
44  QPID_TYPES_EXTERN Uuid(const unsigned char* data16);
45  QPID_TYPES_EXTERN Uuid(const char* data16);
46 
48  QPID_TYPES_EXTERN void generate();
49 
51  QPID_TYPES_EXTERN void clear();
52 
54  QPID_TYPES_EXTERN bool isNull() const;
55  QPID_TYPES_EXTERN operator bool() const;
56  QPID_TYPES_EXTERN bool operator!() const;
57 
59  QPID_TYPES_EXTERN std::string str() const;
60 
61  QPID_TYPES_EXTERN size_t size() const;
62  QPID_TYPES_EXTERN const unsigned char* data() const;
63 
64  friend QPID_TYPES_EXTERN bool operator==(const Uuid&, const Uuid&);
65  friend QPID_TYPES_EXTERN bool operator!=(const Uuid&, const Uuid&);
66  friend QPID_TYPES_EXTERN bool operator<(const Uuid&, const Uuid&);
67  friend QPID_TYPES_EXTERN bool operator>(const Uuid&, const Uuid&);
68  friend QPID_TYPES_EXTERN bool operator<=(const Uuid&, const Uuid&);
69  friend QPID_TYPES_EXTERN bool operator>=(const Uuid&, const Uuid&);
70  friend QPID_TYPES_EXTERN std::ostream& operator<<(std::ostream&, Uuid);
71  friend QPID_TYPES_EXTERN std::istream& operator>>(std::istream&, Uuid&);
72 
74  QPID_TYPES_EXTERN size_t hash() const;
75 
77  struct Hasher {
78  size_t operator()(const Uuid& u) const { return u.hash(); }
79  };
80 
81  private:
82  unsigned char bytes[16];
83 };
84 
86 inline size_t hash_value(const Uuid& uuid) { return uuid.hash(); }
87 
89 QPID_TYPES_EXTERN bool operator==(const Uuid&, const Uuid&);
91 QPID_TYPES_EXTERN bool operator!=(const Uuid&, const Uuid&);
92 
93 QPID_TYPES_EXTERN bool operator<(const Uuid&, const Uuid&);
94 QPID_TYPES_EXTERN bool operator>(const Uuid&, const Uuid&);
95 QPID_TYPES_EXTERN bool operator<=(const Uuid&, const Uuid&);
96 QPID_TYPES_EXTERN bool operator>=(const Uuid&, const Uuid&);
97 
99 QPID_TYPES_EXTERN std::ostream& operator<<(std::ostream&, Uuid);
100 
102 QPID_TYPES_EXTERN std::istream& operator>>(std::istream&, Uuid&);
103 
104 }} // namespace qpid::types
105 
106 
107 #endif
Definition: Uuid.h:32
QPID_TYPES_EXTERN size_t hash() const
Definition: Uuid.h:77
Definition: Address.h:32